Login:App:Wizard: add error handling
This commit is contained in:
parent
117c745eb3
commit
b4cb1cdadc
@ -74,7 +74,7 @@ import {
|
|||||||
|
|
||||||
import RefreshReactSvgUrl from "PUBLIC_DIR/images/refresh.react.svg?url";
|
import RefreshReactSvgUrl from "PUBLIC_DIR/images/refresh.react.svg?url";
|
||||||
|
|
||||||
import { TCulturesOption, TTimeZoneOption } from "@/types";
|
import { TCulturesOption, TError, TTimeZoneOption } from "@/types";
|
||||||
import {
|
import {
|
||||||
DEFAULT_SELECT_LANGUAGE,
|
DEFAULT_SELECT_LANGUAGE,
|
||||||
DEFAULT_SELECT_TIMEZONE,
|
DEFAULT_SELECT_TIMEZONE,
|
||||||
@ -87,6 +87,7 @@ import {
|
|||||||
StyledLink,
|
StyledLink,
|
||||||
WizardContainer,
|
WizardContainer,
|
||||||
} from "./page.styled";
|
} from "./page.styled";
|
||||||
|
import { toastr } from "@docspace/shared/components/toast";
|
||||||
|
|
||||||
type WizardFormProps = {
|
type WizardFormProps = {
|
||||||
passwordSettings?: TPasswordSettings;
|
passwordSettings?: TPasswordSettings;
|
||||||
@ -133,7 +134,6 @@ function WizardForm(props: WizardFormProps) {
|
|||||||
const [agreeTerms, setAgreeTerms] = useState(false);
|
const [agreeTerms, setAgreeTerms] = useState(false);
|
||||||
const [hasErrorAgree, setHasErrorAgree] = useState(false);
|
const [hasErrorAgree, setHasErrorAgree] = useState(false);
|
||||||
const [isCreated, setIsCreated] = useState(false);
|
const [isCreated, setIsCreated] = useState(false);
|
||||||
const [error, setError] = useState<unknown>();
|
|
||||||
|
|
||||||
const { t, i18n } = useTranslation(["Wizard", "Common"]);
|
const { t, i18n } = useTranslation(["Wizard", "Common"]);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -180,8 +180,6 @@ function WizardForm(props: WizardFormProps) {
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("select", select);
|
|
||||||
|
|
||||||
if (select.length === 0) {
|
if (select.length === 0) {
|
||||||
setSelectedLanguage(DEFAULT_SELECT_LANGUAGE);
|
setSelectedLanguage(DEFAULT_SELECT_LANGUAGE);
|
||||||
} else {
|
} else {
|
||||||
@ -316,16 +314,25 @@ function WizardForm(props: WizardFormProps) {
|
|||||||
|
|
||||||
window.location.replace("/");
|
window.location.replace("/");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error);
|
const knownError = error as TError;
|
||||||
|
let errorMessage: string;
|
||||||
|
|
||||||
|
if (typeof knownError === "object") {
|
||||||
|
errorMessage =
|
||||||
|
knownError?.response?.data?.error?.message ||
|
||||||
|
knownError?.statusText ||
|
||||||
|
knownError?.message ||
|
||||||
|
"";
|
||||||
|
} else {
|
||||||
|
errorMessage = knownError;
|
||||||
|
}
|
||||||
|
|
||||||
|
toastr.error(errorMessage);
|
||||||
|
console.error(errorMessage);
|
||||||
setIsCreated(false);
|
setIsCreated(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (error) {
|
|
||||||
console.error(error);
|
|
||||||
throw new Error(t("ErrorInitWizard"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WizardContainer>
|
<WizardContainer>
|
||||||
<Text fontWeight={600} fontSize="16px" className="form-header">
|
<Text fontWeight={600} fontSize="16px" className="form-header">
|
||||||
|
Loading…
Reference in New Issue
Block a user