@digitaldefiance/express-suite-react-components 2.4.1 → 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 CHANGED
@@ -297,6 +297,10 @@ MIT © Digital Defiance
297
297
 
298
298
  ## ChangeLog
299
299
 
300
+ ### Version 2.4.2
301
+
302
+ - Add UserSettingsFormWrapper
303
+
300
304
  ### Version 2.4.1
301
305
 
302
306
  - 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.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",
@@ -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;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,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"}
@@ -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;