@digitaldefiance/express-suite-react-components 2.9.38 → 2.9.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/auth/Private.d.ts +6 -0
- package/src/auth/Private.d.ts.map +1 -0
- package/src/auth/Private.js +14 -0
- package/src/auth/PrivateRoute.d.ts +8 -0
- package/src/auth/PrivateRoute.d.ts.map +1 -0
- package/src/auth/PrivateRoute.js +23 -0
- package/src/auth/UnAuth.d.ts +6 -0
- package/src/auth/UnAuth.d.ts.map +1 -0
- package/src/auth/UnAuth.js +14 -0
- package/src/auth/UnAuthRoute.d.ts +8 -0
- package/src/auth/UnAuthRoute.d.ts.map +1 -0
- package/src/auth/UnAuthRoute.js +22 -0
- package/src/auth/{index.ts → index.d.ts} +2 -1
- package/src/auth/index.d.ts.map +1 -0
- package/src/auth/index.js +10 -0
- package/src/components/ApiAccess.d.ts +16 -0
- package/src/components/ApiAccess.d.ts.map +1 -0
- package/src/components/ApiAccess.js +77 -0
- package/src/components/BackupCodeLoginForm.d.ts +43 -0
- package/src/components/BackupCodeLoginForm.d.ts.map +1 -0
- package/src/components/BackupCodeLoginForm.js +139 -0
- package/src/components/BackupCodesForm.d.ts +26 -0
- package/src/components/BackupCodesForm.d.ts.map +1 -0
- package/src/components/BackupCodesForm.js +120 -0
- package/src/components/ChangePasswordForm.d.ts +26 -0
- package/src/components/ChangePasswordForm.d.ts.map +1 -0
- package/src/components/ChangePasswordForm.js +78 -0
- package/src/components/ConfirmationDialog.d.ts +13 -0
- package/src/components/ConfirmationDialog.d.ts.map +1 -0
- package/src/components/ConfirmationDialog.js +10 -0
- package/src/components/CurrencyCodeSelector.d.ts +9 -0
- package/src/components/CurrencyCodeSelector.d.ts.map +1 -0
- package/src/components/CurrencyCodeSelector.js +31 -0
- package/src/components/CurrencyInput.d.ts +13 -0
- package/src/components/CurrencyInput.d.ts.map +1 -0
- package/src/components/CurrencyInput.js +22 -0
- package/src/components/DashboardPage.d.ts +8 -0
- package/src/components/DashboardPage.d.ts.map +1 -0
- package/src/components/DashboardPage.js +10 -0
- package/src/components/DropdownMenu.d.ts +9 -0
- package/src/components/DropdownMenu.d.ts.map +1 -0
- package/src/components/DropdownMenu.js +56 -0
- package/src/components/ExpirationSecondsSelector.d.ts +13 -0
- package/src/components/ExpirationSecondsSelector.d.ts.map +1 -0
- package/src/components/ExpirationSecondsSelector.js +32 -0
- package/src/components/Flag.d.ts +20 -0
- package/src/components/Flag.d.ts.map +1 -0
- package/src/components/Flag.js +43 -0
- package/src/components/ForgotPasswordForm.d.ts +18 -0
- package/src/components/ForgotPasswordForm.d.ts.map +1 -0
- package/src/components/ForgotPasswordForm.js +61 -0
- package/src/components/LoginForm.d.ts +44 -0
- package/src/components/LoginForm.d.ts.map +1 -0
- package/src/components/LoginForm.js +122 -0
- package/src/components/LogoutPage.d.ts +8 -0
- package/src/components/LogoutPage.d.ts.map +1 -0
- package/src/components/LogoutPage.js +16 -0
- package/src/components/RegisterForm.d.ts +56 -0
- package/src/components/RegisterForm.d.ts.map +1 -0
- package/src/components/RegisterForm.js +140 -0
- package/src/components/ResetPasswordForm.d.ts +23 -0
- package/src/components/ResetPasswordForm.d.ts.map +1 -0
- package/src/components/ResetPasswordForm.js +78 -0
- package/src/components/SideMenu.d.ts +8 -0
- package/src/components/SideMenu.d.ts.map +1 -0
- package/src/components/SideMenu.js +25 -0
- package/src/components/SideMenuListItem.d.ts +13 -0
- package/src/components/SideMenuListItem.d.ts.map +1 -0
- package/src/components/SideMenuListItem.js +44 -0
- package/src/components/TopMenu.d.ts +24 -0
- package/src/components/TopMenu.d.ts.map +1 -0
- package/src/components/TopMenu.js +35 -0
- package/src/components/TranslatedTitle.d.ts +7 -0
- package/src/components/TranslatedTitle.d.ts.map +1 -0
- package/src/components/TranslatedTitle.js +15 -0
- package/src/components/UserLanguageSelector.d.ts +4 -0
- package/src/components/UserLanguageSelector.d.ts.map +1 -0
- package/src/components/UserLanguageSelector.js +31 -0
- package/src/components/UserMenu.d.ts +4 -0
- package/src/components/UserMenu.d.ts.map +1 -0
- package/src/components/UserMenu.js +12 -0
- package/src/components/UserSettingsForm.d.ts +57 -0
- package/src/components/UserSettingsForm.d.ts.map +1 -0
- package/src/components/UserSettingsForm.js +126 -0
- package/src/components/VerifyEmailPage.d.ts +23 -0
- package/src/components/VerifyEmailPage.d.ts.map +1 -0
- package/src/components/VerifyEmailPage.js +70 -0
- package/src/components/{index.ts → index.d.ts} +1 -1
- package/src/components/index.d.ts.map +1 -0
- package/src/components/index.js +28 -0
- package/src/contexts/AuthProvider.d.ts +152 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -0
- package/src/contexts/AuthProvider.js +502 -0
- package/src/contexts/I18nProvider.d.ts +16 -0
- package/src/contexts/I18nProvider.d.ts.map +1 -0
- package/src/contexts/I18nProvider.js +46 -0
- package/src/contexts/MenuContext.d.ts +20 -0
- package/src/contexts/MenuContext.d.ts.map +1 -0
- package/src/contexts/MenuContext.js +273 -0
- package/src/contexts/SuiteConfigProvider.d.ts +44 -0
- package/src/contexts/SuiteConfigProvider.d.ts.map +1 -0
- package/src/contexts/SuiteConfigProvider.js +43 -0
- package/src/contexts/ThemeProvider.d.ts +15 -0
- package/src/contexts/ThemeProvider.d.ts.map +1 -0
- package/src/contexts/ThemeProvider.js +36 -0
- package/src/contexts/{index.ts → index.d.ts} +1 -0
- package/src/contexts/index.d.ts.map +1 -0
- package/src/contexts/index.js +8 -0
- package/src/hooks/{index.ts → index.d.ts} +1 -0
- package/src/hooks/index.d.ts.map +1 -0
- package/src/hooks/index.js +8 -0
- package/src/hooks/useBackupCodes.d.ts +15 -0
- package/src/hooks/useBackupCodes.d.ts.map +1 -0
- package/src/hooks/useBackupCodes.js +74 -0
- package/src/hooks/useEmailVerification.d.ts +10 -0
- package/src/hooks/useEmailVerification.d.ts.map +1 -0
- package/src/hooks/useEmailVerification.js +40 -0
- package/src/hooks/useExpiringValue.d.ts +14 -0
- package/src/hooks/useExpiringValue.d.ts.map +1 -0
- package/src/hooks/useExpiringValue.js +53 -0
- package/src/hooks/useLocalStorage.d.ts +2 -0
- package/src/hooks/useLocalStorage.d.ts.map +1 -0
- package/src/hooks/useLocalStorage.js +15 -0
- package/src/hooks/useUserSettings.d.ts +48 -0
- package/src/hooks/useUserSettings.d.ts.map +1 -0
- package/src/hooks/useUserSettings.js +169 -0
- package/src/{index.ts → index.d.ts} +1 -1
- package/src/index.d.ts.map +1 -0
- package/src/index.js +12 -0
- package/src/interfaces/IAppConfig.d.ts +6 -0
- package/src/interfaces/IAppConfig.d.ts.map +1 -0
- package/src/interfaces/IAppConfig.js +2 -0
- package/src/interfaces/IMenuConfig.d.ts +11 -0
- package/src/interfaces/IMenuConfig.d.ts.map +1 -0
- package/src/interfaces/IMenuConfig.js +2 -0
- package/src/interfaces/IMenuOption.d.ts +58 -0
- package/src/interfaces/IMenuOption.d.ts.map +1 -0
- package/src/interfaces/IMenuOption.js +2 -0
- package/src/interfaces/index.d.ts +4 -0
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +6 -0
- package/src/services/__mocks__/authService.d.ts +21 -0
- package/src/services/__mocks__/authService.d.ts.map +1 -0
- package/src/services/__mocks__/authService.js +15 -0
- package/src/services/api.d.ts +3 -0
- package/src/services/api.d.ts.map +1 -0
- package/src/services/api.js +14 -0
- package/src/services/authService.d.ts +72 -0
- package/src/services/authService.d.ts.map +1 -0
- package/src/services/authService.js +335 -0
- package/src/services/authenticatedApi.d.ts +3 -0
- package/src/services/authenticatedApi.d.ts.map +1 -0
- package/src/services/authenticatedApi.js +18 -0
- package/src/services/index.d.ts +4 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/index.js +6 -0
- package/src/types/MenuType.d.ts +11 -0
- package/src/types/MenuType.d.ts.map +1 -0
- package/src/types/MenuType.js +12 -0
- package/src/types/expirationSeconds.d.ts +3 -0
- package/src/types/expirationSeconds.d.ts.map +1 -0
- package/src/types/expirationSeconds.js +17 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +4 -0
- package/src/types/translation.d.ts +10 -0
- package/src/types/translation.d.ts.map +1 -0
- package/src/types/translation.js +9 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts +8 -0
- package/src/wrappers/BackupCodeLoginWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodeLoginWrapper.js +20 -0
- package/src/wrappers/BackupCodesWrapper.d.ts +7 -0
- package/src/wrappers/BackupCodesWrapper.d.ts.map +1 -0
- package/src/wrappers/BackupCodesWrapper.js +17 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts +8 -0
- package/src/wrappers/ChangePasswordFormWrapper.d.ts.map +1 -0
- package/src/wrappers/ChangePasswordFormWrapper.js +21 -0
- package/src/wrappers/LoginFormWrapper.d.ts +9 -0
- package/src/wrappers/LoginFormWrapper.d.ts.map +1 -0
- package/src/wrappers/LoginFormWrapper.js +43 -0
- package/src/wrappers/LogoutPageWrapper.d.ts +9 -0
- package/src/wrappers/LogoutPageWrapper.d.ts.map +1 -0
- package/src/wrappers/LogoutPageWrapper.js +21 -0
- package/src/wrappers/RegisterFormWrapper.d.ts +9 -0
- package/src/wrappers/RegisterFormWrapper.d.ts.map +1 -0
- package/src/wrappers/RegisterFormWrapper.js +31 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts +8 -0
- package/src/wrappers/UserSettingsFormWrapper.d.ts.map +1 -0
- package/src/wrappers/UserSettingsFormWrapper.js +24 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts +8 -0
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +1 -0
- package/src/wrappers/VerifyEmailPageWrapper.js +20 -0
- package/src/wrappers/{index.tsx → index.d.ts} +1 -8
- package/src/wrappers/index.d.ts.map +1 -0
- package/src/wrappers/index.js +20 -0
- package/LICENSE +0 -21
- package/src/auth/Private.tsx +0 -17
- package/src/auth/PrivateRoute.tsx +0 -28
- package/src/auth/UnAuth.tsx +0 -16
- package/src/auth/UnAuthRoute.tsx +0 -30
- package/src/components/ApiAccess.tsx +0 -174
- package/src/components/BackupCodeLoginForm.tsx +0 -488
- package/src/components/BackupCodesForm.tsx +0 -286
- package/src/components/ChangePasswordForm.tsx +0 -272
- package/src/components/ConfirmationDialog.tsx +0 -48
- package/src/components/CurrencyCodeSelector.tsx +0 -60
- package/src/components/CurrencyInput.tsx +0 -80
- package/src/components/DashboardPage.tsx +0 -24
- package/src/components/DropdownMenu.tsx +0 -92
- package/src/components/ExpirationSecondsSelector.tsx +0 -60
- package/src/components/Flag.tsx +0 -52
- package/src/components/ForgotPasswordForm.tsx +0 -173
- package/src/components/LoginForm.tsx +0 -455
- package/src/components/LogoutPage.tsx +0 -21
- package/src/components/RegisterForm.tsx +0 -602
- package/src/components/ResetPasswordForm.tsx +0 -246
- package/src/components/SideMenu.tsx +0 -46
- package/src/components/SideMenuListItem.tsx +0 -74
- package/src/components/TopMenu.tsx +0 -145
- package/src/components/TranslatedTitle.tsx +0 -29
- package/src/components/UserLanguageSelector.tsx +0 -45
- package/src/components/UserMenu.tsx +0 -15
- package/src/components/UserSettingsForm.tsx +0 -505
- package/src/components/VerifyEmailPage.tsx +0 -184
- package/src/contexts/AuthProvider.spec.tsx +0 -1195
- package/src/contexts/AuthProvider.tsx +0 -924
- package/src/contexts/I18nProvider.tsx +0 -114
- package/src/contexts/MenuContext.tsx +0 -398
- package/src/contexts/SuiteConfigProvider.tsx +0 -93
- package/src/contexts/ThemeProvider.tsx +0 -67
- package/src/hooks/useBackupCodes.ts +0 -105
- package/src/hooks/useEmailVerification.ts +0 -49
- package/src/hooks/useExpiringValue.ts +0 -78
- package/src/hooks/useLocalStorage.ts +0 -18
- package/src/hooks/useUserSettings.ts +0 -269
- package/src/interfaces/IAppConfig.ts +0 -5
- package/src/interfaces/IMenuConfig.ts +0 -11
- package/src/interfaces/IMenuOption.ts +0 -55
- package/src/interfaces/index.ts +0 -3
- package/src/services/__mocks__/authService.ts +0 -14
- package/src/services/api.ts +0 -13
- package/src/services/authService.ts +0 -500
- package/src/services/authenticatedApi.ts +0 -17
- package/src/services/index.ts +0 -3
- package/src/types/MenuType.ts +0 -15
- package/src/types/expirationSeconds.ts +0 -18
- package/src/types/index.ts +0 -1
- package/src/types/translation.ts +0 -20
- package/src/wrappers/BackupCodeLoginWrapper.tsx +0 -34
- package/src/wrappers/BackupCodesWrapper.tsx +0 -28
- package/src/wrappers/ChangePasswordFormWrapper.tsx +0 -34
- package/src/wrappers/LoginFormWrapper.tsx +0 -59
- package/src/wrappers/LogoutPageWrapper.tsx +0 -30
- package/src/wrappers/RegisterFormWrapper.tsx +0 -61
- package/src/wrappers/UserSettingsFormWrapper.tsx +0 -39
- package/src/wrappers/VerifyEmailPageWrapper.tsx +0 -27
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Constants,
|
|
3
|
-
SuiteCoreComponentId,
|
|
4
|
-
SuiteCoreStringKey,
|
|
5
|
-
} from '@digitaldefiance/suite-core-lib';
|
|
6
|
-
import {
|
|
7
|
-
Alert,
|
|
8
|
-
AlertTitle,
|
|
9
|
-
Box,
|
|
10
|
-
Button,
|
|
11
|
-
Checkbox,
|
|
12
|
-
Container,
|
|
13
|
-
FormControl,
|
|
14
|
-
FormControlLabel,
|
|
15
|
-
FormHelperText,
|
|
16
|
-
InputLabel,
|
|
17
|
-
Link,
|
|
18
|
-
MenuItem,
|
|
19
|
-
Select,
|
|
20
|
-
TextField,
|
|
21
|
-
Typography,
|
|
22
|
-
} from '@mui/material';
|
|
23
|
-
import { useFormik } from 'formik';
|
|
24
|
-
import { FC, useState } from 'react';
|
|
25
|
-
import * as Yup from 'yup';
|
|
26
|
-
import { useI18n } from '../contexts';
|
|
27
|
-
|
|
28
|
-
export interface RegisterFormValues {
|
|
29
|
-
username: string;
|
|
30
|
-
email: string;
|
|
31
|
-
timezone: string;
|
|
32
|
-
password?: string;
|
|
33
|
-
confirmPassword?: string;
|
|
34
|
-
directChallenge?: boolean;
|
|
35
|
-
[key: string]: string | boolean | undefined;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface RegisterFormProps {
|
|
39
|
-
onSubmit: (
|
|
40
|
-
values: RegisterFormValues,
|
|
41
|
-
usePassword: boolean
|
|
42
|
-
) => Promise<
|
|
43
|
-
| { success: boolean; message: string; mnemonic?: string }
|
|
44
|
-
| {
|
|
45
|
-
error: string;
|
|
46
|
-
errorType?: string;
|
|
47
|
-
field?: string;
|
|
48
|
-
errors?: Array<{ path: string; msg: string }>;
|
|
49
|
-
}
|
|
50
|
-
>;
|
|
51
|
-
timezones: string[];
|
|
52
|
-
getInitialTimezone: () => string;
|
|
53
|
-
usernameValidation?: Yup.StringSchema;
|
|
54
|
-
emailValidation?: Yup.StringSchema;
|
|
55
|
-
timezoneValidation?: Yup.StringSchema;
|
|
56
|
-
passwordValidation?: Yup.StringSchema;
|
|
57
|
-
confirmPasswordValidation?: Yup.StringSchema;
|
|
58
|
-
additionalFields?: (
|
|
59
|
-
formik: ReturnType<typeof useFormik<RegisterFormValues>>,
|
|
60
|
-
usePassword: boolean
|
|
61
|
-
) => React.ReactNode;
|
|
62
|
-
additionalInitialValues?: Record<string, string | boolean>;
|
|
63
|
-
additionalValidation?: Record<string, Yup.Schema>;
|
|
64
|
-
labels?: {
|
|
65
|
-
title?: string;
|
|
66
|
-
username?: string;
|
|
67
|
-
email?: string;
|
|
68
|
-
timezone?: string;
|
|
69
|
-
password?: string;
|
|
70
|
-
confirmPassword?: string;
|
|
71
|
-
useMnemonic?: string;
|
|
72
|
-
usePassword?: string;
|
|
73
|
-
registering?: string;
|
|
74
|
-
register?: string;
|
|
75
|
-
successTitle?: string;
|
|
76
|
-
mnemonicSuccess?: string;
|
|
77
|
-
proceedToLogin?: string;
|
|
78
|
-
loginLink?: string;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const RegisterForm: FC<RegisterFormProps> = ({
|
|
83
|
-
onSubmit,
|
|
84
|
-
timezones,
|
|
85
|
-
getInitialTimezone,
|
|
86
|
-
usernameValidation,
|
|
87
|
-
emailValidation,
|
|
88
|
-
timezoneValidation,
|
|
89
|
-
passwordValidation,
|
|
90
|
-
confirmPasswordValidation,
|
|
91
|
-
additionalFields,
|
|
92
|
-
additionalInitialValues = {},
|
|
93
|
-
additionalValidation = {},
|
|
94
|
-
labels = {},
|
|
95
|
-
}) => {
|
|
96
|
-
const { tComponent } = useI18n();
|
|
97
|
-
const [apiErrors, setApiErrors] = useState<Record<string, string>>({});
|
|
98
|
-
const [mnemonic, setMnemonic] = useState<string | null>(null);
|
|
99
|
-
const [usePassword, setUsePassword] = useState(true);
|
|
100
|
-
const [registrationSuccess, setRegistrationSuccess] = useState(false);
|
|
101
|
-
const [registering, setRegistering] = useState(false);
|
|
102
|
-
|
|
103
|
-
const validation = {
|
|
104
|
-
username:
|
|
105
|
-
usernameValidation ||
|
|
106
|
-
Yup.string()
|
|
107
|
-
.min(
|
|
108
|
-
Constants.UsernameMinLength,
|
|
109
|
-
tComponent<SuiteCoreStringKey>(
|
|
110
|
-
SuiteCoreComponentId,
|
|
111
|
-
SuiteCoreStringKey.Validation_UsernameMinLengthTemplate
|
|
112
|
-
)
|
|
113
|
-
)
|
|
114
|
-
.max(
|
|
115
|
-
Constants.UsernameMaxLength,
|
|
116
|
-
tComponent<SuiteCoreStringKey>(
|
|
117
|
-
SuiteCoreComponentId,
|
|
118
|
-
SuiteCoreStringKey.Validation_UsernameMaxLengthTemplate
|
|
119
|
-
)
|
|
120
|
-
)
|
|
121
|
-
.matches(
|
|
122
|
-
Constants.UsernameRegex,
|
|
123
|
-
tComponent<SuiteCoreStringKey>(
|
|
124
|
-
SuiteCoreComponentId,
|
|
125
|
-
SuiteCoreStringKey.Validation_UsernameRegexErrorTemplate
|
|
126
|
-
)
|
|
127
|
-
)
|
|
128
|
-
.required(
|
|
129
|
-
tComponent<SuiteCoreStringKey>(
|
|
130
|
-
SuiteCoreComponentId,
|
|
131
|
-
SuiteCoreStringKey.Validation_Required
|
|
132
|
-
)
|
|
133
|
-
),
|
|
134
|
-
email:
|
|
135
|
-
emailValidation ||
|
|
136
|
-
Yup.string()
|
|
137
|
-
.email(
|
|
138
|
-
tComponent<SuiteCoreStringKey>(
|
|
139
|
-
SuiteCoreComponentId,
|
|
140
|
-
SuiteCoreStringKey.Validation_InvalidEmail
|
|
141
|
-
)
|
|
142
|
-
)
|
|
143
|
-
.required(
|
|
144
|
-
tComponent<SuiteCoreStringKey>(
|
|
145
|
-
SuiteCoreComponentId,
|
|
146
|
-
SuiteCoreStringKey.Validation_Required
|
|
147
|
-
)
|
|
148
|
-
),
|
|
149
|
-
timezone:
|
|
150
|
-
timezoneValidation ||
|
|
151
|
-
Yup.string()
|
|
152
|
-
.required(
|
|
153
|
-
tComponent<SuiteCoreStringKey>(
|
|
154
|
-
SuiteCoreComponentId,
|
|
155
|
-
SuiteCoreStringKey.Validation_TimezoneRequired
|
|
156
|
-
)
|
|
157
|
-
)
|
|
158
|
-
.oneOf(
|
|
159
|
-
timezones,
|
|
160
|
-
tComponent<SuiteCoreStringKey>(
|
|
161
|
-
SuiteCoreComponentId,
|
|
162
|
-
SuiteCoreStringKey.Validation_TimezoneInvalid
|
|
163
|
-
)
|
|
164
|
-
),
|
|
165
|
-
password:
|
|
166
|
-
passwordValidation ||
|
|
167
|
-
Yup.string()
|
|
168
|
-
.matches(
|
|
169
|
-
Constants.PasswordRegex,
|
|
170
|
-
tComponent<SuiteCoreStringKey>(
|
|
171
|
-
SuiteCoreComponentId,
|
|
172
|
-
SuiteCoreStringKey.Validation_PasswordRegexErrorTemplate
|
|
173
|
-
)
|
|
174
|
-
)
|
|
175
|
-
.min(
|
|
176
|
-
8,
|
|
177
|
-
tComponent<SuiteCoreStringKey>(
|
|
178
|
-
SuiteCoreComponentId,
|
|
179
|
-
SuiteCoreStringKey.Validation_PasswordMinLengthTemplate
|
|
180
|
-
)
|
|
181
|
-
)
|
|
182
|
-
.required(
|
|
183
|
-
tComponent<SuiteCoreStringKey>(
|
|
184
|
-
SuiteCoreComponentId,
|
|
185
|
-
SuiteCoreStringKey.Validation_Required
|
|
186
|
-
)
|
|
187
|
-
),
|
|
188
|
-
confirmPassword:
|
|
189
|
-
confirmPasswordValidation ||
|
|
190
|
-
Yup.string()
|
|
191
|
-
.oneOf(
|
|
192
|
-
[Yup.ref('password')],
|
|
193
|
-
tComponent<SuiteCoreStringKey>(
|
|
194
|
-
SuiteCoreComponentId,
|
|
195
|
-
SuiteCoreStringKey.Validation_PasswordMatch
|
|
196
|
-
)
|
|
197
|
-
)
|
|
198
|
-
.required(
|
|
199
|
-
tComponent<SuiteCoreStringKey>(
|
|
200
|
-
SuiteCoreComponentId,
|
|
201
|
-
SuiteCoreStringKey.Validation_Required
|
|
202
|
-
)
|
|
203
|
-
),
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const formik = useFormik<RegisterFormValues>({
|
|
207
|
-
initialValues: {
|
|
208
|
-
username: '',
|
|
209
|
-
email: '',
|
|
210
|
-
timezone: getInitialTimezone(),
|
|
211
|
-
password: '',
|
|
212
|
-
confirmPassword: '',
|
|
213
|
-
directChallenge: false,
|
|
214
|
-
...additionalInitialValues,
|
|
215
|
-
},
|
|
216
|
-
enableReinitialize: true,
|
|
217
|
-
validationSchema: Yup.object({
|
|
218
|
-
username: validation.username,
|
|
219
|
-
email: validation.email,
|
|
220
|
-
timezone: validation.timezone,
|
|
221
|
-
...(usePassword
|
|
222
|
-
? {
|
|
223
|
-
password: validation.password,
|
|
224
|
-
confirmPassword: validation.confirmPassword,
|
|
225
|
-
}
|
|
226
|
-
: {}),
|
|
227
|
-
...additionalValidation,
|
|
228
|
-
}),
|
|
229
|
-
onSubmit: async (values, { setSubmitting, setFieldError, setTouched }) => {
|
|
230
|
-
setRegistering(true);
|
|
231
|
-
const registerResult = await onSubmit(values, usePassword);
|
|
232
|
-
|
|
233
|
-
if ('success' in registerResult && registerResult.success) {
|
|
234
|
-
setRegistrationSuccess(true);
|
|
235
|
-
if (!usePassword && registerResult.mnemonic) {
|
|
236
|
-
setMnemonic(registerResult.mnemonic);
|
|
237
|
-
}
|
|
238
|
-
} else {
|
|
239
|
-
setRegistrationSuccess(false);
|
|
240
|
-
const newApiErrors: Record<string, string> = {};
|
|
241
|
-
const fieldsToTouch: Record<string, boolean> = {};
|
|
242
|
-
|
|
243
|
-
if ('field' in registerResult && registerResult.field) {
|
|
244
|
-
setFieldError(registerResult.field, registerResult.error);
|
|
245
|
-
fieldsToTouch[registerResult.field] = true;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if ('errors' in registerResult && registerResult.errors) {
|
|
249
|
-
registerResult.errors.forEach((err) => {
|
|
250
|
-
if (err.path && err.msg) {
|
|
251
|
-
setFieldError(err.path, err.msg);
|
|
252
|
-
fieldsToTouch[err.path] = true;
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (
|
|
258
|
-
'error' in registerResult &&
|
|
259
|
-
registerResult.error &&
|
|
260
|
-
!Object.keys(newApiErrors).length
|
|
261
|
-
) {
|
|
262
|
-
newApiErrors.general = registerResult.error;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
setApiErrors(newApiErrors);
|
|
266
|
-
setTouched(fieldsToTouch, false);
|
|
267
|
-
}
|
|
268
|
-
setSubmitting(false);
|
|
269
|
-
setRegistering(false);
|
|
270
|
-
setApiErrors({});
|
|
271
|
-
},
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
return (
|
|
275
|
-
<Container maxWidth="sm">
|
|
276
|
-
<Box
|
|
277
|
-
sx={{
|
|
278
|
-
mt: 8,
|
|
279
|
-
display: 'flex',
|
|
280
|
-
flexDirection: 'column',
|
|
281
|
-
alignItems: 'center',
|
|
282
|
-
}}
|
|
283
|
-
>
|
|
284
|
-
<Typography variant="h4" component="h1" gutterBottom>
|
|
285
|
-
{labels.title ||
|
|
286
|
-
tComponent<SuiteCoreStringKey>(
|
|
287
|
-
SuiteCoreComponentId,
|
|
288
|
-
SuiteCoreStringKey.Common_Registration
|
|
289
|
-
)}
|
|
290
|
-
</Typography>
|
|
291
|
-
|
|
292
|
-
<Box
|
|
293
|
-
component="form"
|
|
294
|
-
onSubmit={formik.handleSubmit}
|
|
295
|
-
sx={{ mt: 1, width: '100%' }}
|
|
296
|
-
>
|
|
297
|
-
<TextField
|
|
298
|
-
fullWidth
|
|
299
|
-
id="username"
|
|
300
|
-
name="username"
|
|
301
|
-
label={
|
|
302
|
-
labels.username ||
|
|
303
|
-
tComponent<SuiteCoreStringKey>(
|
|
304
|
-
SuiteCoreComponentId,
|
|
305
|
-
SuiteCoreStringKey.Common_Username
|
|
306
|
-
)
|
|
307
|
-
}
|
|
308
|
-
value={formik.values.username}
|
|
309
|
-
onChange={formik.handleChange}
|
|
310
|
-
onBlur={formik.handleBlur}
|
|
311
|
-
error={Boolean(
|
|
312
|
-
formik.touched.username &&
|
|
313
|
-
(formik.errors.username || apiErrors.username)
|
|
314
|
-
)}
|
|
315
|
-
helperText={
|
|
316
|
-
formik.touched.username &&
|
|
317
|
-
(formik.errors.username || apiErrors.username)
|
|
318
|
-
}
|
|
319
|
-
margin="normal"
|
|
320
|
-
/>
|
|
321
|
-
<TextField
|
|
322
|
-
fullWidth
|
|
323
|
-
id="email"
|
|
324
|
-
name="email"
|
|
325
|
-
label={
|
|
326
|
-
labels.email ||
|
|
327
|
-
tComponent<SuiteCoreStringKey>(
|
|
328
|
-
SuiteCoreComponentId,
|
|
329
|
-
SuiteCoreStringKey.Common_Email
|
|
330
|
-
)
|
|
331
|
-
}
|
|
332
|
-
value={formik.values.email}
|
|
333
|
-
onChange={formik.handleChange}
|
|
334
|
-
onBlur={formik.handleBlur}
|
|
335
|
-
error={Boolean(
|
|
336
|
-
formik.touched.email && (formik.errors.email || apiErrors.email)
|
|
337
|
-
)}
|
|
338
|
-
helperText={
|
|
339
|
-
formik.touched.email && (formik.errors.email || apiErrors.email)
|
|
340
|
-
}
|
|
341
|
-
margin="normal"
|
|
342
|
-
/>
|
|
343
|
-
<FormControl fullWidth margin="normal">
|
|
344
|
-
<InputLabel id="timezone-label">
|
|
345
|
-
{labels.timezone ||
|
|
346
|
-
tComponent<SuiteCoreStringKey>(
|
|
347
|
-
SuiteCoreComponentId,
|
|
348
|
-
SuiteCoreStringKey.Common_Timezone
|
|
349
|
-
)}
|
|
350
|
-
</InputLabel>
|
|
351
|
-
<Select
|
|
352
|
-
labelId="timezone-label"
|
|
353
|
-
id="timezone"
|
|
354
|
-
name="timezone"
|
|
355
|
-
value={formik.values.timezone}
|
|
356
|
-
onChange={formik.handleChange}
|
|
357
|
-
onBlur={formik.handleBlur}
|
|
358
|
-
error={formik.touched.timezone && Boolean(formik.errors.timezone)}
|
|
359
|
-
label={
|
|
360
|
-
labels.timezone ||
|
|
361
|
-
tComponent<SuiteCoreStringKey>(
|
|
362
|
-
SuiteCoreComponentId,
|
|
363
|
-
SuiteCoreStringKey.Common_Timezone
|
|
364
|
-
)
|
|
365
|
-
}
|
|
366
|
-
>
|
|
367
|
-
{timezones.map((tz) => (
|
|
368
|
-
<MenuItem key={tz} value={tz}>
|
|
369
|
-
{tz}
|
|
370
|
-
</MenuItem>
|
|
371
|
-
))}
|
|
372
|
-
</Select>
|
|
373
|
-
{formik.touched.timezone &&
|
|
374
|
-
(formik.errors.timezone || apiErrors.timezone) && (
|
|
375
|
-
<Typography color="error" variant="caption">
|
|
376
|
-
{formik.errors.timezone || apiErrors.timezone}
|
|
377
|
-
</Typography>
|
|
378
|
-
)}
|
|
379
|
-
</FormControl>
|
|
380
|
-
|
|
381
|
-
<Box sx={{ display: 'flex', alignItems: 'center', mt: 2 }}>
|
|
382
|
-
<Button variant="text" onClick={() => setUsePassword(!usePassword)}>
|
|
383
|
-
{usePassword
|
|
384
|
-
? labels.useMnemonic ||
|
|
385
|
-
tComponent<SuiteCoreStringKey>(
|
|
386
|
-
SuiteCoreComponentId,
|
|
387
|
-
SuiteCoreStringKey.Common_UseMnemonic
|
|
388
|
-
)
|
|
389
|
-
: labels.usePassword ||
|
|
390
|
-
tComponent<SuiteCoreStringKey>(
|
|
391
|
-
SuiteCoreComponentId,
|
|
392
|
-
SuiteCoreStringKey.Common_UsePassword
|
|
393
|
-
)}
|
|
394
|
-
</Button>
|
|
395
|
-
</Box>
|
|
396
|
-
|
|
397
|
-
{usePassword && (
|
|
398
|
-
<>
|
|
399
|
-
<TextField
|
|
400
|
-
fullWidth
|
|
401
|
-
id="password"
|
|
402
|
-
name="password"
|
|
403
|
-
label={
|
|
404
|
-
labels.password ||
|
|
405
|
-
tComponent<SuiteCoreStringKey>(
|
|
406
|
-
SuiteCoreComponentId,
|
|
407
|
-
SuiteCoreStringKey.Common_Password
|
|
408
|
-
)
|
|
409
|
-
}
|
|
410
|
-
type="password"
|
|
411
|
-
value={formik.values.password}
|
|
412
|
-
onChange={formik.handleChange}
|
|
413
|
-
onBlur={formik.handleBlur}
|
|
414
|
-
error={Boolean(
|
|
415
|
-
formik.touched.password && formik.errors.password
|
|
416
|
-
)}
|
|
417
|
-
helperText={formik.touched.password && formik.errors.password}
|
|
418
|
-
margin="normal"
|
|
419
|
-
/>
|
|
420
|
-
<TextField
|
|
421
|
-
fullWidth
|
|
422
|
-
id="confirmPassword"
|
|
423
|
-
name="confirmPassword"
|
|
424
|
-
label={
|
|
425
|
-
labels.confirmPassword ||
|
|
426
|
-
tComponent<SuiteCoreStringKey>(
|
|
427
|
-
SuiteCoreComponentId,
|
|
428
|
-
SuiteCoreStringKey.Common_ConfirmNewPassword
|
|
429
|
-
)
|
|
430
|
-
}
|
|
431
|
-
type="password"
|
|
432
|
-
value={formik.values.confirmPassword}
|
|
433
|
-
onChange={formik.handleChange}
|
|
434
|
-
onBlur={formik.handleBlur}
|
|
435
|
-
error={Boolean(
|
|
436
|
-
formik.touched.confirmPassword &&
|
|
437
|
-
formik.errors.confirmPassword
|
|
438
|
-
)}
|
|
439
|
-
helperText={
|
|
440
|
-
formik.touched.confirmPassword &&
|
|
441
|
-
formik.errors.confirmPassword
|
|
442
|
-
}
|
|
443
|
-
margin="normal"
|
|
444
|
-
/>
|
|
445
|
-
</>
|
|
446
|
-
)}
|
|
447
|
-
|
|
448
|
-
<FormControl fullWidth margin="normal">
|
|
449
|
-
<FormControlLabel
|
|
450
|
-
control={
|
|
451
|
-
<Checkbox
|
|
452
|
-
id="directChallenge"
|
|
453
|
-
name="directChallenge"
|
|
454
|
-
checked={formik.values.directChallenge || false}
|
|
455
|
-
onChange={formik.handleChange}
|
|
456
|
-
/>
|
|
457
|
-
}
|
|
458
|
-
label={tComponent<SuiteCoreStringKey>(
|
|
459
|
-
SuiteCoreComponentId,
|
|
460
|
-
SuiteCoreStringKey.Registration_DirectChallengeLabel
|
|
461
|
-
)}
|
|
462
|
-
/>
|
|
463
|
-
<FormHelperText>
|
|
464
|
-
{tComponent<SuiteCoreStringKey>(
|
|
465
|
-
SuiteCoreComponentId,
|
|
466
|
-
SuiteCoreStringKey.Registration_DirectChallengeHelper
|
|
467
|
-
)}
|
|
468
|
-
</FormHelperText>
|
|
469
|
-
</FormControl>
|
|
470
|
-
|
|
471
|
-
{additionalFields && additionalFields(formik, usePassword)}
|
|
472
|
-
|
|
473
|
-
{apiErrors.general && (
|
|
474
|
-
<Alert severity="error" sx={{ mt: 2, mb: 2 }}>
|
|
475
|
-
{apiErrors.general}
|
|
476
|
-
</Alert>
|
|
477
|
-
)}
|
|
478
|
-
|
|
479
|
-
<Button
|
|
480
|
-
type="submit"
|
|
481
|
-
fullWidth
|
|
482
|
-
variant="contained"
|
|
483
|
-
color="primary"
|
|
484
|
-
sx={{ mt: 3, mb: 2 }}
|
|
485
|
-
disabled={formik.isSubmitting}
|
|
486
|
-
>
|
|
487
|
-
{registering
|
|
488
|
-
? labels.registering ||
|
|
489
|
-
tComponent<SuiteCoreStringKey>(
|
|
490
|
-
SuiteCoreComponentId,
|
|
491
|
-
SuiteCoreStringKey.Registration_Registering
|
|
492
|
-
)
|
|
493
|
-
: labels.register ||
|
|
494
|
-
tComponent<SuiteCoreStringKey>(
|
|
495
|
-
SuiteCoreComponentId,
|
|
496
|
-
SuiteCoreStringKey.Registration_RegisterButton
|
|
497
|
-
)}
|
|
498
|
-
</Button>
|
|
499
|
-
|
|
500
|
-
{registering && (
|
|
501
|
-
<Alert
|
|
502
|
-
severity="success"
|
|
503
|
-
sx={{ mt: 2, mb: 2, whiteSpace: 'pre-wrap' }}
|
|
504
|
-
>
|
|
505
|
-
<AlertTitle>
|
|
506
|
-
{labels.registering ||
|
|
507
|
-
tComponent<SuiteCoreStringKey>(
|
|
508
|
-
SuiteCoreComponentId,
|
|
509
|
-
SuiteCoreStringKey.Registration_Registering
|
|
510
|
-
)}
|
|
511
|
-
</AlertTitle>
|
|
512
|
-
<Typography variant="body2" component="div">
|
|
513
|
-
{tComponent<SuiteCoreStringKey>(
|
|
514
|
-
SuiteCoreComponentId,
|
|
515
|
-
SuiteCoreStringKey.Registration_RegisteringMessage
|
|
516
|
-
)}
|
|
517
|
-
</Typography>
|
|
518
|
-
</Alert>
|
|
519
|
-
)}
|
|
520
|
-
|
|
521
|
-
{mnemonic && (
|
|
522
|
-
<Alert
|
|
523
|
-
severity="success"
|
|
524
|
-
sx={{ mt: 2, mb: 2, whiteSpace: 'pre-wrap' }}
|
|
525
|
-
>
|
|
526
|
-
<AlertTitle>
|
|
527
|
-
{labels.successTitle ||
|
|
528
|
-
tComponent<SuiteCoreStringKey>(
|
|
529
|
-
SuiteCoreComponentId,
|
|
530
|
-
SuiteCoreStringKey.Registration_SuccessTitle
|
|
531
|
-
)}
|
|
532
|
-
</AlertTitle>
|
|
533
|
-
<Typography variant="body2" component="div">
|
|
534
|
-
{labels.mnemonicSuccess ||
|
|
535
|
-
tComponent<SuiteCoreStringKey>(
|
|
536
|
-
SuiteCoreComponentId,
|
|
537
|
-
SuiteCoreStringKey.Registration_MnemonicSuccess
|
|
538
|
-
)}
|
|
539
|
-
<Typography
|
|
540
|
-
variant="body1"
|
|
541
|
-
component="div"
|
|
542
|
-
sx={{ mt: 1, fontFamily: 'monospace' }}
|
|
543
|
-
>
|
|
544
|
-
{mnemonic}
|
|
545
|
-
</Typography>
|
|
546
|
-
<Box sx={{ textAlign: 'center' }}>
|
|
547
|
-
<Link href="/login">
|
|
548
|
-
{labels.proceedToLogin ||
|
|
549
|
-
tComponent<SuiteCoreStringKey>(
|
|
550
|
-
SuiteCoreComponentId,
|
|
551
|
-
SuiteCoreStringKey.ProceedToLogin
|
|
552
|
-
)}
|
|
553
|
-
</Link>
|
|
554
|
-
</Box>
|
|
555
|
-
</Typography>
|
|
556
|
-
</Alert>
|
|
557
|
-
)}
|
|
558
|
-
|
|
559
|
-
{registrationSuccess && (
|
|
560
|
-
<Alert severity="success" sx={{ mt: 2, mb: 2 }}>
|
|
561
|
-
<AlertTitle>
|
|
562
|
-
{labels.successTitle ||
|
|
563
|
-
tComponent<SuiteCoreStringKey>(
|
|
564
|
-
SuiteCoreComponentId,
|
|
565
|
-
SuiteCoreStringKey.Registration_SuccessTitle
|
|
566
|
-
)}
|
|
567
|
-
</AlertTitle>
|
|
568
|
-
<Typography variant="body2" component="div">
|
|
569
|
-
{tComponent<SuiteCoreStringKey>(
|
|
570
|
-
SuiteCoreComponentId,
|
|
571
|
-
SuiteCoreStringKey.Registration_Success
|
|
572
|
-
)}
|
|
573
|
-
<Box sx={{ textAlign: 'center' }}>
|
|
574
|
-
<Link href="/login">
|
|
575
|
-
{labels.proceedToLogin ||
|
|
576
|
-
tComponent<SuiteCoreStringKey>(
|
|
577
|
-
SuiteCoreComponentId,
|
|
578
|
-
SuiteCoreStringKey.ProceedToLogin
|
|
579
|
-
)}
|
|
580
|
-
</Link>
|
|
581
|
-
</Box>
|
|
582
|
-
</Typography>
|
|
583
|
-
</Alert>
|
|
584
|
-
)}
|
|
585
|
-
{!mnemonic && !registrationSuccess && (
|
|
586
|
-
<Box sx={{ textAlign: 'center' }}>
|
|
587
|
-
<Link href="/login" variant="body2">
|
|
588
|
-
{labels.loginLink ||
|
|
589
|
-
tComponent<SuiteCoreStringKey>(
|
|
590
|
-
SuiteCoreComponentId,
|
|
591
|
-
SuiteCoreStringKey.Registration_LoginLink
|
|
592
|
-
)}
|
|
593
|
-
</Link>
|
|
594
|
-
</Box>
|
|
595
|
-
)}
|
|
596
|
-
</Box>
|
|
597
|
-
</Box>
|
|
598
|
-
</Container>
|
|
599
|
-
);
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
export default RegisterForm;
|