@digitaldefiance/express-suite-react-components 2.4.1 → 2.4.3

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 CHANGED
@@ -297,6 +297,15 @@ MIT © Digital Defiance
297
297
 
298
298
  ## ChangeLog
299
299
 
300
+ ### Version 2.4.3
301
+
302
+ - Simplify UserSettingsForm/Wrapper
303
+ - Upgrade i18n/CurrencyInput
304
+
305
+ ### Version 2.4.2
306
+
307
+ - Add UserSettingsFormWrapper
308
+
300
309
  ### Version 2.4.1
301
310
 
302
311
  - Add directChallenge configuration option to registration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/express-suite-react-components",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "React MUI components for Digital Defiance Express Suite",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "react-router-dom": "6.29.0"
26
26
  },
27
27
  "dependencies": {
28
- "@digitaldefiance/i18n-lib": "3.6.0",
29
- "@digitaldefiance/suite-core-lib": "^2.2.13",
28
+ "@digitaldefiance/i18n-lib": "3.6.1",
29
+ "@digitaldefiance/suite-core-lib": "^2.2.14",
30
30
  "@emotion/react": "^11.14.0",
31
31
  "@emotion/styled": "^11.14.0",
32
32
  "@mui/icons-material": "^7.0.2",
@@ -34,7 +34,9 @@
34
34
  "@mui/system": "^7.0.2",
35
35
  "@mui/x-date-pickers": "^8.9.0",
36
36
  "axios": "^1.9.0",
37
+ "currency-codes": "^2.2.0",
37
38
  "formik": "^2.4.6",
39
+ "moment-timezone": "^0.6.0",
38
40
  "react-number-format": "^5.4.4",
39
41
  "yup": "^1.6.1"
40
42
  },
@@ -2,17 +2,12 @@ export interface CurrencyInputProps {
2
2
  value: number;
3
3
  onChange: (value: number) => void;
4
4
  currencyCode?: string;
5
+ locale?: string;
5
6
  label: string;
6
7
  error?: boolean;
7
8
  helperText?: string;
8
9
  name: string;
9
10
  }
10
- export declare function getCurrencyFormat(currencyCode?: string): {
11
- symbol: string;
12
- position: 'prefix' | 'postfix' | 'infix';
13
- groupSeparator: string;
14
- decimalSeparator: string;
15
- };
16
11
  export declare const CurrencyInput: React.FC<CurrencyInputProps>;
17
12
  export default CurrencyInput;
18
13
  //# sourceMappingURL=CurrencyInput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyInput.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/CurrencyInput.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,iBAAiB,CAAC,YAAY,GAAE,MAAc,GAAG;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAOA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA6DtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"CurrencyInput.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/CurrencyInput.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA8DtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,20 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CurrencyInput = void 0;
4
- exports.getCurrencyFormat = getCurrencyFormat;
5
4
  const jsx_runtime_1 = require("react/jsx-runtime");
6
5
  const material_1 = require("@mui/material");
7
6
  const react_number_format_1 = require("react-number-format");
8
- function getCurrencyFormat(currencyCode = 'USD') {
9
- return {
10
- symbol: '$',
11
- position: 'prefix',
12
- groupSeparator: ',',
13
- decimalSeparator: '.',
14
- };
15
- }
16
- const CurrencyInput = ({ value, onChange, currencyCode = 'USD', label, error, helperText, name, }) => {
17
- const format = getCurrencyFormat(currencyCode);
7
+ const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
8
+ const CurrencyInput = ({ value, onChange, currencyCode = 'USD', locale = 'en-US', label, error, helperText, name, }) => {
9
+ const format = (0, i18n_lib_1.getCurrencyFormat)(locale, currencyCode);
18
10
  if (format.position === 'infix') {
19
11
  const [whole, decimal] = value.toString().split('.');
20
12
  const displayValue = `${whole}${format.symbol}${format.decimalSeparator}${decimal || '00'}`;
@@ -23,15 +23,10 @@ export interface UserSettingsFormProps {
23
23
  msg: string;
24
24
  }>;
25
25
  }>;
26
- timezones: string[];
27
26
  languages: Array<{
28
27
  code: string;
29
28
  label: string;
30
29
  }>;
31
- currencies: Array<{
32
- code: string;
33
- label: string;
34
- }>;
35
30
  emailValidation?: Yup.StringSchema;
36
31
  timezoneValidation?: Yup.StringSchema;
37
32
  siteLanguageValidation?: Yup.StringSchema;
@@ -1 +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"}
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,EAAqB,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAM3B,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,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,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,CAqQtD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -7,24 +7,29 @@ const material_1 = require("@mui/material");
7
7
  const formik_1 = require("formik");
8
8
  const react_1 = require("react");
9
9
  const Yup = tslib_1.__importStar(require("yup"));
10
+ const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
11
+ const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
10
12
  const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
11
13
  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 UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
15
+ const { tComponent } = (0, contexts_1.useI18n)();
14
16
  const [apiErrors, setApiErrors] = (0, react_1.useState)({});
15
17
  const [saving, setSaving] = (0, react_1.useState)(false);
16
18
  const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
19
+ const timezones = (0, react_1.useMemo)(() => moment_timezone_1.default.tz.names(), []);
20
+ const currencies = (0, react_1.useMemo)(() => i18n_lib_1.CurrencyCode.getAllData().map(c => ({ code: c.code, label: `${c.code} - ${c.currency}` })), []);
17
21
  const validation = {
18
22
  email: emailValidation || Yup.string()
19
23
  .email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
20
24
  .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
21
25
  timezone: timezoneValidation || Yup.string()
22
26
  .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)),
27
+ .test('valid-timezone', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid), (value) => !value || moment_timezone_1.default.tz.zone(value) !== null),
24
28
  siteLanguage: siteLanguageValidation || Yup.string()
25
29
  .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
26
30
  currency: currencyValidation || Yup.string()
27
- .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
31
+ .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
32
+ .test('valid-currency', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required), (value) => !value || i18n_lib_1.CurrencyCode.isValid(value)),
28
33
  darkMode: darkModeValidation || Yup.boolean()
29
34
  .required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
30
35
  directChallenge: directChallengeValidation || Yup.boolean()
@@ -12,4 +12,12 @@ 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
+ languages: Array<{
18
+ code: string;
19
+ label: string;
20
+ }>;
21
+ }
22
+ export declare const UserSettingsFormWrapper: FC<UserSettingsFormWrapperProps>;
15
23
  //# 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;AAcxD,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"}
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,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CAwCpE,CAAC"}
@@ -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, languages }) => {
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, languages: languages }));
160
+ };
161
+ exports.UserSettingsFormWrapper = UserSettingsFormWrapper;