@digitaldefiance/express-suite-react-components 2.4.2 → 2.4.4
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 +11 -0
- package/package.json +5 -3
- package/src/components/CurrencyInput.d.ts +1 -6
- package/src/components/CurrencyInput.d.ts.map +1 -1
- package/src/components/CurrencyInput.js +3 -11
- package/src/components/TopMenu.js +2 -2
- package/src/components/UserSettingsForm.d.ts +0 -5
- package/src/components/UserSettingsForm.d.ts.map +1 -1
- package/src/components/UserSettingsForm.js +9 -4
- package/src/components/VerifyEmailPage.js +7 -7
- package/src/contexts/AuthProvider.js +6 -6
- package/src/contexts/MenuContext.d.ts +1 -0
- package/src/contexts/MenuContext.d.ts.map +1 -1
- package/src/contexts/MenuContext.js +40 -31
- package/src/wrappers/index.d.ts +0 -5
- package/src/wrappers/index.d.ts.map +1 -1
- package/src/wrappers/index.js +2 -2
package/README.md
CHANGED
|
@@ -297,6 +297,17 @@ MIT © Digital Defiance
|
|
|
297
297
|
|
|
298
298
|
## ChangeLog
|
|
299
299
|
|
|
300
|
+
### Version 2.4.4
|
|
301
|
+
|
|
302
|
+
- Fix t(tComponent( calls
|
|
303
|
+
- Add enableBackupCode to MenuProvider
|
|
304
|
+
- Add User Settings to menu
|
|
305
|
+
|
|
306
|
+
### Version 2.4.3
|
|
307
|
+
|
|
308
|
+
- Simplify UserSettingsForm/Wrapper
|
|
309
|
+
- Upgrade i18n/CurrencyInput
|
|
310
|
+
|
|
300
311
|
### Version 2.4.2
|
|
301
312
|
|
|
302
313
|
- Add UserSettingsFormWrapper
|
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.4",
|
|
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.
|
|
29
|
-
"@digitaldefiance/suite-core-lib": "^2.2.
|
|
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":"
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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'}`;
|
|
@@ -25,14 +25,14 @@ const TopMenu = ({ Logo, additionalMenus }) => {
|
|
|
25
25
|
const appConfig = 'APP_CONFIG' in window
|
|
26
26
|
? window.APP_CONFIG
|
|
27
27
|
: undefined;
|
|
28
|
-
const siteTitle =
|
|
28
|
+
const siteTitle = tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_SiteTemplate);
|
|
29
29
|
return ((0, jsx_runtime_1.jsxs)(material_1.AppBar, { position: "fixed", sx: { top: 10 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Toolbar, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "large", edge: "start", color: "inherit", "aria-label": "menu", sx: { mr: 2 }, onClick: handleOpenSideMenu, children: (0, jsx_runtime_1.jsx)(Menu_1.default, {}) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
30
30
|
height: 40,
|
|
31
31
|
width: 40,
|
|
32
32
|
marginRight: 2,
|
|
33
33
|
display: 'flex',
|
|
34
34
|
alignItems: 'center',
|
|
35
|
-
}, children: Logo }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: { flexGrow: 1 }, children: siteTitle }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', alignItems: 'center' }, children: [isAuthenticated ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/dashboard", children:
|
|
35
|
+
}, children: Logo }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: { flexGrow: 1 }, children: siteTitle }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', alignItems: 'center' }, children: [isAuthenticated ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/dashboard", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_Dashboard) }), getTopMenus().map((menu, index) => menu.isUserMenu ? (0, jsx_runtime_1.jsx)(UserMenu_1.UserMenu, {}, `user-menu`) : (0, jsx_runtime_1.jsx)(DropdownMenu_1.DropdownMenu, { menuType: menu.menuType, menuIcon: menu.menuIcon }, `menu-${index}`))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/login", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Login_LoginButton) }), (0, jsx_runtime_1.jsx)(material_1.Button, { color: "inherit", component: react_router_dom_1.Link, to: "/register", children: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RegisterButton) })] })), (0, jsx_runtime_1.jsx)(UserLanguageSelector_1.UserLanguageSelector, {})] })] }), (0, jsx_runtime_1.jsx)(SideMenu_1.SideMenu, { isOpen: isSideMenuOpen, onClose: handleCloseSideMenu })] }));
|
|
36
36
|
};
|
|
37
37
|
exports.TopMenu = TopMenu;
|
|
38
38
|
exports.default = exports.TopMenu;
|
|
@@ -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,
|
|
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,
|
|
13
|
-
const {
|
|
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
|
-
.
|
|
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,13 +12,13 @@ const VerifyEmailPage = ({ token, onVerify, labels = {}, loginLink = '/login', r
|
|
|
12
12
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
13
13
|
const [verificationStatus, setVerificationStatus] = (0, react_1.useState)('pending');
|
|
14
14
|
const translatedLabels = {
|
|
15
|
-
title: labels.title ||
|
|
16
|
-
success: labels.success ||
|
|
17
|
-
failed: labels.failed ||
|
|
18
|
-
noToken: labels.noToken ||
|
|
19
|
-
proceedToLogin: labels.proceedToLogin ||
|
|
20
|
-
contactSupport: labels.contactSupport ||
|
|
21
|
-
requestNewEmail: labels.requestNewEmail ||
|
|
15
|
+
title: labels.title || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_EmailVerification),
|
|
16
|
+
success: labels.success || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Success),
|
|
17
|
+
failed: labels.failed || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Failed),
|
|
18
|
+
noToken: labels.noToken || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.NoVerificationTokenProvided),
|
|
19
|
+
proceedToLogin: labels.proceedToLogin || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin),
|
|
20
|
+
contactSupport: labels.contactSupport || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.HavingTroubleContactSupport),
|
|
21
|
+
requestNewEmail: labels.requestNewEmail || tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RequestNewVerificationEmail),
|
|
22
22
|
};
|
|
23
23
|
(0, react_1.useEffect)(() => {
|
|
24
24
|
const verifyEmail = async (verificationToken) => {
|
|
@@ -170,7 +170,7 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
170
170
|
}, []);
|
|
171
171
|
const passwordLogin = (0, react_1.useCallback)(async (password, username, email) => {
|
|
172
172
|
if (!isPasswordLoginAvailable()) {
|
|
173
|
-
return { error:
|
|
173
|
+
return { error: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Error_Login_PasswordLoginNotSetup), errorType: 'PasswordLoginNotSetup' };
|
|
174
174
|
}
|
|
175
175
|
setLoading(true);
|
|
176
176
|
const passwordLoginService = getPasswordLoginService();
|
|
@@ -216,11 +216,11 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
216
216
|
setLoading(false);
|
|
217
217
|
setWallet(wallet);
|
|
218
218
|
setMnemonic(mnemonic);
|
|
219
|
-
return { success: true, message:
|
|
219
|
+
return { success: true, message: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordLogin_Setup_Success) };
|
|
220
220
|
}
|
|
221
221
|
catch {
|
|
222
222
|
setLoading(false);
|
|
223
|
-
return { success: false, message:
|
|
223
|
+
return { success: false, message: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordLogin_Setup_Failure) };
|
|
224
224
|
}
|
|
225
225
|
}, [setMnemonic, setWallet, t, tComponent]);
|
|
226
226
|
const backupCodeLogin = (0, react_1.useCallback)(async (identifier, code, isEmail, recoverMnemonic, newPassword) => {
|
|
@@ -270,7 +270,7 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
270
270
|
}, [baseUrl]);
|
|
271
271
|
const changePassword = (0, react_1.useCallback)(async (currentPassword, newPassword) => {
|
|
272
272
|
if (!isPasswordLoginAvailable()) {
|
|
273
|
-
return { error:
|
|
273
|
+
return { error: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Error_Login_PasswordLoginNotSetup), errorType: 'PasswordLoginNotSetup' };
|
|
274
274
|
}
|
|
275
275
|
setLoading(true);
|
|
276
276
|
try {
|
|
@@ -278,13 +278,13 @@ const AuthProviderInner = ({ children, baseUrl, constants, eciesConfig, onLogout
|
|
|
278
278
|
const { mnemonic, wallet } = await passwordLoginService.getWalletAndMnemonicFromLocalStorageBundle(new ecies_lib_1.SecureString(currentPassword));
|
|
279
279
|
if (!mnemonic) {
|
|
280
280
|
setLoading(false);
|
|
281
|
-
return { error:
|
|
281
|
+
return { error: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordLogin_InvalidCurrentPassword), errorType: 'InvalidCurrentPassword' };
|
|
282
282
|
}
|
|
283
283
|
await passwordLoginService.setupPasswordLoginLocalStorageBundle(mnemonic, new ecies_lib_1.SecureString(newPassword));
|
|
284
284
|
setLoading(false);
|
|
285
285
|
setWallet(wallet);
|
|
286
286
|
setMnemonic(mnemonic);
|
|
287
|
-
return { success: true, message:
|
|
287
|
+
return { success: true, message: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.PasswordChange_Success) };
|
|
288
288
|
}
|
|
289
289
|
catch (error) {
|
|
290
290
|
setLoading(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuContext.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/MenuContext.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MenuContext.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/MenuContext.tsx"],"names":[],"mappings":"AAiBA,OAAO,EACL,EAAE,EACF,SAAS,EAQV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,QAAQ,EAAa,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,UAAU,eAAe;IACvB,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,cAAc,EAAE,CACd,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,OAAO,KACrB,WAAW,EAAE,CAAC;IACnB,kBAAkB,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,IAAI,CAAC;IACxD,mBAAmB,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,MAAM,IAAI,CAAC;IAC5D,WAAW,EAAE,MAAM,KAAK,CAAC,WAAW,CAAC,CAAC;CACvC;AAID,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAiP9C,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,eAM1B,CAAC"}
|
|
@@ -12,11 +12,11 @@ const MenuType_1 = require("../types/MenuType");
|
|
|
12
12
|
const I18nProvider_1 = require("./I18nProvider");
|
|
13
13
|
const ThemeProvider_1 = require("./ThemeProvider");
|
|
14
14
|
const MenuContext = (0, react_1.createContext)(undefined);
|
|
15
|
-
const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
15
|
+
const MenuProvider = ({ children, menuConfigs = [], enableBackupCodes = true }) => {
|
|
16
16
|
const { userData: user, isAuthenticated, mnemonic, clearMnemonic, wallet, clearWallet } = (0, AuthProvider_1.useAuth)();
|
|
17
17
|
const registeredMenuOptions = (0, react_1.useRef)(new Set());
|
|
18
18
|
const [registeredOptions, setRegisteredOptions] = (0, react_1.useState)(new Map());
|
|
19
|
-
const {
|
|
19
|
+
const { tComponent } = (0, I18nProvider_1.useI18n)();
|
|
20
20
|
const { mode, toggleColorMode } = (0, ThemeProvider_1.useTheme)();
|
|
21
21
|
const registerMenuOption = (0, react_1.useCallback)((option) => {
|
|
22
22
|
const unregister = () => {
|
|
@@ -47,7 +47,7 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
47
47
|
const baseOptions = [
|
|
48
48
|
{
|
|
49
49
|
id: 'dashboard',
|
|
50
|
-
label:
|
|
50
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_Dashboard),
|
|
51
51
|
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Dashboard, {}),
|
|
52
52
|
link: '/dashboard',
|
|
53
53
|
requiresAuth: true,
|
|
@@ -64,7 +64,7 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
id: 'logout',
|
|
67
|
-
label:
|
|
67
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.LogoutButton),
|
|
68
68
|
icon: (0, jsx_runtime_1.jsx)(icons_material_1.ExitToApp, {}),
|
|
69
69
|
link: '/logout',
|
|
70
70
|
requiresAuth: true,
|
|
@@ -73,7 +73,7 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
id: 'login',
|
|
76
|
-
label:
|
|
76
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Login_LoginButton),
|
|
77
77
|
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Login, {}),
|
|
78
78
|
link: '/login',
|
|
79
79
|
requiresAuth: false,
|
|
@@ -82,7 +82,7 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
id: 'register',
|
|
85
|
-
label:
|
|
85
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.RegisterButton),
|
|
86
86
|
icon: (0, jsx_runtime_1.jsx)(icons_material_1.PersonAdd, {}),
|
|
87
87
|
link: '/register',
|
|
88
88
|
requiresAuth: false,
|
|
@@ -91,7 +91,7 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
id: 'forgot-password',
|
|
94
|
-
label:
|
|
94
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.ForgotPassword_Title),
|
|
95
95
|
icon: (0, jsx_runtime_1.jsx)(icons_material_1.LockOpen, {}),
|
|
96
96
|
link: '/forgot-password',
|
|
97
97
|
requiresAuth: false,
|
|
@@ -100,31 +100,31 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
id: 'change-password',
|
|
103
|
-
label:
|
|
103
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ChangePassword),
|
|
104
104
|
icon: (0, jsx_runtime_1.jsx)(icons_material_1.LockReset, {}),
|
|
105
105
|
link: '/change-password',
|
|
106
106
|
requiresAuth: true,
|
|
107
107
|
includeOnMenus: [MenuType_1.MenuTypes.UserMenu, MenuType_1.MenuTypes.SideMenu],
|
|
108
108
|
index: index++,
|
|
109
109
|
},
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
110
|
+
...(enableBackupCodes ? [{
|
|
111
|
+
id: 'backup-code',
|
|
112
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.BackupCodeRecovery_Title),
|
|
113
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Key, {}),
|
|
114
|
+
link: '/backup-code',
|
|
115
|
+
requiresAuth: false,
|
|
116
|
+
includeOnMenus: [MenuType_1.MenuTypes.UserMenu, MenuType_1.MenuTypes.SideMenu],
|
|
117
|
+
index: index++,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: 'backup-codes',
|
|
121
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.BackupCodeRecovery_GenerateNewCodes),
|
|
122
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Autorenew, {}),
|
|
123
|
+
link: '/backup-codes',
|
|
124
|
+
requiresAuth: true,
|
|
125
|
+
includeOnMenus: [MenuType_1.MenuTypes.UserMenu, MenuType_1.MenuTypes.SideMenu],
|
|
126
|
+
index: index++,
|
|
127
|
+
}] : []),
|
|
128
128
|
{
|
|
129
129
|
id: 'divider',
|
|
130
130
|
label: '',
|
|
@@ -135,7 +135,7 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
id: 'clear-mnemonic',
|
|
138
|
-
label:
|
|
138
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ClearMnemonic),
|
|
139
139
|
action: clearMnemonic,
|
|
140
140
|
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Key, {}),
|
|
141
141
|
requiresAuth: true,
|
|
@@ -145,7 +145,7 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
147
|
id: 'clear-wallet',
|
|
148
|
-
label:
|
|
148
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ClearWallet),
|
|
149
149
|
action: clearWallet,
|
|
150
150
|
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Key, {}),
|
|
151
151
|
requiresAuth: true,
|
|
@@ -165,18 +165,27 @@ const MenuProvider = ({ children, menuConfigs = [] }) => {
|
|
|
165
165
|
{
|
|
166
166
|
id: 'theme-toggle',
|
|
167
167
|
label: mode === 'dark'
|
|
168
|
-
?
|
|
169
|
-
:
|
|
168
|
+
? tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ThemeToggle_Light)
|
|
169
|
+
: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ThemeToggle_Dark),
|
|
170
170
|
icon: mode === 'dark' ? (0, jsx_runtime_1.jsx)(icons_material_1.Brightness7, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.Brightness4, {}),
|
|
171
171
|
includeOnMenus: [MenuType_1.MenuTypes.SideMenu],
|
|
172
172
|
index: index++,
|
|
173
173
|
requiresAuth: undefined,
|
|
174
174
|
action: toggleColorMode,
|
|
175
175
|
},
|
|
176
|
+
{
|
|
177
|
+
id: 'user-settings',
|
|
178
|
+
label: tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Settings_Title),
|
|
179
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Settings, {}),
|
|
180
|
+
link: '/user-settings',
|
|
181
|
+
requiresAuth: true,
|
|
182
|
+
includeOnMenus: [MenuType_1.MenuTypes.UserMenu, MenuType_1.MenuTypes.SideMenu],
|
|
183
|
+
index: index++,
|
|
184
|
+
}
|
|
176
185
|
];
|
|
177
186
|
const allOptions = [...baseOptions, ...registeredOptions.values()];
|
|
178
187
|
return allOptions.sort((a, b) => a.index - b.index);
|
|
179
|
-
}, [
|
|
188
|
+
}, [tComponent, registeredOptions, user?.roles, mode, toggleColorMode]);
|
|
180
189
|
const getMenuOptions = (0, react_1.useCallback)((menuType, includeDividers) => {
|
|
181
190
|
const MenuFilter = (o) => {
|
|
182
191
|
// Apply the custom filter first
|
package/src/wrappers/index.d.ts
CHANGED
|
@@ -14,15 +14,10 @@ export interface VerifyEmailPageWrapperProps {
|
|
|
14
14
|
export declare const VerifyEmailPageWrapper: FC<VerifyEmailPageWrapperProps>;
|
|
15
15
|
export interface UserSettingsFormWrapperProps {
|
|
16
16
|
baseUrl: string;
|
|
17
|
-
timezones: string[];
|
|
18
17
|
languages: Array<{
|
|
19
18
|
code: string;
|
|
20
19
|
label: string;
|
|
21
20
|
}>;
|
|
22
|
-
currencies: Array<{
|
|
23
|
-
code: string;
|
|
24
|
-
label: string;
|
|
25
|
-
}>;
|
|
26
21
|
}
|
|
27
22
|
export declare const UserSettingsFormWrapper: FC<UserSettingsFormWrapperProps>;
|
|
28
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;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,
|
|
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"}
|
package/src/wrappers/index.js
CHANGED
|
@@ -130,7 +130,7 @@ const VerifyEmailPageWrapper = ({ baseUrl }) => {
|
|
|
130
130
|
return (0, jsx_runtime_1.jsx)(VerifyEmailPage_1.VerifyEmailPage, { token: token, onVerify: handleVerify });
|
|
131
131
|
};
|
|
132
132
|
exports.VerifyEmailPageWrapper = VerifyEmailPageWrapper;
|
|
133
|
-
const UserSettingsFormWrapper = ({ baseUrl,
|
|
133
|
+
const UserSettingsFormWrapper = ({ baseUrl, languages }) => {
|
|
134
134
|
const { userData, setCurrencyCode, setLanguage } = (0, contexts_1.useAuth)();
|
|
135
135
|
const api = (0, services_1.createAuthenticatedApiClient)(baseUrl);
|
|
136
136
|
const handleSubmit = async (values) => {
|
|
@@ -156,6 +156,6 @@ const UserSettingsFormWrapper = ({ baseUrl, timezones, languages, currencies })
|
|
|
156
156
|
darkMode: userData?.darkMode || false,
|
|
157
157
|
directChallenge: userData?.directChallenge || false,
|
|
158
158
|
};
|
|
159
|
-
return ((0, jsx_runtime_1.jsx)(UserSettingsForm_1.UserSettingsForm, { initialValues: initialValues, onSubmit: handleSubmit,
|
|
159
|
+
return ((0, jsx_runtime_1.jsx)(UserSettingsForm_1.UserSettingsForm, { initialValues: initialValues, onSubmit: handleSubmit, languages: languages }));
|
|
160
160
|
};
|
|
161
161
|
exports.UserSettingsFormWrapper = UserSettingsFormWrapper;
|