@saasquatch/mint-components 1.12.0-4 → 1.12.0-6

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 (123) 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 +22 -4
  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 +53 -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 +55 -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 +8 -3
  27. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.js +11 -1
  28. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.js +9 -1
  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 +22 -4
  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 +53 -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-116c1809.entry.js +11 -0
  62. package/dist/mint-components/{p-99a09fab.entry.js → p-126a4f24.entry.js} +2 -2
  63. package/dist/mint-components/{p-d4138847.system.entry.js → p-28450e40.system.entry.js} +1 -1
  64. package/dist/mint-components/p-2b5b2586.system.js +1 -0
  65. package/dist/mint-components/p-39840341.js +1 -0
  66. package/dist/mint-components/p-4606b096.entry.js +12 -0
  67. package/dist/mint-components/p-46a5718f.system.entry.js +1 -0
  68. package/dist/mint-components/{p-ff77d11f.entry.js → p-4986a616.entry.js} +10 -10
  69. package/dist/mint-components/p-4a43ffbd.js +1 -0
  70. package/dist/mint-components/p-696e634f.system.entry.js +1 -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 +5 -0
  91. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.d.ts +5 -0
  92. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.d.ts +5 -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 +60 -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/types/components/sqm-widget-verification/useWidgetVerification.d.ts +0 -1
@@ -1,9 +1,23 @@
1
- import { isDemo, useParentState, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
- import { withHooks } from "@saasquatch/stencil-hooks";
1
+ import { isDemo, useLazyQuery, useParentState, useSetParent, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
+ import { useState, withHooks } from "@saasquatch/stencil-hooks";
3
3
  import { Component, h, Prop } from "@stencil/core";
4
- import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE } from "./keys";
4
+ import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE, VERIFICATION_PARENT_NAMESPACE, } from "./keys";
5
5
  import { getProps } from "../../utils/utils";
6
6
  import { extractProps } from "../tax-and-cash/sqm-tax-and-cash/extractProps";
7
+ import { gql } from "graphql-request";
8
+ import { useEffect } from "@saasquatch/universal-hooks";
9
+ const USER_LOOKUP = gql `
10
+ query viewer {
11
+ viewer {
12
+ ... on User {
13
+ id
14
+ accountId
15
+ email
16
+ emailVerified
17
+ }
18
+ }
19
+ }
20
+ `;
7
21
  function useWidgetVerificationInternal() {
8
22
  const userIdentity = useUserIdentity();
9
23
  const [showCode, setShowCode] = useParentState({
@@ -14,7 +28,33 @@ function useWidgetVerificationInternal() {
14
28
  namespace: VERIFICATION_EMAIL_NAMESPACE,
15
29
  initialValue: userIdentity === null || userIdentity === void 0 ? void 0 : userIdentity.email,
16
30
  });
17
- return { showCode };
31
+ const setContext = useSetParent(VERIFICATION_PARENT_NAMESPACE);
32
+ const [loading, setLoading] = useState(true);
33
+ const [fetch] = useLazyQuery(USER_LOOKUP);
34
+ useEffect(() => {
35
+ const checkUser = async () => {
36
+ var _a;
37
+ let result = null;
38
+ try {
39
+ const res = await fetch({});
40
+ if (!res || res instanceof Error)
41
+ throw new Error();
42
+ if ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified)
43
+ setContext(true);
44
+ }
45
+ catch (e) {
46
+ console.error("Could not fetch user information", e);
47
+ }
48
+ finally {
49
+ setLoading(false);
50
+ }
51
+ };
52
+ checkUser();
53
+ }, []);
54
+ const onVerification = () => {
55
+ setContext(true);
56
+ };
57
+ return { showCode, onVerification, loading };
18
58
  }
19
59
  export class WidgetVerificationInternal {
20
60
  constructor() {
@@ -26,11 +66,15 @@ export class WidgetVerificationInternal {
26
66
  return extractProps(props, prefix);
27
67
  }
28
68
  render() {
29
- const { showCode } = isDemo()
69
+ const { showCode, onVerification, loading } = isDemo()
30
70
  ? useDemoWidgetVerificationInternal()
31
71
  : useWidgetVerificationInternal();
72
+ if (loading) {
73
+ // TODO: Proper loading state
74
+ return h("div", null, "Loading");
75
+ }
32
76
  if (showCode) {
33
- return (h("sqm-code-verification", Object.assign({}, this.getStepTextProps("codeStep_"))));
77
+ return (h("sqm-code-verification", Object.assign({ onVerification: onVerification }, this.getStepTextProps("codeStep_"))));
34
78
  }
35
79
  return (h("sqm-email-verification", Object.assign({}, this.getStepTextProps("emailStep_"))));
36
80
  }
@@ -286,5 +330,9 @@ function useDemoWidgetVerificationInternal() {
286
330
  namespace: VERIFICATION_EMAIL_NAMESPACE,
287
331
  initialValue: undefined,
288
332
  });
289
- return { showCode };
333
+ const setContext = useSetParent(VERIFICATION_PARENT_NAMESPACE);
334
+ const onVerification = () => {
335
+ setContext(true);
336
+ };
337
+ return { showCode, onVerification, loading: false };
290
338
  }
@@ -1,9 +1,9 @@
1
1
  import { useParentState } from "@saasquatch/component-boilerplate";
2
- import { useHost, withHooks } from "@saasquatch/stencil-hooks";
2
+ import { withHooks } from "@saasquatch/stencil-hooks";
3
3
  import { useCallback, useEffect, useState } from "@saasquatch/universal-hooks";
4
4
  import { Component, h, Host, Prop } from "@stencil/core";
5
5
  import debugFn from "debug";
6
- import { VERIFICATION_EVENT_KEY, VERIFICATION_PARENT_NAMESPACE } from "./keys";
6
+ import { VERIFICATION_PARENT_NAMESPACE } from "./keys";
7
7
  import { getProps } from "../../utils/utils";
8
8
  const debug = debugFn("sq:widget-verification");
9
9
  function useTemplateChildren({ parent, callback }) {
@@ -132,15 +132,12 @@ export class WidgetVerification {
132
132
  render() {
133
133
  const [context, setContext] = useParentState({
134
134
  namespace: VERIFICATION_PARENT_NAMESPACE,
135
- initialValue: undefined,
135
+ initialValue: false,
136
136
  });
137
- const authToken = context === null || context === void 0 ? void 0 : context.token;
138
137
  const [container, setContainer] = useState(undefined);
139
138
  const [slot, setSlot] = useState(undefined);
140
- if (!authToken)
141
- debug("No user identity available");
142
139
  const updateTemplates = useCallback(() => {
143
- const isAuth = !!authToken;
140
+ const isAuth = context;
144
141
  const templates = slot.querySelectorAll(`template`);
145
142
  const template = Array.from(templates).find((t) => t.slot === (isAuth ? "verified" : "not-verified"));
146
143
  if (template) {
@@ -188,7 +185,7 @@ export class WidgetVerification {
188
185
  target.style.height = "25px";
189
186
  });
190
187
  }
191
- }, [container, slot, authToken]);
188
+ }, [container, slot, context]);
192
189
  useEffect(() => {
193
190
  if (!container || !slot) {
194
191
  debug("DOM not ready:");
@@ -197,18 +194,18 @@ export class WidgetVerification {
197
194
  // Run on first render
198
195
  updateTemplates();
199
196
  return useTemplateChildren({ parent: slot, callback: updateTemplates });
200
- }, [slot, container, authToken]);
201
- useEffect(() => {
202
- const host = useHost();
203
- const callback = (e) => {
204
- e.stopPropagation();
205
- setContext({ token: e.detail.token });
206
- };
207
- host.addEventListener(VERIFICATION_EVENT_KEY, callback);
208
- return () => {
209
- host.removeEventListener(VERIFICATION_EVENT_KEY, callback);
210
- };
211
- }, []);
197
+ }, [slot, container, context]);
198
+ // useEffect(() => {
199
+ // const host = useHost();
200
+ // const callback = (e: CustomEvent) => {
201
+ // e.stopPropagation();
202
+ // setContext({ token: e.detail.token });
203
+ // };
204
+ // host.addEventListener(VERIFICATION_EVENT_KEY, callback);
205
+ // return () => {
206
+ // host.removeEventListener(VERIFICATION_EVENT_KEY, callback);
207
+ // };
208
+ // }, []);
212
209
  return (h(Host, null,
213
210
  h("div", { ref: setSlot, style: { display: "contents" } },
214
211
  h("template", { slot: "not-verified" },
@@ -0,0 +1,165 @@
1
+ import { useLazyQuery, useMutation, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
+ import { useEffect, useState } from "@saasquatch/universal-hooks";
3
+ import { gql } from "graphql-request";
4
+ const UserLookupQuery = gql `
5
+ query userLookup {
6
+ viewer {
7
+ ... on User {
8
+ id
9
+ accountId
10
+ email
11
+ impactConnection {
12
+ user {
13
+ id
14
+ email
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+ `;
21
+ const ParticipantVerificationEmailMutation = gql `
22
+ mutation requestUserEmailVerification($user: UserIdInput!) {
23
+ requestUserEmailVerification(user: $user) {
24
+ success
25
+ }
26
+ }
27
+ `;
28
+ const ImpactVerificationEmailMutation = gql `
29
+ mutation requestImpactPublisherEmail2FA($user: UserIdInput!) {
30
+ requestImpactPublisherEmail2FA(user: $user) {
31
+ success
32
+ }
33
+ }
34
+ `;
35
+ const VerifyUserEmailMutation = gql `
36
+ mutation verifyUserEmail($user: UserIdInput!, $code: String!) {
37
+ verifyUserEmail(user: $user, code: $code) {
38
+ id
39
+ accountId
40
+ email
41
+ emailVerified
42
+ }
43
+ }
44
+ `;
45
+ const SubmitImpactCodeMutation = gql `
46
+ mutation submitImpactPublisherEmail2FACode(
47
+ $user: UserIdInput!
48
+ $code: String!
49
+ ) {
50
+ submitImpactPublisherEmail2FACode(user: $user, code: $code) {
51
+ verifiedEmail
52
+ accessKey
53
+ }
54
+ }
55
+ `;
56
+ // ! It's important when using this hook to ensure initialisation
57
+ // ! is done before calling any mutations
58
+ export function useVerificationEmail() {
59
+ const userIdentity = useUserIdentity();
60
+ const [hasEmails, setHasEmails] = useState({
61
+ participant: false,
62
+ impact: false,
63
+ });
64
+ const [fetch] = useLazyQuery(UserLookupQuery);
65
+ // Send mutations
66
+ const [sendParticipantEmail, { loading: participantEmailLoading, errors: participantEmailErrors },] = useMutation(ParticipantVerificationEmailMutation);
67
+ const [sendImpactEmail, { loading: impactEmailLoading, errors: impactEmailErrors },] = useMutation(ImpactVerificationEmailMutation);
68
+ const sendLoading = participantEmailLoading || impactEmailLoading;
69
+ const sendErrors = participantEmailErrors || impactEmailErrors;
70
+ // Verification mutations
71
+ const [verifyUserEmail, { loading: verifyMutationLoading, errors: verifyMutationErrors },] = useMutation(VerifyUserEmailMutation);
72
+ const [submitImpactCode, { loading: submitImpactCodeLoading, errors: submitImpactCodeErrors },] = useMutation(SubmitImpactCodeMutation);
73
+ const verifyLoading = verifyMutationLoading || submitImpactCodeLoading;
74
+ const verifyErrors = verifyMutationErrors || submitImpactCodeErrors;
75
+ const [initialized, setInitialized] = useState(false);
76
+ const initialise = async () => {
77
+ var _a, _b, _c, _d;
78
+ try {
79
+ const lookup = await fetch({});
80
+ if (!lookup || lookup instanceof Error)
81
+ throw new Error();
82
+ setHasEmails({
83
+ participant: !!((_a = lookup === null || lookup === void 0 ? void 0 : lookup.viewer) === null || _a === void 0 ? void 0 : _a.email),
84
+ 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),
85
+ });
86
+ setInitialized(true);
87
+ }
88
+ catch (e) {
89
+ console.error("Could not initialise verification", e);
90
+ }
91
+ };
92
+ const sendVerificationEmail = async () => {
93
+ let result = null;
94
+ if (!initialized)
95
+ return result;
96
+ if (!hasEmails.participant && !hasEmails.impact)
97
+ return result;
98
+ try {
99
+ const request = hasEmails.impact ? sendImpactEmail : sendParticipantEmail;
100
+ const res = await request({
101
+ user: {
102
+ id: userIdentity.id,
103
+ accountId: userIdentity.accountId,
104
+ },
105
+ });
106
+ if (res instanceof Error || !res)
107
+ throw new Error();
108
+ result = hasEmails.impact
109
+ ? res.requestImpactPublisherEmail2FA
110
+ : res.requestUserEmailVerification;
111
+ }
112
+ catch (e) {
113
+ console.error("Could not send verification email", e);
114
+ }
115
+ finally {
116
+ return result;
117
+ }
118
+ };
119
+ const verifyVerificationEmail = async (code) => {
120
+ var _a;
121
+ let result = null;
122
+ if (!initialized)
123
+ return result;
124
+ if (!hasEmails.participant && !hasEmails.impact)
125
+ return result;
126
+ try {
127
+ const request = hasEmails.impact ? submitImpactCode : verifyUserEmail;
128
+ const res = await request({
129
+ user: {
130
+ id: userIdentity.id,
131
+ accountId: userIdentity.accountId,
132
+ },
133
+ code,
134
+ });
135
+ if (res instanceof Error || !res)
136
+ throw new Error();
137
+ result = {
138
+ success: true,
139
+ accessKey: hasEmails.impact
140
+ ? (_a = res.submitImpactPublisherEmail2FACode) === null || _a === void 0 ? void 0 : _a.accessKey : undefined,
141
+ };
142
+ }
143
+ catch (e) {
144
+ console.error("Could not verify email", e);
145
+ }
146
+ finally {
147
+ return result;
148
+ }
149
+ };
150
+ useEffect(() => {
151
+ if (!initialized)
152
+ initialise();
153
+ }, []);
154
+ return {
155
+ initialized,
156
+ send: [
157
+ sendVerificationEmail,
158
+ { loading: sendLoading, errors: sendErrors },
159
+ ],
160
+ verify: [
161
+ verifyVerificationEmail,
162
+ { loading: verifyLoading, errors: verifyErrors },
163
+ ],
164
+ };
165
+ }
@@ -21,6 +21,7 @@ const bankingFormProps = {
21
21
  loadingError: false,
22
22
  },
23
23
  callbacks: {
24
+ onVerification: () => { },
24
25
  onSubmit: async () => console.log("Submit"),
25
26
  setPaymentMethodChecked: () => { },
26
27
  setPaymentScheduleChecked: () => { },
@@ -210,6 +210,7 @@ const stepFourProps = {
210
210
  },
211
211
  },
212
212
  callbacks: {
213
+ onVerification: () => { },
213
214
  onSubmit: async () => console.log("Submit"),
214
215
  setPaymentMethodChecked: () => { },
215
216
  setPaymentScheduleChecked: () => { },
@@ -257,6 +258,7 @@ const dashboardProps = {
257
258
  indirectTaxNumber: "123456",
258
259
  indirectTaxType: "VAT",
259
260
  showNewFormDialog: false,
261
+ hasHold: false,
260
262
  },
261
263
  slots: {
262
264
  payoutDetailsCardSlot: (h("sqm-payout-details-card", { demoData: {
@@ -771,6 +773,7 @@ export const TaxAndCashDashboardActiveW8BENForm = () => {
771
773
  indirectTaxType: "VAT",
772
774
  indirectTaxNumber: "123456",
773
775
  showNewFormDialog: false,
776
+ hasHold: false,
774
777
  },
775
778
  } }));
776
779
  };
@@ -786,6 +789,7 @@ export const TaxAndCashDashboardActiveW8BENEForm = () => {
786
789
  indirectTaxType: "VAT",
787
790
  indirectTaxNumber: "123456",
788
791
  showNewFormDialog: false,
792
+ hasHold: false,
789
793
  },
790
794
  } }));
791
795
  };
@@ -802,6 +806,7 @@ export const TaxAndCashDashboardNotActiveW9Form = () => {
802
806
  indirectTaxType: "VAT",
803
807
  indirectTaxNumber: "123456",
804
808
  showNewFormDialog: false,
809
+ hasHold: false,
805
810
  },
806
811
  } }));
807
812
  };
@@ -819,6 +824,7 @@ export const TaxAndCashDashboardNotVerifiedW9Form = () => {
819
824
  indirectTaxType: "VAT",
820
825
  indirectTaxNumber: "123456",
821
826
  showNewFormDialog: false,
827
+ hasHold: false,
822
828
  },
823
829
  } }));
824
830
  };
@@ -837,6 +843,7 @@ export const TaxAndCashDashboardNotVerifiedW8BENForm = () => {
837
843
  indirectTaxType: "VAT",
838
844
  indirectTaxNumber: "123456",
839
845
  showNewFormDialog: false,
846
+ hasHold: false,
840
847
  },
841
848
  } }));
842
849
  };
@@ -855,6 +862,7 @@ export const TaxAndCashDashboardNotVerifiedW8BENEForm = () => {
855
862
  indirectTaxType: "VAT",
856
863
  indirectTaxNumber: "123456",
857
864
  showNewFormDialog: false,
865
+ hasHold: false,
858
866
  },
859
867
  } }));
860
868
  };
@@ -873,6 +881,7 @@ export const TaxAndCashDashboardNotActiveW8BENEForm = () => {
873
881
  indirectTaxType: "VAT",
874
882
  country: "United Kingdom",
875
883
  showNewFormDialog: false,
884
+ hasHold: false,
876
885
  },
877
886
  } }));
878
887
  };
@@ -891,6 +900,7 @@ export const TaxAndCashDashboardNoFormNeeded = () => {
891
900
  indirectTaxNumber: "123456",
892
901
  indirectTaxType: "GST",
893
902
  showNewFormDialog: false,
903
+ hasHold: false,
894
904
  },
895
905
  } }));
896
906
  };
@@ -910,6 +920,7 @@ export const TaxAndCashDashboardIndirectTaxCanada = () => {
910
920
  indirectTaxType: "GST",
911
921
  indirectTaxNumber: "123456",
912
922
  showNewFormDialog: false,
923
+ hasHold: false,
913
924
  },
914
925
  } }));
915
926
  };
@@ -930,6 +941,7 @@ export const TaxAndCashDashboardIndirectTaxCanadaQuebec = () => {
930
941
  indirectTaxNumber: "123456",
931
942
  qstNumber: "44212",
932
943
  showNewFormDialog: false,
944
+ hasHold: false,
933
945
  },
934
946
  } }));
935
947
  };
@@ -950,6 +962,7 @@ export const TaxAndCashDashboardIndirectTaxSpain = () => {
950
962
  indirectTaxNumber: "123456",
951
963
  subRegionTaxNumber: "44212",
952
964
  showNewFormDialog: false,
965
+ hasHold: false,
953
966
  },
954
967
  } }));
955
968
  };
@@ -965,6 +978,7 @@ export const TaxAndCashDashboardIndirectTaxNotRegistered = () => {
965
978
  noFormNeeded: false,
966
979
  notRegistered: true,
967
980
  showNewFormDialog: false,
981
+ hasHold: false,
968
982
  },
969
983
  } }));
970
984
  };
@@ -982,6 +996,7 @@ export const TaxAndCashDashboardIdentityVerifcationRequired = () => {
982
996
  noFormNeeded: false,
983
997
  notRegistered: true,
984
998
  showNewFormDialog: false,
999
+ hasHold: false,
985
1000
  },
986
1001
  } }));
987
1002
  };
@@ -997,6 +1012,25 @@ export const TaxAndCashDashboardNewTaxForm = () => {
997
1012
  noFormNeeded: false,
998
1013
  notRegistered: true,
999
1014
  showNewFormDialog: true,
1015
+ hasHold: false,
1016
+ },
1017
+ } }));
1018
+ };
1019
+ export const TaxAndCashDashboardPayoutsOnHold = () => {
1020
+ return (h("sqm-tax-and-cash-dashboard", { demoData: {
1021
+ ...dashboardProps,
1022
+ states: {
1023
+ canEditPayoutInfo: true,
1024
+ disabled: true,
1025
+ status: "ACTIVE",
1026
+ documentType: "W8BEN",
1027
+ documentTypeString: taxTypeToName("W8BEN"),
1028
+ dateSubmitted: "Jan 18th, 2025",
1029
+ noFormNeeded: false,
1030
+ indirectTaxNumber: "123456",
1031
+ country: "Slovania",
1032
+ showNewFormDialog: false,
1033
+ hasHold: true,
1000
1034
  },
1001
1035
  } }));
1002
1036
  };
@@ -1013,6 +1047,7 @@ export const TaxAndCashDashboardLoading = () => {
1013
1047
  noFormNeeded: false,
1014
1048
  loading: true,
1015
1049
  showNewFormDialog: false,
1050
+ hasHold: false,
1016
1051
  },
1017
1052
  } }));
1018
1053
  };
@@ -1030,6 +1065,7 @@ export const TaxAndCashDashboardWithLoadingError = () => {
1030
1065
  loading: true,
1031
1066
  loadingError: true,
1032
1067
  showNewFormDialog: false,
1068
+ hasHold: false,
1033
1069
  },
1034
1070
  } }));
1035
1071
  };
@@ -1048,6 +1084,7 @@ export const TaxAndCashDashboardWithGeneralError = () => {
1048
1084
  indirectTaxType: "VAT",
1049
1085
  country: "Slovania",
1050
1086
  showNewFormDialog: false,
1087
+ hasHold: false,
1051
1088
  errors: {
1052
1089
  general: true,
1053
1090
  },
@@ -1068,6 +1105,7 @@ export const TaxAndCashDashboardDisabled = () => {
1068
1105
  indirectTaxNumber: "123456",
1069
1106
  country: "Slovania",
1070
1107
  showNewFormDialog: false,
1108
+ hasHold: false,
1071
1109
  },
1072
1110
  } }));
1073
1111
  };
@@ -314,7 +314,7 @@ export class BankingInfoForm {
314
314
  },
315
315
  };
316
316
  if (props.states.isPartner && props.states.showVerification) {
317
- return h("sqm-code-verification", null);
317
+ return (h("sqm-code-verification", { onVerification: props.callbacks.onVerification }));
318
318
  }
319
319
  return (h(Host, null,
320
320
  h(BankingInfoFormView, { callbacks: props.callbacks, text: props.text, states: props.states, refs: props.refs, slots: {
@@ -1619,6 +1619,7 @@ function useDemoBankingInfoForm(props) {
1619
1619
  setPaymentScheduleChecked,
1620
1620
  setCountrySearch: () => { },
1621
1621
  onBack: async () => setStep("/dashboard"),
1622
+ onVerification: () => { },
1622
1623
  },
1623
1624
  text: props.getTextProps(),
1624
1625
  refs: {
@@ -288,6 +288,12 @@ export function useBankingInfoForm(props) {
288
288
  }
289
289
  await runMutation(formData, token);
290
290
  };
291
+ const onVerification = async (token) => {
292
+ host.dispatchEvent(new CustomEvent(VERIFICATION_EVENT_KEY, {
293
+ detail: { token },
294
+ bubbles: false,
295
+ }));
296
+ };
291
297
  function setPaymentMethodChecked(paymentMethod) {
292
298
  _setPaymentMethodChecked(paymentMethod);
293
299
  if (paymentMethod === "toPayPalAccount") {
@@ -312,6 +318,7 @@ export function useBankingInfoForm(props) {
312
318
  setPaymentScheduleChecked,
313
319
  onBack: () => setStep("/dashboard"),
314
320
  setCountrySearch,
321
+ onVerification,
315
322
  },
316
323
  states: {
317
324
  showVerification,
@@ -5,8 +5,16 @@ export default {
5
5
  const defaultProps = {
6
6
  status: "INFORMATION_REQUIRED",
7
7
  loading: false,
8
+ showVerifyIdentity: false,
8
9
  };
9
10
  export const InformationRequired = () => (h("sqm-payout-status-alert", { demoData: { states: defaultProps } }));
10
11
  export const VerifyIdentity = () => (h("sqm-payout-status-alert", { demoData: { states: { ...defaultProps, status: "VERIFICATION_NEEDED" } } }));
12
+ export const VerifyIdentityOpen = () => (h("sqm-payout-status-alert", { demoData: {
13
+ states: {
14
+ ...defaultProps,
15
+ status: "VERIFICATION_NEEDED",
16
+ showVerifyIdentity: true,
17
+ },
18
+ } }));
11
19
  export const Hold = () => (h("sqm-payout-status-alert", { demoData: { states: { ...defaultProps, status: "HOLD" } } }));
12
20
  export const Loading = () => (h("sqm-payout-status-alert", { demoData: { states: { ...defaultProps, loading: true } } }));
@@ -32,7 +32,7 @@ const sheet = createStyleSheet(style);
32
32
  const styleString = sheet.toString();
33
33
  export function PayoutStatusAlertView(props) {
34
34
  var _a, _b, _c, _d, _e;
35
- const { text, states } = props;
35
+ const { text, states, callbacks } = props;
36
36
  if (states.loading) {
37
37
  return h("sl-skeleton", { class: sheet.classes.SkeletonOne });
38
38
  }
@@ -78,7 +78,9 @@ export function PayoutStatusAlertView(props) {
78
78
  case "INFORMATION_REQUIRED":
79
79
  return (h("sqm-scroll", { "scroll-tag-name": "sqm-tabs", "button-text": "Payout and tax settings", "scroll-animation": "smooth" }));
80
80
  case "VERIFICATION_NEEDED":
81
- return (h("sl-button", { type: "default", loading: states.loading }, text.verificationRequiredButtonText));
81
+ return (h("sl-button", { type: "default", loading: states.loading,
82
+ //AL: TODO callback to open verification form
83
+ onClick: () => callbacks.onClick }, text.verificationRequiredButtonText));
82
84
  default:
83
85
  return;
84
86
  }
@@ -89,5 +91,8 @@ export function PayoutStatusAlertView(props) {
89
91
  h("sl-icon", { slot: "icon", name: (_c = getAlert(states.status)) === null || _c === void 0 ? void 0 : _c.icon }),
90
92
  h("strong", null, (_d = getAlert(states.status)) === null || _d === void 0 ? void 0 : _d.header),
91
93
  h("p", { class: sheet.classes.AlertDescriptionText }, (_e = getAlert(states.status)) === null || _e === void 0 ? void 0 : _e.description),
92
- getButton(states.status))));
94
+ getButton(states.status)),
95
+ h("sl-dialog", {
96
+ // class={sheet.classes.Dialog}
97
+ open: states.showVerifyIdentity, "onSl-hide": callbacks.onCancel }, "AL: TODO add IFRAME URL")));
93
98
  }
@@ -5,6 +5,11 @@ import { getProps } from "../../../utils/utils";
5
5
  import { PayoutStatusAlertView, } from "./sqm-payout-status-alert-view";
6
6
  import { usePayoutStatus } from "./usePayoutStatus";
7
7
  import { isDemo } from "@saasquatch/component-boilerplate";
8
+ /**
9
+ * @uiName Payout Status Alert
10
+ * @exampleGroup Tax and Cash
11
+ * @example Payout Status Alert - <sqm-payout-status-alert></sqm-payout-status-alert>
12
+ */
8
13
  export class PayoutStatusAlert {
9
14
  constructor() {
10
15
  /**
@@ -227,7 +232,7 @@ export class PayoutStatusAlert {
227
232
  "mutable": false,
228
233
  "complexType": {
229
234
  "original": "DemoData<PayoutStatusAlertViewProps>",
230
- "resolved": "{ states?: { loading: boolean; status: PayoutStatus; }; }",
235
+ "resolved": "{ states?: { loading: boolean; status: PayoutStatus; showVerifyIdentity: boolean; }; }",
231
236
  "references": {
232
237
  "DemoData": {
233
238
  "location": "import",
@@ -259,7 +264,12 @@ function useDemoPayoutStatusAlert(props) {
259
264
  states: {
260
265
  status: "INFORMATION_REQUIRED",
261
266
  loading: false,
267
+ showVerifyIdentity: false,
262
268
  },
263
269
  text: props.getTextProps(),
270
+ callbacks: {
271
+ onClick: () => console.log("show"),
272
+ onCancel: () => console.log("hide"),
273
+ },
264
274
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
265
275
  }
@@ -22,6 +22,7 @@ const GET_USER_STATUS = gql `
22
22
  export function usePayoutStatus(props) {
23
23
  const { loading, data, errors, refetch } = useQuery(GET_USER_STATUS, {});
24
24
  const [status, setStatus] = useState(undefined);
25
+ const [showDialog, setShowDialog] = useState(false);
25
26
  useEffect(() => {
26
27
  if (!data)
27
28
  return;
@@ -45,5 +46,12 @@ export function usePayoutStatus(props) {
45
46
  window.addEventListener("sqm:tax-form-updated", cb);
46
47
  return () => window.removeEventListener("sqm:tax-form-updated", cb);
47
48
  }, []);
48
- return { states: { loading, status }, text: props.getTextProps() };
49
+ return {
50
+ states: { loading, status, showVerifyIdentity: showDialog },
51
+ text: props.getTextProps(),
52
+ callbacks: {
53
+ onClick: () => setShowDialog(true),
54
+ onCancel: () => setShowDialog(false)
55
+ }
56
+ };
49
57
  }
@@ -19,6 +19,11 @@ export const GET_USER = gql `
19
19
  email
20
20
  countryCode
21
21
  customFields
22
+ managedIdentity {
23
+ uid
24
+ email
25
+ emailVerified
26
+ }
22
27
  impactConnection {
23
28
  connected
24
29
  user {