@digitaldefiance/express-suite-react-components 4.26.12 → 4.26.14

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/express-suite-react-components",
3
- "version": "4.26.12",
3
+ "version": "4.26.14",
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.6",
35
+ "@digitaldefiance/suite-core-lib": "4.26.8",
36
36
  "@emotion/react": "^11.14.0",
37
37
  "@emotion/styled": "^11.14.0",
38
38
  "@mui/icons-material": "^7.0.2",
@@ -11,6 +11,7 @@ export interface VerifyEmailPageProps {
11
11
  success?: string;
12
12
  failed?: string;
13
13
  noToken?: string;
14
+ checkYourEmail?: string;
14
15
  proceedToLogin?: string;
15
16
  contactSupport?: string;
16
17
  requestNewEmail?: string;
@@ -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,EAAgC,MAAM,OAAO,CAAC;AAGzD,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,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,CAoJpD,CAAC;AAEF,eAAe,eAAe,CAAC"}
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
- const verifyEmail = async (verificationToken) => {
34
- try {
35
- const result = await onVerify(verificationToken);
36
- if (result.success) {
37
- setMessage(result.message || translatedLabels.success);
38
- setVerificationStatus('success');
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
- else {
41
- setMessage(result.message || translatedLabels.failed);
57
+ catch {
58
+ setMessage(translatedLabels.failed);
42
59
  setVerificationStatus('error');
43
60
  }
44
- }
45
- catch {
46
- setMessage(translatedLabels.failed);
47
- setVerificationStatus('error');
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
- setMessage(translatedLabels.noToken);
59
- setVerificationStatus('error');
70
+ setVerificationStatus('info');
60
71
  }
61
- }, [token, onVerify, translatedLabels]);
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.jsxs)(material_1.Box, { sx: { width: '100%', mt: 2 }, 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 }), "."] }))] }))] }) }));
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,EAAE,MAAM,OAAO,CAAC;AAC3B,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"}
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;