@saasquatch/mint-components 1.12.0-5 → 1.12.0-7

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.
Files changed (124) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/mint-components.cjs.js +1 -1
  3. package/dist/cjs/sqm-banking-info-form_16.cjs.entry.js +47 -18
  4. package/dist/cjs/sqm-big-stat_39.cjs.entry.js +33 -6
  5. package/dist/cjs/sqm-code-verification.cjs.entry.js +34 -48
  6. package/dist/cjs/sqm-email-verification.cjs.entry.js +143 -21
  7. package/dist/cjs/{sqm-invoice-table-view-dbba9bb4.js → sqm-invoice-table-view-e530775f.js} +39 -0
  8. package/dist/cjs/sqm-stencilbook.cjs.entry.js +19 -1
  9. package/dist/cjs/sqm-widget-verification-internal.cjs.entry.js +55 -7
  10. package/dist/cjs/sqm-widget-verification.cjs.entry.js +15 -18
  11. package/dist/cjs/useVerificationEmail-35aea294.js +170 -0
  12. package/dist/collection/collection-manifest.json +1 -1
  13. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.js +7 -0
  14. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.js +1 -1
  15. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.js +20 -2
  16. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.js +33 -24
  17. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.js +19 -42
  18. package/dist/collection/components/sqm-widget-verification/sqm-widget-verification-internal.js +56 -7
  19. package/dist/collection/components/sqm-widget-verification/sqm-widget-verification.js +17 -20
  20. package/dist/collection/components/sqm-widget-verification/useVerificationEmail.js +165 -0
  21. package/dist/collection/components/tax-and-cash/BankingForm.stories.js +1 -0
  22. package/dist/collection/components/tax-and-cash/TaxForm.stories.js +38 -0
  23. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form.js +2 -1
  24. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/useBankingInfoForm.js +7 -0
  25. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.js +8 -0
  26. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.js +10 -5
  27. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.js +33 -1
  28. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.js +13 -2
  29. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/data.js +5 -0
  30. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +8 -8
  31. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.js +11 -0
  32. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.js +10 -9
  33. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/useTaxAndCashDashboard.js +2 -1
  34. package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +14 -11
  35. package/dist/esm/{keys-a1496e39.js → keys-db1897ae.js} +1 -1
  36. package/dist/esm/loader.js +1 -1
  37. package/dist/esm/mint-components.js +1 -1
  38. package/dist/esm/sqm-banking-info-form_16.entry.js +48 -19
  39. package/dist/esm/sqm-big-stat_39.entry.js +34 -7
  40. package/dist/esm/sqm-code-verification.entry.js +36 -50
  41. package/dist/esm/sqm-email-verification.entry.js +127 -5
  42. package/dist/esm/{sqm-invoice-table-view-663674f2.js → sqm-invoice-table-view-22bb7240.js} +39 -0
  43. package/dist/esm/sqm-stencilbook.entry.js +19 -1
  44. package/dist/esm/sqm-widget-verification-internal.entry.js +55 -7
  45. package/dist/esm/sqm-widget-verification.entry.js +17 -20
  46. package/dist/esm/useVerificationEmail-02b78bd7.js +168 -0
  47. package/dist/esm-es5/{keys-a1496e39.js → keys-db1897ae.js} +1 -1
  48. package/dist/esm-es5/loader.js +1 -1
  49. package/dist/esm-es5/mint-components.js +1 -1
  50. package/dist/esm-es5/sqm-banking-info-form_16.entry.js +1 -1
  51. package/dist/esm-es5/sqm-big-stat_39.entry.js +1 -1
  52. package/dist/esm-es5/sqm-code-verification.entry.js +1 -1
  53. package/dist/esm-es5/sqm-email-verification.entry.js +1 -1
  54. package/dist/esm-es5/sqm-invoice-table-view-22bb7240.js +1 -0
  55. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  56. package/dist/esm-es5/sqm-widget-verification-internal.entry.js +1 -1
  57. package/dist/esm-es5/sqm-widget-verification.entry.js +1 -1
  58. package/dist/esm-es5/useVerificationEmail-02b78bd7.js +1 -0
  59. package/dist/mint-components/mint-components.esm.js +1 -1
  60. package/dist/mint-components/{p-53d9df5e.entry.js → p-0aebee07.entry.js} +8 -3
  61. package/dist/mint-components/p-0e2d876d.entry.js +240 -0
  62. package/dist/mint-components/p-116c1809.entry.js +11 -0
  63. package/dist/mint-components/{p-99a09fab.entry.js → p-126a4f24.entry.js} +2 -2
  64. package/dist/mint-components/p-22b7bd75.system.entry.js +1 -0
  65. package/dist/mint-components/{p-d4138847.system.entry.js → p-28450e40.system.entry.js} +1 -1
  66. package/dist/mint-components/p-2b5b2586.system.js +1 -0
  67. package/dist/mint-components/p-39840341.js +1 -0
  68. package/dist/mint-components/p-4a43ffbd.js +1 -0
  69. package/dist/mint-components/p-55fe2ec0.system.entry.js +1 -0
  70. package/dist/mint-components/p-6fb496ac.entry.js +12 -0
  71. package/dist/mint-components/p-71b8adf7.system.js +1 -0
  72. package/dist/mint-components/p-7666cd3d.js +48 -0
  73. package/dist/mint-components/p-87bf9880.entry.js +25 -0
  74. package/dist/mint-components/p-8a7d2170.system.entry.js +1 -0
  75. package/dist/mint-components/p-a5eedbe2.system.entry.js +1 -0
  76. package/dist/mint-components/p-a60ec391.system.entry.js +1 -0
  77. package/dist/mint-components/p-b2a99637.system.js +1 -0
  78. package/dist/mint-components/p-ca423ca2.system.entry.js +1 -0
  79. package/dist/mint-components/p-e05ff098.system.js +1 -1
  80. package/dist/mint-components/p-e373b78a.entry.js +1 -0
  81. package/dist/types/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.d.ts +1 -0
  82. package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.d.ts +1 -0
  83. package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.d.ts +4 -0
  84. package/dist/types/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.d.ts +2 -1
  85. package/dist/types/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.d.ts +0 -6
  86. package/dist/types/components/sqm-widget-verification/useVerificationEmail.d.ts +14 -0
  87. package/dist/types/components/tax-and-cash/TaxForm.stories.d.ts +1 -0
  88. package/dist/types/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.d.ts +1 -0
  89. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.d.ts +1 -0
  90. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.d.ts +9 -0
  91. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.d.ts +4 -0
  92. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.d.ts +9 -0
  93. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/data.d.ts +5 -0
  94. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.d.ts +2 -2
  95. package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.d.ts +3 -0
  96. package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.d.ts +2 -2
  97. package/dist/types/components.d.ts +68 -52
  98. package/docs/docs.docx +0 -0
  99. package/docs/raisins.json +1 -1
  100. package/grapesjs/grapesjs.js +1 -1
  101. package/package.json +1 -1
  102. package/dist/cjs/useEmailVerification-33465f36.js +0 -155
  103. package/dist/collection/components/sqm-widget-verification/useWidgetVerification.js +0 -3
  104. package/dist/esm/useEmailVerification-8f2dc2bd.js +0 -152
  105. package/dist/esm-es5/sqm-invoice-table-view-663674f2.js +0 -1
  106. package/dist/esm-es5/useEmailVerification-8f2dc2bd.js +0 -1
  107. package/dist/mint-components/p-158e9d3a.entry.js +0 -1
  108. package/dist/mint-components/p-20c5ce3d.system.entry.js +0 -1
  109. package/dist/mint-components/p-219be817.system.entry.js +0 -1
  110. package/dist/mint-components/p-2c03096f.system.entry.js +0 -1
  111. package/dist/mint-components/p-4c9b6fbe.system.js +0 -1
  112. package/dist/mint-components/p-4d060f15.js +0 -1
  113. package/dist/mint-components/p-5810e318.entry.js +0 -1
  114. package/dist/mint-components/p-6029c42d.entry.js +0 -8
  115. package/dist/mint-components/p-6cae44d7.js +0 -1
  116. package/dist/mint-components/p-78c1bd77.system.js +0 -1
  117. package/dist/mint-components/p-80a32fe9.system.entry.js +0 -1
  118. package/dist/mint-components/p-a2baff3e.entry.js +0 -1
  119. package/dist/mint-components/p-b52b7e60.system.entry.js +0 -1
  120. package/dist/mint-components/p-f4dff47a.system.entry.js +0 -1
  121. package/dist/mint-components/p-faf019cf.system.js +0 -1
  122. package/dist/mint-components/p-fcb224ab.js +0 -25
  123. package/dist/mint-components/p-ff77d11f.entry.js +0 -240
  124. package/dist/types/components/sqm-widget-verification/useWidgetVerification.d.ts +0 -1
@@ -1,10 +1,23 @@
1
1
  import { r as registerInstance, h as h$1 } from './index-17b4da69.js';
2
- import { j as h } from './stencil-hooks.module-3c7f7c90.js';
3
- import { i as isDemo, F as Fn, K } from './index.module-c0eb7dc2.js';
2
+ import { j as h, f as useState, d as useEffect } from './stencil-hooks.module-3c7f7c90.js';
3
+ import { i as isDemo, F as Fn, S as Sn, K, e as an } from './index.module-c0eb7dc2.js';
4
+ import { d as dist } from './index-0c7b14c5.js';
4
5
  import { g as getProps } from './utils-334c1e34.js';
5
- import { S as SHOW_CODE_NAMESPACE, b as VERIFICATION_EMAIL_NAMESPACE } from './keys-a1496e39.js';
6
+ import { S as SHOW_CODE_NAMESPACE, a as VERIFICATION_EMAIL_NAMESPACE, V as VERIFICATION_PARENT_NAMESPACE } from './keys-db1897ae.js';
6
7
  import { e as extractProps } from './extractProps-ae1afbb3.js';
7
8
 
9
+ const USER_LOOKUP = dist.gql `
10
+ query viewer {
11
+ viewer {
12
+ ... on User {
13
+ id
14
+ accountId
15
+ email
16
+ emailVerified
17
+ }
18
+ }
19
+ }
20
+ `;
8
21
  function useWidgetVerificationInternal() {
9
22
  const userIdentity = K();
10
23
  const [showCode, setShowCode] = Fn({
@@ -15,7 +28,32 @@ function useWidgetVerificationInternal() {
15
28
  namespace: VERIFICATION_EMAIL_NAMESPACE,
16
29
  initialValue: userIdentity === null || userIdentity === void 0 ? void 0 : userIdentity.email,
17
30
  });
18
- return { showCode };
31
+ const setContext = Sn(VERIFICATION_PARENT_NAMESPACE);
32
+ const [loading, setLoading] = useState(true);
33
+ const [fetch] = an(USER_LOOKUP);
34
+ useEffect(() => {
35
+ const checkUser = async () => {
36
+ var _a;
37
+ try {
38
+ const res = await fetch({});
39
+ if (!res || res instanceof Error)
40
+ throw new Error();
41
+ if ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified)
42
+ setContext(true);
43
+ }
44
+ catch (e) {
45
+ console.error("Could not fetch user information", e);
46
+ }
47
+ finally {
48
+ setLoading(false);
49
+ }
50
+ };
51
+ checkUser();
52
+ }, []);
53
+ const onVerification = () => {
54
+ setContext(true);
55
+ };
56
+ return { showCode, onVerification, loading };
19
57
  }
20
58
  const WidgetVerificationInternal = class {
21
59
  constructor(hostRef) {
@@ -28,11 +66,17 @@ const WidgetVerificationInternal = class {
28
66
  return extractProps(props, prefix);
29
67
  }
30
68
  render() {
31
- const { showCode } = isDemo()
69
+ const { showCode, onVerification, loading } = isDemo()
32
70
  ? useDemoWidgetVerificationInternal()
33
71
  : useWidgetVerificationInternal();
72
+ // TODO: Shoelace spinner is throwing errors
73
+ if (loading)
74
+ return h$1("div", null);
75
+ // if (loading) {
76
+ // return <sl-spinner style="font-size: 2rem;"></sl-spinner>;
77
+ // }
34
78
  if (showCode) {
35
- return (h$1("sqm-code-verification", Object.assign({}, this.getStepTextProps("codeStep_"))));
79
+ return (h$1("sqm-code-verification", Object.assign({ onVerification: onVerification }, this.getStepTextProps("codeStep_"))));
36
80
  }
37
81
  return (h$1("sqm-email-verification", Object.assign({}, this.getStepTextProps("emailStep_"))));
38
82
  }
@@ -46,7 +90,11 @@ function useDemoWidgetVerificationInternal() {
46
90
  namespace: VERIFICATION_EMAIL_NAMESPACE,
47
91
  initialValue: undefined,
48
92
  });
49
- return { showCode };
93
+ const setContext = Sn(VERIFICATION_PARENT_NAMESPACE);
94
+ const onVerification = () => {
95
+ setContext(true);
96
+ };
97
+ return { showCode, onVerification, loading: false };
50
98
  }
51
99
 
52
100
  export { WidgetVerificationInternal as sqm_widget_verification_internal };
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, h as h$1, c as Host } from './index-17b4da69.js';
2
- import { b as browser, j as h, f as useState, d as useEffect, l } from './stencil-hooks.module-3c7f7c90.js';
2
+ import { b as browser, j as h, f as useState, d as useEffect } from './stencil-hooks.module-3c7f7c90.js';
3
3
  import { F as Fn, a as useCallback } from './index.module-c0eb7dc2.js';
4
4
  import { g as getProps } from './utils-334c1e34.js';
5
- import { V as VERIFICATION_EVENT_KEY, a as VERIFICATION_PARENT_NAMESPACE } from './keys-a1496e39.js';
5
+ import { V as VERIFICATION_PARENT_NAMESPACE } from './keys-db1897ae.js';
6
6
 
7
7
  const debug = browser("sq:widget-verification");
8
8
  function useTemplateChildren({ parent, callback }) {
@@ -125,15 +125,12 @@ const WidgetVerification = class {
125
125
  render() {
126
126
  const [context, setContext] = Fn({
127
127
  namespace: VERIFICATION_PARENT_NAMESPACE,
128
- initialValue: undefined,
128
+ initialValue: false,
129
129
  });
130
- const authToken = context === null || context === void 0 ? void 0 : context.token;
131
130
  const [container, setContainer] = useState(undefined);
132
131
  const [slot, setSlot] = useState(undefined);
133
- if (!authToken)
134
- debug("No user identity available");
135
132
  const updateTemplates = useCallback(() => {
136
- const isAuth = !!authToken;
133
+ const isAuth = context;
137
134
  const templates = slot.querySelectorAll(`template`);
138
135
  const template = Array.from(templates).find((t) => t.slot === (isAuth ? "verified" : "not-verified"));
139
136
  if (template) {
@@ -181,7 +178,7 @@ const WidgetVerification = class {
181
178
  target.style.height = "25px";
182
179
  });
183
180
  }
184
- }, [container, slot, authToken]);
181
+ }, [container, slot, context]);
185
182
  useEffect(() => {
186
183
  if (!container || !slot) {
187
184
  debug("DOM not ready:");
@@ -190,18 +187,18 @@ const WidgetVerification = class {
190
187
  // Run on first render
191
188
  updateTemplates();
192
189
  return useTemplateChildren({ parent: slot, callback: updateTemplates });
193
- }, [slot, container, authToken]);
194
- useEffect(() => {
195
- const host = l();
196
- const callback = (e) => {
197
- e.stopPropagation();
198
- setContext({ token: e.detail.token });
199
- };
200
- host.addEventListener(VERIFICATION_EVENT_KEY, callback);
201
- return () => {
202
- host.removeEventListener(VERIFICATION_EVENT_KEY, callback);
203
- };
204
- }, []);
190
+ }, [slot, container, context]);
191
+ // useEffect(() => {
192
+ // const host = useHost();
193
+ // const callback = (e: CustomEvent) => {
194
+ // e.stopPropagation();
195
+ // setContext({ token: e.detail.token });
196
+ // };
197
+ // host.addEventListener(VERIFICATION_EVENT_KEY, callback);
198
+ // return () => {
199
+ // host.removeEventListener(VERIFICATION_EVENT_KEY, callback);
200
+ // };
201
+ // }, []);
205
202
  return (h$1(Host, null, h$1("div", { ref: setSlot, style: { display: "contents" } }, h$1("template", { slot: "not-verified" }, h$1("sqm-widget-verification-internal", Object.assign({}, getProps(this)))), h$1("slot", { name: "not-verified" }), h$1("slot", { name: "verified" })), h$1("div", { ref: setContainer }, h$1("slot", { name: "shown" }))));
206
203
  }
207
204
  };
@@ -0,0 +1,168 @@
1
+ import { f as useState, d as useEffect } from './stencil-hooks.module-3c7f7c90.js';
2
+ import { K, e as an, b as xe } from './index.module-c0eb7dc2.js';
3
+ import { d as dist } from './index-0c7b14c5.js';
4
+
5
+ const UserLookupQuery = dist.gql `
6
+ query userLookup {
7
+ viewer {
8
+ ... on User {
9
+ id
10
+ accountId
11
+ email
12
+ impactConnection {
13
+ user {
14
+ id
15
+ email
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
21
+ `;
22
+ const ParticipantVerificationEmailMutation = dist.gql `
23
+ mutation requestUserEmailVerification($user: UserIdInput!) {
24
+ requestUserEmailVerification(user: $user) {
25
+ success
26
+ }
27
+ }
28
+ `;
29
+ const ImpactVerificationEmailMutation = dist.gql `
30
+ mutation requestImpactPublisherEmail2FA($user: UserIdInput!) {
31
+ requestImpactPublisherEmail2FA(user: $user) {
32
+ success
33
+ }
34
+ }
35
+ `;
36
+ const VerifyUserEmailMutation = dist.gql `
37
+ mutation verifyUserEmail($user: UserIdInput!, $code: String!) {
38
+ verifyUserEmail(user: $user, code: $code) {
39
+ id
40
+ accountId
41
+ email
42
+ emailVerified
43
+ }
44
+ }
45
+ `;
46
+ const SubmitImpactCodeMutation = dist.gql `
47
+ mutation submitImpactPublisherEmail2FACode(
48
+ $user: UserIdInput!
49
+ $code: String!
50
+ ) {
51
+ submitImpactPublisherEmail2FACode(user: $user, code: $code) {
52
+ verifiedEmail
53
+ accessKey
54
+ }
55
+ }
56
+ `;
57
+ // ! It's important when using this hook to ensure initialisation
58
+ // ! is done before calling any mutations
59
+ function useVerificationEmail() {
60
+ const userIdentity = K();
61
+ const [hasEmails, setHasEmails] = useState({
62
+ participant: false,
63
+ impact: false,
64
+ });
65
+ const [fetch] = an(UserLookupQuery);
66
+ // Send mutations
67
+ const [sendParticipantEmail, { loading: participantEmailLoading, errors: participantEmailErrors },] = xe(ParticipantVerificationEmailMutation);
68
+ const [sendImpactEmail, { loading: impactEmailLoading, errors: impactEmailErrors },] = xe(ImpactVerificationEmailMutation);
69
+ const sendLoading = participantEmailLoading || impactEmailLoading;
70
+ const sendErrors = participantEmailErrors || impactEmailErrors;
71
+ // Verification mutations
72
+ const [verifyUserEmail, { loading: verifyMutationLoading, errors: verifyMutationErrors },] = xe(VerifyUserEmailMutation);
73
+ const [submitImpactCode, { loading: submitImpactCodeLoading, errors: submitImpactCodeErrors },] = xe(SubmitImpactCodeMutation);
74
+ const verifyLoading = verifyMutationLoading || submitImpactCodeLoading;
75
+ const verifyErrors = verifyMutationErrors || submitImpactCodeErrors;
76
+ const [initialized, setInitialized] = useState(false);
77
+ const initialise = async () => {
78
+ var _a, _b, _c, _d;
79
+ try {
80
+ const lookup = await fetch({});
81
+ if (!lookup || lookup instanceof Error)
82
+ throw new Error();
83
+ setHasEmails({
84
+ participant: !!((_a = lookup === null || lookup === void 0 ? void 0 : lookup.viewer) === null || _a === void 0 ? void 0 : _a.email),
85
+ impact: !!((_d = (_c = (_b = lookup === null || lookup === void 0 ? void 0 : lookup.viewer) === null || _b === void 0 ? void 0 : _b.impactConnection) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.email),
86
+ });
87
+ setInitialized(true);
88
+ }
89
+ catch (e) {
90
+ console.error("Could not initialise verification", e);
91
+ }
92
+ };
93
+ const sendVerificationEmail = async () => {
94
+ let result = null;
95
+ if (!initialized)
96
+ return result;
97
+ if (!hasEmails.participant && !hasEmails.impact)
98
+ return result;
99
+ try {
100
+ const request = hasEmails.impact ? sendImpactEmail : sendParticipantEmail;
101
+ const res = await request({
102
+ user: {
103
+ id: userIdentity.id,
104
+ accountId: userIdentity.accountId,
105
+ },
106
+ });
107
+ if (res instanceof Error || !res)
108
+ throw new Error();
109
+ result = hasEmails.impact
110
+ ? res.requestImpactPublisherEmail2FA
111
+ : res.requestUserEmailVerification;
112
+ }
113
+ catch (e) {
114
+ console.error("Could not send verification email", e);
115
+ }
116
+ finally {
117
+ return result;
118
+ }
119
+ };
120
+ const verifyVerificationEmail = async (code) => {
121
+ var _a;
122
+ let result = null;
123
+ if (!initialized)
124
+ return result;
125
+ if (!hasEmails.participant && !hasEmails.impact)
126
+ return result;
127
+ try {
128
+ const request = hasEmails.impact ? submitImpactCode : verifyUserEmail;
129
+ const res = await request({
130
+ user: {
131
+ id: userIdentity.id,
132
+ accountId: userIdentity.accountId,
133
+ },
134
+ code,
135
+ });
136
+ if (res instanceof Error || !res)
137
+ throw new Error();
138
+ result = {
139
+ success: true,
140
+ accessKey: hasEmails.impact
141
+ ? (_a = res.submitImpactPublisherEmail2FACode) === null || _a === void 0 ? void 0 : _a.accessKey : undefined,
142
+ };
143
+ }
144
+ catch (e) {
145
+ console.error("Could not verify email", e);
146
+ }
147
+ finally {
148
+ return result;
149
+ }
150
+ };
151
+ useEffect(() => {
152
+ if (!initialized)
153
+ initialise();
154
+ }, []);
155
+ return {
156
+ initialized,
157
+ send: [
158
+ sendVerificationEmail,
159
+ { loading: sendLoading, errors: sendErrors },
160
+ ],
161
+ verify: [
162
+ verifyVerificationEmail,
163
+ { loading: verifyLoading, errors: verifyErrors },
164
+ ],
165
+ };
166
+ }
167
+
168
+ export { useVerificationEmail as u };
@@ -1 +1 @@
1
- var SHOW_CODE_NAMESPACE="sq:code-verification";var VERIFICATION_EMAIL_NAMESPACE="sq:verification-email";var VERIFICATION_PARENT_NAMESPACE="sq:verification-context";var VERIFICATION_EVENT_KEY="sq:code-verified";export{SHOW_CODE_NAMESPACE as S,VERIFICATION_EVENT_KEY as V,VERIFICATION_PARENT_NAMESPACE as a,VERIFICATION_EMAIL_NAMESPACE as b};
1
+ var SHOW_CODE_NAMESPACE="sq:code-verification";var VERIFICATION_EMAIL_NAMESPACE="sq:verification-email";var VERIFICATION_PARENT_NAMESPACE="sq:verification-context";var VERIFICATION_EVENT_KEY="sq:code-verified";export{SHOW_CODE_NAMESPACE as S,VERIFICATION_PARENT_NAMESPACE as V,VERIFICATION_EMAIL_NAMESPACE as a,VERIFICATION_EVENT_KEY as b};