From 6105790a5bbfc3473a0e7338f53736c934ad6fba Mon Sep 17 00:00:00 2001 From: Darya Umrikhina Date: Thu, 11 Jul 2024 12:10:21 +0400 Subject: [PATCH] Login:Src:Utils: add new actions for Wizard --- packages/login/src/utils/actions.ts | 55 +++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/packages/login/src/utils/actions.ts b/packages/login/src/utils/actions.ts index 8ba2362e82..099395744d 100644 --- a/packages/login/src/utils/actions.ts +++ b/packages/login/src/utils/actions.ts @@ -36,6 +36,7 @@ import { TPortalCultures, TSettings, TThirdPartyProvider, + TTimeZone, TVersionBuild, } from "@docspace/shared/api/settings/types"; import { TUser } from "@docspace/shared/api/people/types"; @@ -161,7 +162,9 @@ export async function getPortalCultures() { return cultures.response as TPortalCultures; } -export async function getPortalPasswordSettings(confirmKey: string | null = null) { +export async function getPortalPasswordSettings( + confirmKey: string | null = null, +) { const [getPortalPasswordSettings] = createRequest( [`/settings/security/password`], [confirmKey ? ["Confirm", confirmKey] : ["", ""]], @@ -197,11 +200,57 @@ export async function getUserByEmail( user.displayName = Encoder.htmlDecode(user.displayName); } - console.log("user", user); - return user.response as TUser; } +export async function getMachineName(confirmKey: string | null = null) { + const [getMachineName] = createRequest( + [`/settings/machine`], + [confirmKey ? ["Confirm", confirmKey] : ["", ""]], + "GET", + ); + + const res = await fetch(getMachineName); + + if (!res.ok) return; + + const machineName = await res.json(); + + return machineName.response as string; +} + +export async function getIsLicenseRequired() { + const [getIsLicenseRequired] = createRequest( + [`/settings/license/required`], + [["", ""]], + "GET", + ); + + const res = await fetch(getIsLicenseRequired); + + if (!res.ok) return; + + const isLicenseRequire = await res.json(); + + return isLicenseRequire.response as boolean; +} + +export async function getPortalTimeZones(confirmKey: string | null = null) { + const [getPortalTimeZones] = createRequest( + [`/settings/timezones`], + [confirmKey ? ["Confirm", confirmKey] : ["", ""]], + "GET", + ); + + const res = await fetch(getPortalTimeZones); + + if (!res.ok) return; + + const portalTimeZones = await res.json(); + + return portalTimeZones.response as TTimeZone[]; +} + /* export async function checkConfirmLink(data: any): Promise { try { const [checkConfirmLink] = createRequest(