Login:Components:Wizard: add error handling and remove method isMobile
This commit is contained in:
parent
3e53678c21
commit
988cac14f9
@ -72,13 +72,14 @@ import RefreshReactSvgUrl from "PUBLIC_DIR/images/refresh.react.svg?url";
|
|||||||
import { setLicense } from "@docspace/shared/api/settings";
|
import { setLicense } from "@docspace/shared/api/settings";
|
||||||
import { ComboBox, ComboBoxSize } from "@docspace/shared/components/combobox";
|
import { ComboBox, ComboBoxSize } from "@docspace/shared/components/combobox";
|
||||||
import BetaBadge from "@docspace/client/src/components/BetaBadgeWrapper";
|
import BetaBadge from "@docspace/client/src/components/BetaBadgeWrapper";
|
||||||
import { isMobile } from "@docspace/shared/utils";
|
|
||||||
import { Checkbox } from "@docspace/shared/components/checkbox";
|
import { Checkbox } from "@docspace/shared/components/checkbox";
|
||||||
import { useTheme } from "styled-components";
|
import { useTheme } from "styled-components";
|
||||||
import { Button, ButtonSize } from "@docspace/shared/components/button";
|
import { Button, ButtonSize } from "@docspace/shared/components/button";
|
||||||
import api from "@docspace/shared/api";
|
import api from "@docspace/shared/api";
|
||||||
import { setCookie } from "@docspace/shared/utils/cookie";
|
import { setCookie } from "@docspace/shared/utils/cookie";
|
||||||
import { InputSize, InputType } from "@docspace/shared/components/text-input";
|
import { InputSize, InputType } from "@docspace/shared/components/text-input";
|
||||||
|
import useDeviceType from "@/hooks/useDeviceType";
|
||||||
|
import { DeviceType } from "@docspace/shared/enums";
|
||||||
|
|
||||||
type WizardFormProps = {
|
type WizardFormProps = {
|
||||||
passwordSettings?: TPasswordSettings;
|
passwordSettings?: TPasswordSettings;
|
||||||
@ -125,14 +126,16 @@ 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();
|
||||||
|
const { currentDeviceType } = useDeviceType();
|
||||||
|
|
||||||
const refPassInput = useRef<PasswordInputHandle>(null);
|
const refPassInput = useRef<PasswordInputHandle>(null);
|
||||||
|
|
||||||
//TODO: add property
|
|
||||||
const userCulture = culture || "en";
|
const userCulture = culture || "en";
|
||||||
|
const isMobileView = currentDeviceType === DeviceType.mobile;
|
||||||
|
|
||||||
const convertedCulture = convertLanguage(userCulture);
|
const convertedCulture = convertLanguage(userCulture);
|
||||||
|
|
||||||
@ -271,13 +274,19 @@ function WizardForm(props: WizardFormProps) {
|
|||||||
"max-age": COOKIE_EXPIRATION_YEAR,
|
"max-age": COOKIE_EXPIRATION_YEAR,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.location.replace("/");
|
||||||
//setWizardComplete();
|
//setWizardComplete();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
setError(error);
|
||||||
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">
|
||||||
@ -392,14 +401,14 @@ function WizardForm(props: WizardFormProps) {
|
|||||||
selectedOption={selectedLanguage}
|
selectedOption={selectedLanguage}
|
||||||
onSelect={onLanguageSelect}
|
onSelect={onLanguageSelect}
|
||||||
isDisabled={isCreated}
|
isDisabled={isCreated}
|
||||||
scaled={isMobile()}
|
scaled={isMobileView}
|
||||||
scaledOptions={false}
|
scaledOptions={false}
|
||||||
size={ComboBoxSize.content}
|
size={ComboBoxSize.content}
|
||||||
showDisabledItems={true}
|
showDisabledItems={true}
|
||||||
dropDownMaxHeight={364}
|
dropDownMaxHeight={364}
|
||||||
manualWidth="250px"
|
manualWidth="250px"
|
||||||
isDefaultMode={!isMobile()}
|
isDefaultMode={!isMobileView}
|
||||||
withBlur={isMobile()}
|
withBlur={isMobileView}
|
||||||
fillIcon={false}
|
fillIcon={false}
|
||||||
modernView={true}
|
modernView={true}
|
||||||
/>
|
/>
|
||||||
@ -421,14 +430,14 @@ function WizardForm(props: WizardFormProps) {
|
|||||||
selectedOption={selectedTimezone}
|
selectedOption={selectedTimezone}
|
||||||
onSelect={onTimezoneSelect}
|
onSelect={onTimezoneSelect}
|
||||||
isDisabled={isCreated}
|
isDisabled={isCreated}
|
||||||
scaled={isMobile()}
|
scaled={isMobileView}
|
||||||
scaledOptions={false}
|
scaledOptions={false}
|
||||||
size={ComboBoxSize.content}
|
size={ComboBoxSize.content}
|
||||||
showDisabledItems={true}
|
showDisabledItems={true}
|
||||||
dropDownMaxHeight={364}
|
dropDownMaxHeight={364}
|
||||||
manualWidth="350px"
|
manualWidth="350px"
|
||||||
isDefaultMode={!isMobile()}
|
isDefaultMode={!isMobileView}
|
||||||
withBlur={isMobile()}
|
withBlur={isMobileView}
|
||||||
fillIcon={false}
|
fillIcon={false}
|
||||||
modernView={true}
|
modernView={true}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user