@digitaldefiance/express-suite-react-components 4.26.12 → 4.26.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/components/VerifyEmailPage.d.ts +1 -0
- package/src/components/VerifyEmailPage.d.ts.map +1 -1
- package/src/components/VerifyEmailPage.js +34 -23
- package/src/hooks/useEmailVerification.js +3 -3
- package/src/wrappers/VerifyEmailPageWrapper.d.ts.map +1 -1
- package/src/wrappers/VerifyEmailPageWrapper.js +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "4.26.
|
|
3
|
+
"version": "4.26.13",
|
|
4
4
|
"homepage": "https://github.com/Digital-Defiance/react-components",
|
|
5
5
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@digitaldefiance/i18n-lib": "4.7.3",
|
|
35
|
-
"@digitaldefiance/suite-core-lib": "4.26.
|
|
35
|
+
"@digitaldefiance/suite-core-lib": "4.26.7",
|
|
36
36
|
"@emotion/react": "^11.14.0",
|
|
37
37
|
"@emotion/styled": "^11.14.0",
|
|
38
38
|
"@mui/icons-material": "^7.0.2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerifyEmailPage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/VerifyEmailPage.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"VerifyEmailPage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/VerifyEmailPage.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,EAAE,EAAwC,MAAM,OAAO,CAAC;AAGjE,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAsLpD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -21,6 +21,8 @@ const VerifyEmailPage = ({ token, onVerify, labels = {}, loginLink = '/login', r
|
|
|
21
21
|
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.EmailVerification_Failed),
|
|
22
22
|
noToken: labels.noToken ||
|
|
23
23
|
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.NoVerificationTokenProvided),
|
|
24
|
+
checkYourEmail: labels.checkYourEmail ||
|
|
25
|
+
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Registration_CheckYourEmail),
|
|
24
26
|
proceedToLogin: labels.proceedToLogin ||
|
|
25
27
|
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.ProceedToLogin),
|
|
26
28
|
contactSupport: labels.contactSupport ||
|
|
@@ -29,42 +31,51 @@ const VerifyEmailPage = ({ token, onVerify, labels = {}, loginLink = '/login', r
|
|
|
29
31
|
tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.RequestNewVerificationEmail),
|
|
30
32
|
};
|
|
31
33
|
}, [labels, tComponent]);
|
|
34
|
+
// Use a ref to track whether verification has already been attempted,
|
|
35
|
+
// preventing infinite re-render loops from unstable onVerify references.
|
|
36
|
+
const hasVerified = (0, react_1.useRef)(false);
|
|
37
|
+
// Stable reference to onVerify to avoid re-triggering the effect
|
|
38
|
+
const onVerifyRef = (0, react_1.useRef)(onVerify);
|
|
39
|
+
onVerifyRef.current = onVerify;
|
|
32
40
|
(0, react_1.useEffect)(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
if (hasVerified.current)
|
|
42
|
+
return;
|
|
43
|
+
if (token) {
|
|
44
|
+
hasVerified.current = true;
|
|
45
|
+
const verifyEmail = async () => {
|
|
46
|
+
try {
|
|
47
|
+
const result = await onVerifyRef.current(token);
|
|
48
|
+
if (result.success) {
|
|
49
|
+
setMessage(result.message || translatedLabels.success);
|
|
50
|
+
setVerificationStatus('success');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
setMessage(result.message || translatedLabels.failed);
|
|
54
|
+
setVerificationStatus('error');
|
|
55
|
+
}
|
|
39
56
|
}
|
|
40
|
-
|
|
41
|
-
setMessage(
|
|
57
|
+
catch {
|
|
58
|
+
setMessage(translatedLabels.failed);
|
|
42
59
|
setVerificationStatus('error');
|
|
43
60
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
finally {
|
|
50
|
-
setLoading(false);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
if (token) {
|
|
54
|
-
verifyEmail(token);
|
|
61
|
+
finally {
|
|
62
|
+
setLoading(false);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
verifyEmail();
|
|
55
66
|
}
|
|
56
67
|
else {
|
|
68
|
+
hasVerified.current = true;
|
|
57
69
|
setLoading(false);
|
|
58
|
-
|
|
59
|
-
setVerificationStatus('error');
|
|
70
|
+
setVerificationStatus('info');
|
|
60
71
|
}
|
|
61
|
-
}, [token,
|
|
72
|
+
}, [token, translatedLabels]);
|
|
62
73
|
return ((0, jsx_runtime_1.jsx)(material_1.Container, { maxWidth: "sm", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
63
74
|
mt: 8,
|
|
64
75
|
display: 'flex',
|
|
65
76
|
flexDirection: 'column',
|
|
66
77
|
alignItems: 'center',
|
|
67
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: translatedLabels.title }), loading ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, {})) : ((0, jsx_runtime_1.
|
|
78
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", component: "h1", gutterBottom: true, children: translatedLabels.title }), loading ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: '100%', mt: 2 }, children: verificationStatus === 'info' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mb: 2 }, children: translatedLabels.checkYourEmail }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body1", children: [translatedLabels.contactSupport, ' ', (0, jsx_runtime_1.jsx)(material_1.Link, { href: resendLink, color: "primary", children: translatedLabels.requestNewEmail }), "."] })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Alert, { severity: verificationStatus === 'success' ? 'success' : 'error', sx: { mb: 2 }, children: message }), verificationStatus === 'success' && ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", component: material_1.Link, href: loginLink, fullWidth: true, children: translatedLabels.proceedToLogin })), verificationStatus === 'error' && ((0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body1", children: [translatedLabels.contactSupport, ' ', (0, jsx_runtime_1.jsx)(material_1.Link, { href: resendLink, color: "primary", children: translatedLabels.requestNewEmail }), "."] }))] })) }))] }) }));
|
|
68
79
|
};
|
|
69
80
|
exports.VerifyEmailPage = VerifyEmailPage;
|
|
70
81
|
exports.default = exports.VerifyEmailPage;
|
|
@@ -10,11 +10,11 @@ const useEmailVerification = () => {
|
|
|
10
10
|
const api = (0, react_1.useMemo)(() => (0, services_1.createAuthenticatedApiClient)(baseUrl), [baseUrl]);
|
|
11
11
|
const [isVerifying, setIsVerifying] = (0, react_1.useState)(false);
|
|
12
12
|
const [error, setError] = (0, react_1.useState)(null);
|
|
13
|
-
const verifyEmail = async (verificationToken) => {
|
|
13
|
+
const verifyEmail = (0, react_1.useCallback)(async (verificationToken) => {
|
|
14
14
|
setIsVerifying(true);
|
|
15
15
|
setError(null);
|
|
16
16
|
try {
|
|
17
|
-
const result = await api.post('/verify-email', {
|
|
17
|
+
const result = await api.post('/user/verify-email', {
|
|
18
18
|
token: verificationToken,
|
|
19
19
|
});
|
|
20
20
|
return { success: true, message: result.data.message };
|
|
@@ -30,7 +30,7 @@ const useEmailVerification = () => {
|
|
|
30
30
|
finally {
|
|
31
31
|
setIsVerifying(false);
|
|
32
32
|
}
|
|
33
|
-
};
|
|
33
|
+
}, [api]);
|
|
34
34
|
return {
|
|
35
35
|
isVerifying,
|
|
36
36
|
error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerifyEmailPageWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/VerifyEmailPageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"VerifyEmailPageWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/VerifyEmailPageWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,MAAM,WAAW,2BAA2B;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAiBlE,CAAC"}
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VerifyEmailPageWrapper = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const VerifyEmailPage_1 = require("../components/VerifyEmailPage");
|
|
6
7
|
const hooks_1 = require("../hooks");
|
|
7
8
|
const VerifyEmailPageWrapper = ({ onSuccess, componentProps = {}, }) => {
|
|
8
9
|
const searchParams = new URLSearchParams(window.location.search);
|
|
9
10
|
const token = searchParams.get('token');
|
|
10
11
|
const { verifyEmail } = (0, hooks_1.useEmailVerification)();
|
|
11
|
-
const handleVerify = async (verificationToken) => {
|
|
12
|
+
const handleVerify = (0, react_1.useCallback)(async (verificationToken) => {
|
|
12
13
|
const result = await verifyEmail(verificationToken);
|
|
13
14
|
if (result.success && onSuccess) {
|
|
14
15
|
onSuccess();
|
|
15
16
|
}
|
|
16
17
|
return result;
|
|
17
|
-
};
|
|
18
|
+
}, [verifyEmail, onSuccess]);
|
|
18
19
|
return (0, jsx_runtime_1.jsx)(VerifyEmailPage_1.VerifyEmailPage, { token: token, onVerify: handleVerify, ...componentProps });
|
|
19
20
|
};
|
|
20
21
|
exports.VerifyEmailPageWrapper = VerifyEmailPageWrapper;
|