From 2bfde3088ce0751a17af2bef1ec7a7b595044bb9 Mon Sep 17 00:00:00 2001 From: Darya Umrikhina Date: Wed, 7 Aug 2024 13:51:21 +0400 Subject: [PATCH] Login:Src:Utils: add new actions --- packages/login/src/utils/actions.ts | 42 ++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/packages/login/src/utils/actions.ts b/packages/login/src/utils/actions.ts index dff1fa4d3f..52a42b9381 100644 --- a/packages/login/src/utils/actions.ts +++ b/packages/login/src/utils/actions.ts @@ -100,15 +100,15 @@ export async function getVersionBuild() { } export async function getColorTheme() { - const [getSettings] = createRequest( + const [getColorTheme] = createRequest( [`/settings/colortheme`], [["", ""]], "GET", ); - const res = await fetch(getSettings); + const res = await fetch(getColorTheme); - if (!res.ok) throw new Error(res.statusText); + if (!res.ok) return; const colorTheme = await res.json(); @@ -210,7 +210,7 @@ export async function getPortalCultures() { const res = await fetch(getPortalCultures); - if (!res.ok) throw new Error(res.statusText); + if (!res.ok) return; const cultures = await res.json(); @@ -472,6 +472,21 @@ export async function suspendPortal(confirmKey: string | null = null) { if (!res.ok) throw new Error(res.statusText); } +export async function continuePortal(confirmKey: string | null = null) { + const [continuePortal] = createRequest( + [`/portal/continue`], + [ + confirmKey ? ["confirm", confirmKey] : ["", ""], + ["Content-Type", "application/json;charset=utf-8"], + ], + "PUT", + ); + + const res = await fetch(continuePortal); + + if (!res.ok) throw new Error(res.statusText); +} + export async function changePassword( passwordHash: string, userId?: string, @@ -586,3 +601,22 @@ export async function deleteSelf(confirmKey: string | null = null) { if (!res.ok) throw new Error(res.statusText); } + +export async function deletePortal(confirmKey: string | null = null) { + const [deletePortal] = createRequest( + [`/portal/delete`], + [ + confirmKey ? ["Confirm", confirmKey] : ["", ""], + ["Accept", "application/json;charset=utf-8"], + ], + "DELETE", + ); + + const res = await fetch(deletePortal); + + if (!res.ok) throw new Error(res.statusText); + + const feedbackUrl = await res.json(); + + return feedbackUrl.response as string; +}