@digitaldefiance/express-suite-react-components 2.4.0 → 2.4.2
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/README.md +10 -0
- package/package.json +2 -2
- package/src/components/RegisterForm.d.ts.map +1 -1
- package/src/components/RegisterForm.js +2 -1
- package/src/components/UserSettingsForm.d.ts +61 -0
- package/src/components/UserSettingsForm.d.ts.map +1 -0
- package/src/components/UserSettingsForm.js +88 -0
- package/src/components/index.d.ts +1 -0
- package/src/components/index.d.ts.map +1 -1
- package/src/components/index.js +1 -0
- package/src/wrappers/index.d.ts +13 -0
- package/src/wrappers/index.d.ts.map +1 -1
- package/src/wrappers/index.js +31 -1
package/README.md
CHANGED
|
@@ -297,6 +297,16 @@ MIT © Digital Defiance
|
|
|
297
297
|
|
|
298
298
|
## ChangeLog
|
|
299
299
|
|
|
300
|
+
### Version 2.4.2
|
|
301
|
+
|
|
302
|
+
- Add UserSettingsFormWrapper
|
|
303
|
+
|
|
304
|
+
### Version 2.4.1
|
|
305
|
+
|
|
306
|
+
- Add directChallenge configuration option to registration
|
|
307
|
+
- Add user settings form
|
|
308
|
+
- Update suite core lib
|
|
309
|
+
|
|
300
310
|
### Version 2.4.0
|
|
301
311
|
|
|
302
312
|
#### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@digitaldefiance/i18n-lib": "3.6.0",
|
|
29
|
-
"@digitaldefiance/suite-core-lib": "^2.2.
|
|
29
|
+
"@digitaldefiance/suite-core-lib": "^2.2.13",
|
|
30
30
|
"@emotion/react": "^11.14.0",
|
|
31
31
|
"@emotion/styled": "^11.14.0",
|
|
32
32
|
"@mui/icons-material": "^7.0.2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/RegisterForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RegisterForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/RegisterForm.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,KAAK,OAAO,CACnE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CACvG,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,EAAE,MAAM,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,yBAAyB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC7C,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAC;IAC1E,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA8R9C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -43,6 +43,7 @@ const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidat
|
|
|
43
43
|
timezone: getInitialTimezone(),
|
|
44
44
|
password: '',
|
|
45
45
|
confirmPassword: '',
|
|
46
|
+
directChallenge: false,
|
|
46
47
|
...additionalInitialValues,
|
|
47
48
|
},
|
|
48
49
|
enableReinitialize: true,
|
|
@@ -96,7 +97,7 @@ const RegisterForm = ({ onSubmit, timezones, getInitialTimezone, usernameValidat
|
|
|
96
97
|
});
|
|
97
98
|
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 8, display: 'flex', flexDirection: 'column', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Registration) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "username", name: "username", label: labels.username || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Username), value: formik.values.username, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.username && (formik.errors.username || apiErrors.username)), helperText: formik.touched.username && (formik.errors.username || apiErrors.username), margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email), value: formik.values.email, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.email && (formik.errors.email || apiErrors.email)), helperText: formik.touched.email && (formik.errors.email || apiErrors.email), margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "timezone-label", children: labels.timezone || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "timezone-label", id: "timezone", name: "timezone", value: formik.values.timezone, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.timezone && Boolean(formik.errors.timezone), label: labels.timezone || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone), children: timezones.map((tz) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: tz, children: tz }, tz))) }), formik.touched.timezone && (formik.errors.timezone || apiErrors.timezone) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.timezone || apiErrors.timezone }))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', alignItems: 'center', mt: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: () => setUsePassword(!usePassword), children: usePassword
|
|
98
99
|
? labels.useMnemonic || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UseMnemonic)
|
|
99
|
-
: labels.usePassword || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UsePassword) }) }), usePassword && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "password", name: "password", label: labels.password || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password), type: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.password && formik.errors.password), helperText: formik.touched.password && formik.errors.password, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword), type: "password", value: formik.values.confirmPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword), helperText: formik.touched.confirmPassword && formik.errors.confirmPassword, margin: "normal" })] })), additionalFields && additionalFields(formik, usePassword), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: registering
|
|
100
|
+
: labels.usePassword || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_UsePassword) }) }), usePassword && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "password", name: "password", label: labels.password || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Password), type: "password", value: formik.values.password, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.password && formik.errors.password), helperText: formik.touched.password && formik.errors.password, margin: "normal" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "confirmPassword", name: "confirmPassword", label: labels.confirmPassword || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_ConfirmNewPassword), type: "password", value: formik.values.confirmPassword, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword), helperText: formik.touched.confirmPassword && formik.errors.confirmPassword, margin: "normal" })] })), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge || false, onChange: formik.handleChange }), label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik, usePassword), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: registering
|
|
100
101
|
? labels.registering || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Registering)
|
|
101
102
|
: labels.register || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_RegisterButton) }), registering && ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2, whiteSpace: 'pre-wrap' }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.registering || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Registering) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", component: "div", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_RegisteringMessage) })] })), mnemonic && ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2, whiteSpace: 'pre-wrap' }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [labels.mnemonicSuccess || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_MnemonicSuccess), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", component: "div", sx: { mt: 1, fontFamily: 'monospace' }, children: mnemonic }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] })), registrationSuccess && ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.AlertTitle, { children: labels.successTitle || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_SuccessTitle) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", component: "div", children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_Success), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", children: labels.proceedToLogin || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin) }) })] })] })), !mnemonic && !registrationSuccess && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { textAlign: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Link, { href: "/login", variant: "body2", children: labels.loginLink || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_LoginLink) }) }))] })] }) }));
|
|
102
103
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import * as Yup from 'yup';
|
|
3
|
+
export interface UserSettingsFormValues {
|
|
4
|
+
email: string;
|
|
5
|
+
timezone: string;
|
|
6
|
+
siteLanguage: string;
|
|
7
|
+
currency: string;
|
|
8
|
+
darkMode: boolean;
|
|
9
|
+
directChallenge: boolean;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export interface UserSettingsFormProps {
|
|
13
|
+
initialValues: UserSettingsFormValues;
|
|
14
|
+
onSubmit: (values: UserSettingsFormValues) => Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
} | {
|
|
18
|
+
error: string;
|
|
19
|
+
errorType?: string;
|
|
20
|
+
field?: string;
|
|
21
|
+
errors?: Array<{
|
|
22
|
+
path: string;
|
|
23
|
+
msg: string;
|
|
24
|
+
}>;
|
|
25
|
+
}>;
|
|
26
|
+
timezones: string[];
|
|
27
|
+
languages: Array<{
|
|
28
|
+
code: string;
|
|
29
|
+
label: string;
|
|
30
|
+
}>;
|
|
31
|
+
currencies: Array<{
|
|
32
|
+
code: string;
|
|
33
|
+
label: string;
|
|
34
|
+
}>;
|
|
35
|
+
emailValidation?: Yup.StringSchema;
|
|
36
|
+
timezoneValidation?: Yup.StringSchema;
|
|
37
|
+
siteLanguageValidation?: Yup.StringSchema;
|
|
38
|
+
currencyValidation?: Yup.StringSchema;
|
|
39
|
+
darkModeValidation?: Yup.BooleanSchema;
|
|
40
|
+
directChallengeValidation?: Yup.BooleanSchema;
|
|
41
|
+
additionalFields?: (formik: any) => React.ReactNode;
|
|
42
|
+
additionalInitialValues?: Record<string, any>;
|
|
43
|
+
additionalValidation?: Record<string, Yup.Schema>;
|
|
44
|
+
labels?: {
|
|
45
|
+
title?: string;
|
|
46
|
+
email?: string;
|
|
47
|
+
emailHelper?: string;
|
|
48
|
+
timezone?: string;
|
|
49
|
+
siteLanguage?: string;
|
|
50
|
+
currency?: string;
|
|
51
|
+
darkMode?: string;
|
|
52
|
+
directChallenge?: string;
|
|
53
|
+
directChallengeHelper?: string;
|
|
54
|
+
saving?: string;
|
|
55
|
+
save?: string;
|
|
56
|
+
successMessage?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export declare const UserSettingsForm: FC<UserSettingsFormProps>;
|
|
60
|
+
export default UserSettingsForm;
|
|
61
|
+
//# sourceMappingURL=UserSettingsForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserSettingsForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserSettingsForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,sBAAsB,CAAC;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,OAAO,CACjD;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACrC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CACvG,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,sBAAsB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC1C,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;IACvC,yBAAyB,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;IAC9C,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,KAAK,CAAC,SAAS,CAAC;IACpD,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAmQtD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserSettingsForm = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const formik_1 = require("formik");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
|
+
const contexts_1 = require("../contexts");
|
|
12
|
+
const UserSettingsForm = ({ initialValues, onSubmit, timezones, languages, currencies, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
|
|
13
|
+
const { t, tComponent } = (0, contexts_1.useI18n)();
|
|
14
|
+
const [apiErrors, setApiErrors] = (0, react_1.useState)({});
|
|
15
|
+
const [saving, setSaving] = (0, react_1.useState)(false);
|
|
16
|
+
const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
|
|
17
|
+
const validation = {
|
|
18
|
+
email: emailValidation || Yup.string()
|
|
19
|
+
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
20
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
21
|
+
timezone: timezoneValidation || Yup.string()
|
|
22
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneRequired))
|
|
23
|
+
.oneOf(timezones, tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid)),
|
|
24
|
+
siteLanguage: siteLanguageValidation || Yup.string()
|
|
25
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
26
|
+
currency: currencyValidation || Yup.string()
|
|
27
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
28
|
+
darkMode: darkModeValidation || Yup.boolean()
|
|
29
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
30
|
+
directChallenge: directChallengeValidation || Yup.boolean()
|
|
31
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
32
|
+
};
|
|
33
|
+
const formik = (0, formik_1.useFormik)({
|
|
34
|
+
initialValues: {
|
|
35
|
+
...initialValues,
|
|
36
|
+
...additionalInitialValues,
|
|
37
|
+
},
|
|
38
|
+
enableReinitialize: true,
|
|
39
|
+
validationSchema: Yup.object({
|
|
40
|
+
email: validation.email,
|
|
41
|
+
timezone: validation.timezone,
|
|
42
|
+
siteLanguage: validation.siteLanguage,
|
|
43
|
+
currency: validation.currency,
|
|
44
|
+
darkMode: validation.darkMode,
|
|
45
|
+
directChallenge: validation.directChallenge,
|
|
46
|
+
...additionalValidation,
|
|
47
|
+
}),
|
|
48
|
+
onSubmit: async (values, { setSubmitting, setFieldError, setTouched }) => {
|
|
49
|
+
setSaving(true);
|
|
50
|
+
setSuccessMessage(null);
|
|
51
|
+
const result = await onSubmit(values);
|
|
52
|
+
if ('success' in result && result.success) {
|
|
53
|
+
setSuccessMessage(result.message || labels.successMessage || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SaveSuccess));
|
|
54
|
+
setApiErrors({});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const newApiErrors = {};
|
|
58
|
+
const fieldsToTouch = {};
|
|
59
|
+
if ('field' in result && result.field) {
|
|
60
|
+
setFieldError(result.field, result.error);
|
|
61
|
+
fieldsToTouch[result.field] = true;
|
|
62
|
+
}
|
|
63
|
+
if ('errors' in result && result.errors) {
|
|
64
|
+
result.errors.forEach((err) => {
|
|
65
|
+
if (err.path && err.msg) {
|
|
66
|
+
setFieldError(err.path, err.msg);
|
|
67
|
+
fieldsToTouch[err.path] = true;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if ('error' in result && result.error && !Object.keys(newApiErrors).length) {
|
|
72
|
+
newApiErrors.general = result.error;
|
|
73
|
+
}
|
|
74
|
+
setApiErrors(newApiErrors);
|
|
75
|
+
setTouched(fieldsToTouch, false);
|
|
76
|
+
}
|
|
77
|
+
setSubmitting(false);
|
|
78
|
+
setSaving(false);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 4, display: 'flex', flexDirection: 'column', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: labels.title || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Title) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "form", onSubmit: formik.handleSubmit, sx: { mt: 1, width: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { fullWidth: true, id: "email", name: "email", label: labels.email || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Email), value: formik.values.email, onChange: formik.handleChange, onBlur: formik.handleBlur, error: Boolean(formik.touched.email && (formik.errors.email || apiErrors.email)), helperText: (formik.touched.email && (formik.errors.email || apiErrors.email)) ||
|
|
82
|
+
labels.emailHelper ||
|
|
83
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_EmailHelper), margin: "normal" }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "timezone-label", children: labels.timezone || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "timezone-label", id: "timezone", name: "timezone", value: formik.values.timezone, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.timezone && Boolean(formik.errors.timezone), label: labels.timezone || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Timezone), children: timezones.map((tz) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: tz, children: tz }, tz))) }), formik.touched.timezone && (formik.errors.timezone || apiErrors.timezone) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.timezone || apiErrors.timezone }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "language-label", children: labels.siteLanguage || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "language-label", id: "siteLanguage", name: "siteLanguage", value: formik.values.siteLanguage, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.siteLanguage && Boolean(formik.errors.siteLanguage), label: labels.siteLanguage || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_SiteLanguage), children: languages.map((lang) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: lang.code, children: lang.label }, lang.code))) }), formik.touched.siteLanguage && (formik.errors.siteLanguage || apiErrors.siteLanguage) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.siteLanguage || apiErrors.siteLanguage }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "currency-label", children: labels.currency || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency) }), (0, jsx_runtime_1.jsx)(material_1.Select, { labelId: "currency-label", id: "currency", name: "currency", value: formik.values.currency, onChange: formik.handleChange, onBlur: formik.handleBlur, error: formik.touched.currency && Boolean(formik.errors.currency), label: labels.currency || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Currency), children: currencies.map((curr) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: curr.code, children: curr.label }, curr.code))) }), formik.touched.currency && (formik.errors.currency || apiErrors.currency) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", variant: "caption", children: formik.errors.currency || apiErrors.currency }))] }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { fullWidth: true, margin: "normal", children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "darkMode", name: "darkMode", checked: formik.values.darkMode, onChange: formik.handleChange }), label: labels.darkMode || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_DarkMode) }) }), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, margin: "normal", children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { id: "directChallenge", name: "directChallenge", checked: formik.values.directChallenge, onChange: formik.handleChange }), label: labels.directChallenge || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeLabel) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", sx: { ml: 4, mt: -1 }, children: labels.directChallengeHelper || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_DirectChallengeHelper) })] }), additionalFields && additionalFields(formik), apiErrors.general && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mt: 2, mb: 2 }, children: apiErrors.general })), successMessage && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "success", sx: { mt: 2, mb: 2 }, children: successMessage })), (0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", fullWidth: true, variant: "contained", color: "primary", sx: { mt: 3, mb: 2 }, disabled: formik.isSubmitting, children: saving
|
|
84
|
+
? labels.saving || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Saving)
|
|
85
|
+
: labels.save || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Settings_Save) })] })] }) }));
|
|
86
|
+
};
|
|
87
|
+
exports.UserSettingsForm = UserSettingsForm;
|
|
88
|
+
exports.default = exports.UserSettingsForm;
|
|
@@ -14,6 +14,7 @@ export * from './LoginForm';
|
|
|
14
14
|
export * from './LogoutPage';
|
|
15
15
|
export * from './RegisterForm';
|
|
16
16
|
export * from './ResetPasswordForm';
|
|
17
|
+
export * from './UserSettingsForm';
|
|
17
18
|
export * from './SideMenu';
|
|
18
19
|
export * from './SideMenuListItem';
|
|
19
20
|
export * from './TopMenu';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
|
package/src/components/index.js
CHANGED
|
@@ -18,6 +18,7 @@ tslib_1.__exportStar(require("./LoginForm"), exports);
|
|
|
18
18
|
tslib_1.__exportStar(require("./LogoutPage"), exports);
|
|
19
19
|
tslib_1.__exportStar(require("./RegisterForm"), exports);
|
|
20
20
|
tslib_1.__exportStar(require("./ResetPasswordForm"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./UserSettingsForm"), exports);
|
|
21
22
|
tslib_1.__exportStar(require("./SideMenu"), exports);
|
|
22
23
|
tslib_1.__exportStar(require("./SideMenuListItem"), exports);
|
|
23
24
|
tslib_1.__exportStar(require("./TopMenu"), exports);
|
package/src/wrappers/index.d.ts
CHANGED
|
@@ -12,4 +12,17 @@ export interface VerifyEmailPageWrapperProps {
|
|
|
12
12
|
baseUrl: string;
|
|
13
13
|
}
|
|
14
14
|
export declare const VerifyEmailPageWrapper: FC<VerifyEmailPageWrapperProps>;
|
|
15
|
+
export interface UserSettingsFormWrapperProps {
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
timezones: string[];
|
|
18
|
+
languages: Array<{
|
|
19
|
+
code: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}>;
|
|
22
|
+
currencies: Array<{
|
|
23
|
+
code: string;
|
|
24
|
+
label: string;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export declare const UserSettingsFormWrapper: FC<UserSettingsFormWrapperProps>;
|
|
15
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAexD,eAAO,MAAM,sBAAsB,EAAE,EAWpC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAoC1D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,EAevC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAkC9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,EAyBjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,EAK/B,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAelE,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CA4CpE,CAAC"}
|
package/src/wrappers/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VerifyEmailPageWrapper = exports.LogoutPageWrapper = exports.RegisterFormWrapper = exports.LoginFormWrapper = exports.ChangePasswordFormWrapper = exports.BackupCodesWrapper = exports.BackupCodeLoginWrapper = void 0;
|
|
3
|
+
exports.UserSettingsFormWrapper = exports.VerifyEmailPageWrapper = exports.LogoutPageWrapper = exports.RegisterFormWrapper = exports.LoginFormWrapper = exports.ChangePasswordFormWrapper = exports.BackupCodesWrapper = exports.BackupCodeLoginWrapper = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_router_dom_1 = require("react-router-dom");
|
|
@@ -12,6 +12,7 @@ const LoginForm_1 = require("../components/LoginForm");
|
|
|
12
12
|
const RegisterForm_1 = require("../components/RegisterForm");
|
|
13
13
|
const LogoutPage_1 = require("../components/LogoutPage");
|
|
14
14
|
const VerifyEmailPage_1 = require("../components/VerifyEmailPage");
|
|
15
|
+
const UserSettingsForm_1 = require("../components/UserSettingsForm");
|
|
15
16
|
const contexts_1 = require("../contexts");
|
|
16
17
|
const services_1 = require("../services");
|
|
17
18
|
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
@@ -129,3 +130,32 @@ const VerifyEmailPageWrapper = ({ baseUrl }) => {
|
|
|
129
130
|
return (0, jsx_runtime_1.jsx)(VerifyEmailPage_1.VerifyEmailPage, { token: token, onVerify: handleVerify });
|
|
130
131
|
};
|
|
131
132
|
exports.VerifyEmailPageWrapper = VerifyEmailPageWrapper;
|
|
133
|
+
const UserSettingsFormWrapper = ({ baseUrl, timezones, languages, currencies }) => {
|
|
134
|
+
const { userData, setCurrencyCode, setLanguage } = (0, contexts_1.useAuth)();
|
|
135
|
+
const api = (0, services_1.createAuthenticatedApiClient)(baseUrl);
|
|
136
|
+
const handleSubmit = async (values) => {
|
|
137
|
+
try {
|
|
138
|
+
const result = await api.post('/user/settings', values);
|
|
139
|
+
if (values.currency) {
|
|
140
|
+
await setCurrencyCode(values.currency);
|
|
141
|
+
}
|
|
142
|
+
if (values.siteLanguage) {
|
|
143
|
+
await setLanguage(values.siteLanguage);
|
|
144
|
+
}
|
|
145
|
+
return { success: true, message: result.data.message };
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return { error: error.response?.data?.message || 'Failed to update settings' };
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const initialValues = {
|
|
152
|
+
email: userData?.email || '',
|
|
153
|
+
timezone: userData?.timezone || 'UTC',
|
|
154
|
+
siteLanguage: userData?.siteLanguage || 'en-US',
|
|
155
|
+
currency: userData?.currency || 'USD',
|
|
156
|
+
darkMode: userData?.darkMode || false,
|
|
157
|
+
directChallenge: userData?.directChallenge || false,
|
|
158
|
+
};
|
|
159
|
+
return ((0, jsx_runtime_1.jsx)(UserSettingsForm_1.UserSettingsForm, { initialValues: initialValues, onSubmit: handleSubmit, timezones: timezones, languages: languages, currencies: currencies }));
|
|
160
|
+
};
|
|
161
|
+
exports.UserSettingsFormWrapper = UserSettingsFormWrapper;
|