Login:Src:Components: remove withLoader

This commit is contained in:
Darya Umrikhina 2024-08-13 12:39:27 +04:00
parent d714eafee7
commit e754b93ccf
11 changed files with 90 additions and 88 deletions

View File

@ -37,15 +37,17 @@ import {
} from "@docspace/shared/components/text-input";
import { toastr } from "@docspace/shared/components/toast";
import { EmployeeActivationStatus } from "@docspace/shared/enums";
import { TPasswordHash } from "@docspace/shared/api/settings/types";
import {
TPasswordHash,
TPasswordSettings,
} from "@docspace/shared/api/settings/types";
import { createPasswordHash } from "@docspace/shared/utils/common";
import { PasswordInput } from "@docspace/shared/components/password-input";
import { ALLOWED_PASSWORD_CHARACTERS } from "@docspace/shared/constants";
import { Button, ButtonSize } from "@docspace/shared/components/button";
import { login } from "@docspace/shared/utils/loginUtils";
import withLoader from "@/HOCs/withLoader";
import { TActivateConfirmUser, TError, WithLoaderProps } from "@/types";
import { TActivateConfirmUser, TError } from "@/types";
import { RegisterContainer } from "../CreateUserForm/CreateUserForm.styled";
import { GreetingUserContainer } from "../CreateUserForm/sub-components/GreetingUserContainer";
@ -59,7 +61,8 @@ import {
type ActivateUserFormPorps = {
passwordHash: TPasswordHash;
defaultPage?: string;
} & WithLoaderProps;
passwordSettings?: TPasswordSettings;
};
const ActivateUserForm = ({
passwordSettings,
@ -294,4 +297,4 @@ const ActivateUserForm = ({
);
};
export default withLoader(ActivateUserForm);
export default ActivateUserForm;

View File

@ -34,15 +34,14 @@ import { Text } from "@docspace/shared/components/text";
import { toastr } from "@docspace/shared/components/toast";
import { ownerChange } from "@docspace/shared/api/settings";
import withLoader from "@/HOCs/withLoader";
import { TError, WithLoaderProps } from "@/types";
import { TError } from "@/types";
import { ConfirmRouteContext } from "../ConfirmRoute";
import { ButtonsWrapper } from "../StyledConfirm.styled";
type ChangeOwnerFormProps = {
newOwner?: string;
} & WithLoaderProps;
};
const ChangeOwnerForm = ({ newOwner }: ChangeOwnerFormProps) => {
const { t } = useTranslation(["Confirm", "Common"]);
@ -122,4 +121,4 @@ const ChangeOwnerForm = ({ newOwner }: ChangeOwnerFormProps) => {
);
};
export default withLoader(ChangeOwnerForm);
export default ChangeOwnerForm;

View File

@ -37,8 +37,6 @@ import {
} from "@docspace/shared/components/text-input";
import { Text } from "@docspace/shared/components/text";
import withLoader from "@/HOCs/withLoader";
const ChangePhoneForm = () => {
const { t } = useTranslation(["Confirm", "Common"]);
@ -84,4 +82,4 @@ const ChangePhoneForm = () => {
);
};
export default withLoader(ChangePhoneForm);
export default ChangePhoneForm;

View File

@ -35,7 +35,6 @@ import { toastr } from "@docspace/shared/components/toast";
import { Button, ButtonSize } from "@docspace/shared/components/button";
import { continuePortal } from "@docspace/shared/api/portal";
import withLoader from "@/HOCs/withLoader";
import { TError } from "@/types";
import { ConfirmRouteContext } from "../ConfirmRoute";
@ -117,4 +116,4 @@ const ContinuePortalForm = () => {
);
};
export default withLoader(ContinuePortalForm);
export default ContinuePortalForm;

View File

@ -38,7 +38,12 @@ import {
} from "react";
import { useTranslation } from "react-i18next";
import { TPasswordHash } from "@docspace/shared/api/settings/types";
import {
TCapabilities,
TPasswordHash,
TPasswordSettings,
TThirdPartyProvider,
} from "@docspace/shared/api/settings/types";
import { toastr } from "@docspace/shared/components/toast";
import {
COOKIE_EXPIRATION_YEAR,
@ -54,7 +59,7 @@ import {
import { setCookie } from "@docspace/shared/utils/cookie";
import { DeviceType } from "@docspace/shared/enums";
import { TValidate } from "@docspace/shared/components/email-input";
import { TCreateUserData, TError, WithLoaderProps } from "@/types";
import { TCreateUserData, TError } from "@/types";
import { SocialButtonsGroup } from "@docspace/shared/components/social-buttons-group";
import { Text } from "@docspace/shared/components/text";
import { login } from "@docspace/shared/api/user";
@ -66,7 +71,6 @@ import {
import SsoReactSvg from "PUBLIC_DIR/images/sso.react.svg";
import withLoader from "@/HOCs/withLoader";
import useDeviceType from "@/hooks/useDeviceType";
import { ConfirmRouteContext } from "../ConfirmRoute";
@ -78,9 +82,12 @@ export type CreateUserFormProps = {
userNameRegex: string;
passwordHash: TPasswordHash;
defaultPage?: string;
passwordSettings?: TPasswordSettings;
capabilities?: TCapabilities;
thirdPartyProviders?: TThirdPartyProvider[];
firstName?: string;
lastName?: string;
} & WithLoaderProps;
};
const CreateUserForm = (props: CreateUserFormProps) => {
const {
@ -180,57 +187,57 @@ const CreateUserForm = (props: CreateUserFormProps) => {
const headerKey = linkData?.confirmHeader ?? null;
const toBinaryStr = (str: string) => {
const encoder = new TextEncoder();
const charCodes = encoder.encode(str);
// @ts-ignore
return String.fromCharCode(...charCodes);
};
try {
const toBinaryStr = (str: string) => {
const encoder = new TextEncoder();
const charCodes = encoder.encode(str);
// @ts-ignore
return String.fromCharCode(...charCodes);
};
const loginData = window.btoa(
toBinaryStr(
JSON.stringify({
type: "invitation",
email,
roomName,
firstName,
lastName,
linkData,
}),
),
);
const loginData = window.btoa(
toBinaryStr(
JSON.stringify({
type: "invitation",
email,
roomName,
firstName,
lastName,
linkData,
}),
),
);
const response = await getUserByEmail(email, headerKey);
await getUserByEmail(email, headerKey);
if (typeof response === "number") {
const isNotExistUser = response === 404;
setCookie(LANGUAGE, currentCultureName, {
"max-age": COOKIE_EXPIRATION_YEAR,
});
const finalUrl = roomId
? `/rooms/shared/${roomId}/filter?folder=${roomId}`
: defaultPage;
if (roomId) {
sessionStorage.setItem("referenceUrl", finalUrl);
}
window.location.href = combineUrl(
window.ClientConfig?.proxy?.url,
"/login",
`?loginData=${loginData}`,
);
} catch (error) {
const knownError = error as TError;
const status =
typeof knownError === "object" ? knownError?.response?.status : "";
const isNotExistUser = status === 404;
if (isNotExistUser) {
setRegistrationForm(true);
}
setIsLoading(false);
return;
}
setCookie(LANGUAGE, currentCultureName, {
"max-age": COOKIE_EXPIRATION_YEAR,
});
const finalUrl = roomId
? `/rooms/shared/${roomId}/filter?folder=${roomId}`
: defaultPage;
if (roomId) {
sessionStorage.setItem("referenceUrl", finalUrl);
}
window.location.href = combineUrl(
window.ClientConfig?.proxy?.url,
"/login",
`?loginData=${loginData}`,
);
setIsLoading(false);
};
@ -294,7 +301,6 @@ const CreateUserForm = (props: CreateUserFormProps) => {
createConfirmUser(confirmUser, headerKey).catch((error) => {
const knownError = error as TError;
console.log("error", error);
let errorMessage: string;
if (typeof knownError === "object") {
@ -520,4 +526,4 @@ const CreateUserForm = (props: CreateUserFormProps) => {
);
};
export default withLoader(CreateUserForm);
export default CreateUserForm;

View File

@ -35,8 +35,7 @@ import { Button, ButtonSize } from "@docspace/shared/components/button";
import { toastr } from "@docspace/shared/components/toast";
import { suspendPortal } from "@docspace/shared/api/portal";
import withLoader from "@/HOCs/withLoader";
import { TError, WithLoaderProps } from "@/types";
import { TError } from "@/types";
import { URL_ONLYOFFICE } from "@/utils/constants";
import { ButtonsWrapper } from "../StyledConfirm.styled";
@ -44,7 +43,7 @@ import { ConfirmRouteContext } from "../ConfirmRoute";
type DeactivatePortalProps = {
siteUrl?: string;
} & WithLoaderProps;
};
const DeactivatePortalForm = ({ siteUrl }: DeactivatePortalProps) => {
const { t } = useTranslation(["Confirm", "Common"]);
@ -124,4 +123,4 @@ const DeactivatePortalForm = ({ siteUrl }: DeactivatePortalProps) => {
);
};
export default withLoader(DeactivatePortalForm);
export default DeactivatePortalForm;

View File

@ -37,17 +37,20 @@ import { Text } from "@docspace/shared/components/text";
import { createPasswordHash } from "@docspace/shared/utils/common";
import { toastr } from "@docspace/shared/components/toast";
import { InputSize, InputType } from "@docspace/shared/components/text-input";
import { TPasswordHash } from "@docspace/shared/api/settings/types";
import {
TPasswordHash,
TPasswordSettings,
} from "@docspace/shared/api/settings/types";
import { ALLOWED_PASSWORD_CHARACTERS } from "@docspace/shared/constants";
import { changePassword } from "@docspace/shared/api/people";
import withLoader from "@/HOCs/withLoader";
import { TError, WithLoaderProps } from "@/types";
import { TError } from "@/types";
import { ConfirmRouteContext } from "../ConfirmRoute";
type PasswordChangeFormProps = {
passwordHash: TPasswordHash;
} & WithLoaderProps;
passwordSettings?: TPasswordSettings;
};
const PasswordChangeForm = ({
passwordSettings,
@ -195,4 +198,4 @@ const PasswordChangeForm = ({
);
};
export default withLoader(PasswordChangeForm);
export default PasswordChangeForm;

View File

@ -37,8 +37,7 @@ import { toastr } from "@docspace/shared/components/toast";
import { TColorScheme } from "@docspace/shared/themes";
import { deleteSelf } from "@docspace/shared/api/people";
import withLoader from "@/HOCs/withLoader";
import { TError, WithLoaderProps } from "@/types";
import { TError } from "@/types";
import { GreetingContainer } from "../GreetingContainer";
import { ConfirmRouteContext } from "../ConfirmRoute";
@ -47,7 +46,7 @@ type ProfileRemoveFormProps = {
legalTerms: string;
greetingSettings: string;
currentColorScheme?: TColorScheme;
} & WithLoaderProps;
};
const ProfileRemoveForm = ({
legalTerms,
@ -156,4 +155,4 @@ const ProfileRemoveForm = ({
);
};
export default withLoader(ProfileRemoveForm);
export default ProfileRemoveForm;

View File

@ -35,16 +35,15 @@ import { deletePortal } from "@docspace/shared/api/portal";
import { Button, ButtonSize } from "@docspace/shared/components/button";
import { toastr } from "@docspace/shared/components/toast";
import { TError, WithLoaderProps } from "@/types";
import { TError } from "@/types";
import { URL_ONLYOFFICE } from "@/utils/constants";
import withLoader from "@/HOCs/withLoader";
import { ConfirmRouteContext } from "../ConfirmRoute";
import { ButtonsWrapper } from "../StyledConfirm.styled";
type RemovePortalFormProps = {
siteUrl?: string;
} & WithLoaderProps;
};
const RemovePortalForm = ({ siteUrl }: RemovePortalFormProps) => {
const { t } = useTranslation(["Confirm", "Common"]);
@ -127,4 +126,4 @@ const RemovePortalForm = ({ siteUrl }: RemovePortalFormProps) => {
);
};
export default withLoader(RemovePortalForm);
export default RemovePortalForm;

View File

@ -55,8 +55,7 @@ import {
TFA_IOS_APP_URL,
TFA_WIN_APP_URL,
} from "@/utils/constants";
import withLoader from "@/HOCs/withLoader";
import { TError, WithLoaderProps } from "@/types";
import { TError } from "@/types";
import { ConfirmRouteContext } from "../ConfirmRoute";
import { GreetingContainer } from "../GreetingContainer";
@ -68,9 +67,8 @@ type TfaActivationFormProps = {
qrCode: string;
passwordHash: TPasswordHash;
userName?: string;
currentColorScheme?: TColorScheme;
} & WithLoaderProps;
};
const TfaActivationForm = ({
secretKey,
@ -240,4 +238,4 @@ const TfaActivationForm = ({
);
};
export default withLoader(TfaActivationForm);
export default TfaActivationForm;

View File

@ -44,8 +44,7 @@ import {
import { Button, ButtonSize } from "@docspace/shared/components/button";
import { TPasswordHash } from "@docspace/shared/api/settings/types";
import withLoader from "@/HOCs/withLoader";
import { TError, WithLoaderProps } from "@/types";
import { TError } from "@/types";
import { ConfirmRouteContext } from "../ConfirmRoute";
@ -53,7 +52,7 @@ type TfaAuthFormProps = {
passwordHash: TPasswordHash;
userName?: string;
defaultPage?: string;
} & WithLoaderProps;
};
const TfaAuthForm = ({
passwordHash,
@ -174,4 +173,4 @@ const TfaAuthForm = ({
);
};
export default withLoader(TfaAuthForm);
export default TfaAuthForm;