@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
@@ -1808,7 +1808,7 @@ const sheet$3 = JSS.createStyleSheet(style$3);
1808
1808
  const styleString$3 = sheet$3.toString();
1809
1809
  function PayoutStatusAlertView(props) {
1810
1810
  var _a, _b, _c, _d, _e;
1811
- const { text, states } = props;
1811
+ const { text, states, data, callbacks } = props;
1812
1812
  if (states.loading) {
1813
1813
  return index.h("sl-skeleton", { class: sheet$3.classes.SkeletonOne });
1814
1814
  }
@@ -1821,7 +1821,7 @@ function PayoutStatusAlertView(props) {
1821
1821
  return {
1822
1822
  header: text.informationRequiredHeader,
1823
1823
  description: text.informationRequiredDescription,
1824
- buttonText: text.verificationRequiredButtonText,
1824
+ buttonText: text.informationRequiredButtonText,
1825
1825
  alertType: "info",
1826
1826
  icon: "info-circle",
1827
1827
  class: sheet$3.classes.InfoAlertContainer,
@@ -1852,9 +1852,11 @@ function PayoutStatusAlertView(props) {
1852
1852
  function getButton(status) {
1853
1853
  switch (status) {
1854
1854
  case "INFORMATION_REQUIRED":
1855
- return (index.h("sqm-scroll", { "scroll-tag-name": "sqm-tabs", "button-text": "Payout and tax settings", "scroll-animation": "smooth" }));
1855
+ return data.type === "SquatchJS2" ? (index.h("sqm-scroll", { "scroll-tag-name": "sqm-tabs", "button-text": text.informationRequiredButtonText, "scroll-animation": "smooth" })) : data.type === "SquatchPortal" ? (index.h("sl-button", { type: "default", onClick: callbacks.onTermsClick }, text.informationRequiredButtonText)) : (index.h("sl-button", { type: "default" }, text.informationRequiredButtonText));
1856
1856
  case "VERIFICATION_NEEDED":
1857
- return (index.h("sl-button", { type: "default", loading: states.loading }, text.verificationRequiredButtonText));
1857
+ return (index.h("sl-button", { type: "default", loading: states.loading,
1858
+ //AL: TODO callback to open verification form
1859
+ onClick: () => callbacks.onClick }, text.verificationRequiredButtonText));
1858
1860
  default:
1859
1861
  return;
1860
1862
  }
@@ -1865,7 +1867,10 @@ function PayoutStatusAlertView(props) {
1865
1867
  index.h("sl-icon", { slot: "icon", name: (_c = getAlert(states.status)) === null || _c === void 0 ? void 0 : _c.icon }),
1866
1868
  index.h("strong", null, (_d = getAlert(states.status)) === null || _d === void 0 ? void 0 : _d.header),
1867
1869
  index.h("p", { class: sheet$3.classes.AlertDescriptionText }, (_e = getAlert(states.status)) === null || _e === void 0 ? void 0 : _e.description),
1868
- getButton(states.status))));
1870
+ getButton(states.status)),
1871
+ index.h("sl-dialog", {
1872
+ // class={sheet.classes.Dialog}
1873
+ open: states.showVerifyIdentity, "onSl-hide": callbacks.onCancel }, "AL: TODO add IFRAME URL")));
1869
1874
  }
1870
1875
 
1871
1876
  const GET_USER_STATUS = index$1.dist.gql `
@@ -1887,8 +1892,10 @@ const GET_USER_STATUS = index$1.dist.gql `
1887
1892
  }
1888
1893
  `;
1889
1894
  function usePayoutStatus(props) {
1895
+ const { type } = index_module.getEnvironmentSDK();
1890
1896
  const { loading, data, errors, refetch } = index_module.En(GET_USER_STATUS, {});
1891
1897
  const [status, setStatus] = stencilHooks_module.useState(undefined);
1898
+ const [showDialog, setShowDialog] = stencilHooks_module.useState(false);
1892
1899
  stencilHooks_module.useEffect(() => {
1893
1900
  if (!data)
1894
1901
  return;
@@ -1912,7 +1919,16 @@ function usePayoutStatus(props) {
1912
1919
  window.addEventListener("sqm:tax-form-updated", cb);
1913
1920
  return () => window.removeEventListener("sqm:tax-form-updated", cb);
1914
1921
  }, []);
1915
- return { states: { loading, status }, text: props.getTextProps() };
1922
+ return {
1923
+ states: { loading, status, showVerifyIdentity: showDialog },
1924
+ data: { type },
1925
+ text: props.getTextProps(),
1926
+ callbacks: {
1927
+ onTermsClick: () => window.open(props.termsUrl, "_blank").focus(),
1928
+ onClick: () => setShowDialog(true),
1929
+ onCancel: () => setShowDialog(false),
1930
+ },
1931
+ };
1916
1932
  }
1917
1933
 
1918
1934
  const PayoutStatusAlert = class {
@@ -1950,6 +1966,10 @@ const PayoutStatusAlert = class {
1950
1966
  * @uiName Payout on hold alert description
1951
1967
  */
1952
1968
  this.holdDescription = "Please check your inbox for an email from our referral provider, impact.com. It contains details on how to resolve this issue. If you need further assistance, feel free to reach out to {support email}.";
1969
+ /**
1970
+ * @uiName Cash & Payouts Terms and Conditions url
1971
+ */
1972
+ this.termsUrl = "https://terms.advocate.impact.com/PayoutTermsAndConditions.html";
1953
1973
  stencilHooks_module.h(this);
1954
1974
  }
1955
1975
  disconnectedCallback() { }
@@ -1968,8 +1988,15 @@ function useDemoPayoutStatusAlert(props) {
1968
1988
  states: {
1969
1989
  status: "INFORMATION_REQUIRED",
1970
1990
  loading: false,
1991
+ showVerifyIdentity: false,
1971
1992
  },
1993
+ data: { type: "SquatchAdmin" },
1972
1994
  text: props.getTextProps(),
1995
+ callbacks: {
1996
+ onTermsClick: () => { },
1997
+ onClick: () => console.log("show"),
1998
+ onCancel: () => console.log("hide"),
1999
+ },
1973
2000
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
1974
2001
  }
1975
2002
 
@@ -13,7 +13,7 @@ const index$1 = require('./index-56d1fa5b.js');
13
13
  const utils = require('./utils-6847bc06.js');
14
14
  const sqmTextSpanView = require('./sqm-text-span-view-e1cd9bd3.js');
15
15
  const keys = require('./keys-cff24974.js');
16
- const useEmailVerification = require('./useEmailVerification-33465f36.js');
16
+ const useVerificationEmail = require('./useVerificationEmail-35aea294.js');
17
17
 
18
18
  const style = {
19
19
  Wrapper: {
@@ -134,43 +134,22 @@ function WidgetCodeVerificationView(props) {
134
134
  index.h("sl-input", { class: inputClass, name: "code" }),
135
135
  index.h("sl-input", { class: inputClass, name: "code" })),
136
136
  states.verifyFailed && (index.h("p", { class: sheet.classes.ErrorText }, text.invalidCodeText)),
137
- index.h("sl-button", { class: sheet.classes.ContinueButton, onClick: callbacks.submitCode, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.verifyText)),
137
+ index.h("sl-button", { class: sheet.classes.ContinueButton, onClick: callbacks.submitCode, disabled: states.loading || states.initialiseLoading, loading: states.loading || states.initialiseLoading, exportparts: "base: primarybutton-base", type: "primary" }, text.verifyText)),
138
138
  index.h("div", { class: sheet.classes.FooterContainer },
139
139
  index.h(sqmTextSpanView.TextSpanView, { type: "p" }, resendCodeText)))));
140
140
  }
141
141
 
142
- // TODO: Move to component-boilerplate
143
142
  const VerifyEmailWithCodeMutation = index$1.dist.gql `
144
- mutation verifyUserEmail($user: UserIdInput!, $code: String!) {
145
- verifyUserEmail(user: $user, code: $code) {
143
+ mutation submitImpactPublisherEmail2FACode(
144
+ $user: UserIdInput!
145
+ $code: String!
146
+ ) {
147
+ submitImpactPublisherEmail2FACode(user: $user, code: $code) {
146
148
  verifiedEmail
147
149
  accessKey
148
150
  }
149
151
  }
150
152
  `;
151
- function useCodeVerificationMutation() {
152
- const user = index_module.K();
153
- const [request, { loading, data, errors }] = index_module.xe(VerifyEmailWithCodeMutation);
154
- const verifyUserWithCodeMutation = async (code) => {
155
- try {
156
- const result = await request({
157
- user: {
158
- id: user.id,
159
- accountId: user.accountId,
160
- },
161
- code,
162
- });
163
- if (result instanceof Error || !result)
164
- throw new Error();
165
- return result;
166
- }
167
- catch (e) {
168
- console.error("Failed to verify user", e);
169
- return null;
170
- }
171
- };
172
- return [verifyUserWithCodeMutation, { loading, data, errors }];
173
- }
174
153
  function useWidgetCodeVerification(props) {
175
154
  const host = stencilHooks_module.l();
176
155
  const [_, setShowCode] = index_module.Mn(keys.SHOW_CODE_NAMESPACE);
@@ -180,9 +159,10 @@ function useWidgetCodeVerification(props) {
180
159
  const [codeRef, setCodeRef] = stencilHooks_module.useState(null);
181
160
  const [validationError, setValidationError] = stencilHooks_module.useState(false);
182
161
  const [emailError, setEmailError] = stencilHooks_module.useState(false);
183
- // TODO: Need to handle error states for these errors
184
- const [verifyUser, { loading: verifyLoading, errors: verifyErrors }] = useCodeVerificationMutation();
185
- const [request, { loading: resendLoading, data, errors: resendErrors }] = useEmailVerification.useVerificationEmailMutation();
162
+ // // TODO: Need to handle error states for these errors
163
+ // const [verifyUser, { loading: verifyLoading, errors: verifyErrors }] =
164
+ // useCodeVerificationMutation();
165
+ const { initialized, send: [sendEmail, { loading: sendLoading, errors: sendErrors }], verify: [verifyEmail, { loading: verifyLoading, errors: verifyErrors }], } = useVerificationEmail.useVerificationEmail();
186
166
  stencilHooks_module.useEffect(() => {
187
167
  if (!codeRef)
188
168
  return;
@@ -198,7 +178,7 @@ function useWidgetCodeVerification(props) {
198
178
  }
199
179
  });
200
180
  element.addEventListener("input", (e) => {
201
- const input = e.target.value;
181
+ const input = e.data;
202
182
  if (!input)
203
183
  return;
204
184
  if (idx === codeElements.length - 1) {
@@ -208,8 +188,10 @@ function useWidgetCodeVerification(props) {
208
188
  if (input.length > 1) {
209
189
  const rest = input.slice(1);
210
190
  e.target.value = input.slice(0, 1);
211
- codeElements[idx + 1].value = rest;
212
- codeElements[idx + 1].dispatchEvent(new Event("input"));
191
+ codeElements[idx + 1].dispatchEvent(new InputEvent("input", {
192
+ inputType: "insertFromPaste",
193
+ data: rest,
194
+ }));
213
195
  }
214
196
  codeElements[idx + 1].focus();
215
197
  });
@@ -220,7 +202,10 @@ function useWidgetCodeVerification(props) {
220
202
  setValidationError(false);
221
203
  };
222
204
  const resendEmail = async () => {
223
- const result = await request();
205
+ // UI should only allow this to be called if initialized, but checking just in case
206
+ if (!initialized)
207
+ return;
208
+ const result = await sendEmail();
224
209
  if (!result) {
225
210
  setEmailError(true);
226
211
  return;
@@ -240,16 +225,13 @@ function useWidgetCodeVerification(props) {
240
225
  codeElements.forEach((element) => {
241
226
  code = `${code}${element.value}`;
242
227
  });
228
+ // UI should only allow this to be called if initialized, but checking just in case
229
+ if (!initialized)
230
+ return;
243
231
  setValidationError(false);
244
- // Only 123456 passes for a valid code rn
245
- const res = await verifyUser(code);
246
- if (res) {
247
- const event = new CustomEvent(keys.VERIFICATION_EVENT_KEY, {
248
- detail: { token: res.verifyUserEmail.accessKey },
249
- composed: true,
250
- bubbles: true,
251
- });
252
- host.dispatchEvent(event);
232
+ const res = await verifyEmail(code);
233
+ if (res === null || res === void 0 ? void 0 : res.success) {
234
+ props.onVerification(res.accessKey);
253
235
  reset();
254
236
  }
255
237
  else {
@@ -257,12 +239,15 @@ function useWidgetCodeVerification(props) {
257
239
  }
258
240
  };
259
241
  stencilHooks_module.useEffect(() => {
242
+ // Wait for mutations to be determined from user lookup
243
+ if (!initialized)
244
+ return;
260
245
  // email should already exist if user has completed email-verification
261
246
  if (!email)
262
247
  resendEmail();
263
248
  else
264
249
  setEmailSent(true);
265
- }, []);
250
+ }, [initialized]);
266
251
  return {
267
252
  refs: {
268
253
  codeWrapperRef: setCodeRef,
@@ -270,8 +255,9 @@ function useWidgetCodeVerification(props) {
270
255
  states: {
271
256
  email,
272
257
  emailResent,
273
- resendError: !!(resendErrors === null || resendErrors === void 0 ? void 0 : resendErrors.message) || emailError,
274
- loading: verifyLoading || resendLoading,
258
+ resendError: sendErrors || verifyErrors,
259
+ initialiseLoading: !initialized,
260
+ loading: sendLoading || verifyLoading,
275
261
  verifyFailed: !!validationError,
276
262
  },
277
263
  callbacks: {
@@ -351,7 +337,7 @@ function useDemoWidgetCodeVerification(props) {
351
337
  },
352
338
  callbacks: {
353
339
  resendEmail: async () => setEmailResent(true),
354
- submitCode: async () => setVerifiedContext({ token: "TOKEN" }),
340
+ submitCode: async () => setVerifiedContext(true),
355
341
  },
356
342
  text: props.getTextProps(),
357
343
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
@@ -2,16 +2,138 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-b0129cd6.js');
5
+ const index$1 = require('./index-b0129cd6.js');
6
6
  const stencilHooks_module = require('./stencil-hooks.module-a5a04d8a.js');
7
7
  const index_module = require('./index.module-236d0403.js');
8
8
  const cjs = require('./cjs-1066ec21.js');
9
9
  const JSS = require('./JSS-8503a151.js');
10
- require('./index-56d1fa5b.js');
10
+ const index = require('./index-56d1fa5b.js');
11
11
  const utils = require('./utils-6847bc06.js');
12
12
  const sqmTextSpanView = require('./sqm-text-span-view-e1cd9bd3.js');
13
13
  const keys = require('./keys-cff24974.js');
14
- const useEmailVerification = require('./useEmailVerification-33465f36.js');
14
+ const useVerificationEmail = require('./useVerificationEmail-35aea294.js');
15
+
16
+ const UpsertUserEmailMutation = index.dist.gql `
17
+ mutation upsertUser($userInput: UserInput!) {
18
+ user(userInput: $userInput) {
19
+ id
20
+ accountId
21
+ email
22
+ }
23
+ }
24
+ `;
25
+ const UserLookupQuery = index.dist.gql `
26
+ query user {
27
+ viewer {
28
+ ... on User {
29
+ id
30
+ accountId
31
+ email
32
+ impactConnection {
33
+ user {
34
+ id
35
+ email
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ `;
42
+ function useUpsertUserEmail() {
43
+ const user = index_module.K();
44
+ const [request, { loading: loading, data, errors }] = index_module.xe(UpsertUserEmailMutation);
45
+ const upsertUserEmail = async (email) => {
46
+ try {
47
+ const result = await request({
48
+ user: {
49
+ id: user.id,
50
+ accountId: user.accountId,
51
+ email,
52
+ },
53
+ });
54
+ if (result instanceof Error || !result)
55
+ throw new Error();
56
+ return result;
57
+ }
58
+ catch (e) {
59
+ console.error("Could not set email on user", e);
60
+ return undefined;
61
+ }
62
+ };
63
+ return [
64
+ upsertUserEmail,
65
+ {
66
+ loading,
67
+ data,
68
+ errors,
69
+ },
70
+ ];
71
+ }
72
+ function useWidgetEmailVerification(props) {
73
+ const [_, setShowCode] = index_module.Mn(keys.SHOW_CODE_NAMESPACE);
74
+ const [email, setEmail] = index_module.Mn(keys.VERIFICATION_EMAIL_NAMESPACE);
75
+ const [emailExists, setEmailExists] = stencilHooks_module.useState(false);
76
+ const [error, setError] = stencilHooks_module.useState(false);
77
+ const [mutationError, setMutationError] = stencilHooks_module.useState(false);
78
+ const { initialized, send: [sendEmail, { loading: sendLoading, errors }], } = useVerificationEmail.useVerificationEmail();
79
+ const [upsertUserEmail] = useUpsertUserEmail();
80
+ const [loading, setLoading] = stencilHooks_module.useState(true);
81
+ const { data, loading: initialLoading } = index_module.En(UserLookupQuery, {});
82
+ const emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
83
+ stencilHooks_module.useEffect(() => {
84
+ if (!(data === null || data === void 0 ? void 0 : data.viewer))
85
+ return;
86
+ setEmailExists(!!data.viewer.email);
87
+ }, [data]);
88
+ stencilHooks_module.useEffect(() => {
89
+ if (initialized)
90
+ setLoading(false);
91
+ }, [initialized]);
92
+ const submitEmail = async (e) => {
93
+ e.preventDefault();
94
+ if (!(data === null || data === void 0 ? void 0 : data.viewer))
95
+ return;
96
+ setLoading(true);
97
+ const toAddress = data.viewer.email;
98
+ if (!toAddress) {
99
+ // If no email on the user, set one
100
+ const formData = e.detail.formData;
101
+ const newEmail = formData.get("email").toString();
102
+ if (!emailRegex.test(newEmail)) {
103
+ setError(true);
104
+ return;
105
+ }
106
+ const result = await upsertUserEmail(newEmail);
107
+ if (!result || !result.user.email)
108
+ setError(true);
109
+ }
110
+ // UI should not allow this call til initialisation is done
111
+ if (!initialized)
112
+ return;
113
+ const result = await sendEmail();
114
+ if (!result || !result.success)
115
+ setMutationError(true);
116
+ else {
117
+ // This is used to let the code verification widget know an email was already sent
118
+ setEmail(toAddress);
119
+ setShowCode(true);
120
+ }
121
+ setLoading(false);
122
+ };
123
+ return {
124
+ callbacks: {
125
+ submitEmail,
126
+ },
127
+ states: {
128
+ loading,
129
+ initialLoading: initialLoading && !initialized,
130
+ error,
131
+ email: data === null || data === void 0 ? void 0 : data.viewer.email,
132
+ sendCodeError: mutationError,
133
+ },
134
+ text: props.getTextProps(),
135
+ };
136
+ }
15
137
 
16
138
  const style = {
17
139
  Wrapper: {
@@ -76,35 +198,35 @@ const styleString = sheet.toString();
76
198
  function WidgetEmailVerificationView(props) {
77
199
  const { states, callbacks, text } = props;
78
200
  const renderLoadingSkeleton = () => {
79
- return (index.h("div", { class: sheet.classes.Wrapper },
80
- index.h("sl-skeleton", { class: sheet.classes.SkeletonOne }),
81
- index.h("sl-skeleton", { class: sheet.classes.SkeletonTwo }),
82
- index.h("sl-skeleton", { class: sheet.classes.SkeletonThree })));
201
+ return (index$1.h("div", { class: sheet.classes.Wrapper },
202
+ index$1.h("sl-skeleton", { class: sheet.classes.SkeletonOne }),
203
+ index$1.h("sl-skeleton", { class: sheet.classes.SkeletonTwo }),
204
+ index$1.h("sl-skeleton", { class: sheet.classes.SkeletonThree })));
83
205
  };
84
- return (index.h("div", { part: "sqm-base" },
85
- index.h("style", { type: "text/css" },
206
+ return (index$1.h("div", { part: "sqm-base" },
207
+ index$1.h("style", { type: "text/css" },
86
208
  vanillaStyle,
87
209
  styleString),
88
- states.sendCodeError && (index.h("sl-alert", { exportparts: "base: alert-base, icon:alert-icon", type: "danger", class: sheet.classes.ErrorAlertContainer, open: true },
89
- index.h("sl-icon", { slot: "icon", name: "exclamation-octagon" }),
90
- index.h("b", null, text.sendCodeErrorHeader),
210
+ states.sendCodeError && (index$1.h("sl-alert", { exportparts: "base: alert-base, icon:alert-icon", type: "danger", class: sheet.classes.ErrorAlertContainer, open: true },
211
+ index$1.h("sl-icon", { slot: "icon", name: "exclamation-octagon" }),
212
+ index$1.h("b", null, text.sendCodeErrorHeader),
91
213
  text.sendCodeErrorDescription)),
92
- states.initialLoading ? (renderLoadingSkeleton()) : (index.h("div", { class: sheet.classes.Wrapper },
93
- index.h(sqmTextSpanView.TextSpanView, { type: "p" }, text.verifyEmailHeaderText),
94
- index.h("sl-form", { "onSl-submit": callbacks.submitEmail },
95
- index.h("div", { class: sheet.classes.InputsContainer },
96
- index.h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", label: text.emailLabel, value: states.email, type: "email", id: "email", name: "email", disabled: !!states.email || states.loading }, (states.error
214
+ states.initialLoading ? (renderLoadingSkeleton()) : (index$1.h("div", { class: sheet.classes.Wrapper },
215
+ index$1.h(sqmTextSpanView.TextSpanView, { type: "p" }, text.verifyEmailHeaderText),
216
+ index$1.h("sl-form", { "onSl-submit": callbacks.submitEmail },
217
+ index$1.h("div", { class: sheet.classes.InputsContainer },
218
+ index$1.h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", label: text.emailLabel, value: states.email, type: "email", id: "email", name: "email", disabled: !!states.email || states.loading }, (states.error
97
219
  ? {
98
220
  class: sheet.classes.ErrorInput,
99
221
  helpText: text.emailValidationErrorText,
100
222
  }
101
223
  : {}))),
102
- index.h("sl-button", { submit: true, class: sheet.classes.ContinueButton, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.sendCodeText)))))));
224
+ index$1.h("sl-button", { submit: true, class: sheet.classes.ContinueButton, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.sendCodeText)))))));
103
225
  }
104
226
 
105
227
  const WidgetEmailVerification = class {
106
228
  constructor(hostRef) {
107
- index.registerInstance(this, hostRef);
229
+ index$1.registerInstance(this, hostRef);
108
230
  /**
109
231
  * @uiName Verify email widget header text
110
232
  */
@@ -138,8 +260,8 @@ const WidgetEmailVerification = class {
138
260
  render() {
139
261
  const props = index_module.isDemo()
140
262
  ? useDemoWidgetEmailVerification(this)
141
- : useEmailVerification.useWidgetEmailVerification(this);
142
- return index.h(WidgetEmailVerificationView, Object.assign({}, props));
263
+ : useWidgetEmailVerification(this);
264
+ return index$1.h(WidgetEmailVerificationView, Object.assign({}, props));
143
265
  }
144
266
  };
145
267
  function useDemoWidgetEmailVerification(props) {
@@ -714,6 +714,7 @@ const stepFourProps = {
714
714
  },
715
715
  },
716
716
  callbacks: {
717
+ onVerification: () => { },
717
718
  onSubmit: async () => console.log("Submit"),
718
719
  setPaymentMethodChecked: () => { },
719
720
  setPaymentScheduleChecked: () => { },
@@ -761,6 +762,7 @@ const dashboardProps = {
761
762
  indirectTaxNumber: "123456",
762
763
  indirectTaxType: "VAT",
763
764
  showNewFormDialog: false,
765
+ hasHold: false,
764
766
  },
765
767
  slots: {
766
768
  payoutDetailsCardSlot: (index.h("sqm-payout-details-card", { demoData: {
@@ -1275,6 +1277,7 @@ const TaxAndCashDashboardActiveW8BENForm = () => {
1275
1277
  indirectTaxType: "VAT",
1276
1278
  indirectTaxNumber: "123456",
1277
1279
  showNewFormDialog: false,
1280
+ hasHold: false,
1278
1281
  },
1279
1282
  } }));
1280
1283
  };
@@ -1290,6 +1293,7 @@ const TaxAndCashDashboardActiveW8BENEForm = () => {
1290
1293
  indirectTaxType: "VAT",
1291
1294
  indirectTaxNumber: "123456",
1292
1295
  showNewFormDialog: false,
1296
+ hasHold: false,
1293
1297
  },
1294
1298
  } }));
1295
1299
  };
@@ -1306,6 +1310,7 @@ const TaxAndCashDashboardNotActiveW9Form = () => {
1306
1310
  indirectTaxType: "VAT",
1307
1311
  indirectTaxNumber: "123456",
1308
1312
  showNewFormDialog: false,
1313
+ hasHold: false,
1309
1314
  },
1310
1315
  } }));
1311
1316
  };
@@ -1323,6 +1328,7 @@ const TaxAndCashDashboardNotVerifiedW9Form = () => {
1323
1328
  indirectTaxType: "VAT",
1324
1329
  indirectTaxNumber: "123456",
1325
1330
  showNewFormDialog: false,
1331
+ hasHold: false,
1326
1332
  },
1327
1333
  } }));
1328
1334
  };
@@ -1341,6 +1347,7 @@ const TaxAndCashDashboardNotVerifiedW8BENForm = () => {
1341
1347
  indirectTaxType: "VAT",
1342
1348
  indirectTaxNumber: "123456",
1343
1349
  showNewFormDialog: false,
1350
+ hasHold: false,
1344
1351
  },
1345
1352
  } }));
1346
1353
  };
@@ -1359,6 +1366,7 @@ const TaxAndCashDashboardNotVerifiedW8BENEForm = () => {
1359
1366
  indirectTaxType: "VAT",
1360
1367
  indirectTaxNumber: "123456",
1361
1368
  showNewFormDialog: false,
1369
+ hasHold: false,
1362
1370
  },
1363
1371
  } }));
1364
1372
  };
@@ -1377,6 +1385,7 @@ const TaxAndCashDashboardNotActiveW8BENEForm = () => {
1377
1385
  indirectTaxType: "VAT",
1378
1386
  country: "United Kingdom",
1379
1387
  showNewFormDialog: false,
1388
+ hasHold: false,
1380
1389
  },
1381
1390
  } }));
1382
1391
  };
@@ -1395,6 +1404,7 @@ const TaxAndCashDashboardNoFormNeeded = () => {
1395
1404
  indirectTaxNumber: "123456",
1396
1405
  indirectTaxType: "GST",
1397
1406
  showNewFormDialog: false,
1407
+ hasHold: false,
1398
1408
  },
1399
1409
  } }));
1400
1410
  };
@@ -1414,6 +1424,7 @@ const TaxAndCashDashboardIndirectTaxCanada = () => {
1414
1424
  indirectTaxType: "GST",
1415
1425
  indirectTaxNumber: "123456",
1416
1426
  showNewFormDialog: false,
1427
+ hasHold: false,
1417
1428
  },
1418
1429
  } }));
1419
1430
  };
@@ -1434,6 +1445,7 @@ const TaxAndCashDashboardIndirectTaxCanadaQuebec = () => {
1434
1445
  indirectTaxNumber: "123456",
1435
1446
  qstNumber: "44212",
1436
1447
  showNewFormDialog: false,
1448
+ hasHold: false,
1437
1449
  },
1438
1450
  } }));
1439
1451
  };
@@ -1454,6 +1466,7 @@ const TaxAndCashDashboardIndirectTaxSpain = () => {
1454
1466
  indirectTaxNumber: "123456",
1455
1467
  subRegionTaxNumber: "44212",
1456
1468
  showNewFormDialog: false,
1469
+ hasHold: false,
1457
1470
  },
1458
1471
  } }));
1459
1472
  };
@@ -1469,6 +1482,7 @@ const TaxAndCashDashboardIndirectTaxNotRegistered = () => {
1469
1482
  noFormNeeded: false,
1470
1483
  notRegistered: true,
1471
1484
  showNewFormDialog: false,
1485
+ hasHold: false,
1472
1486
  },
1473
1487
  } }));
1474
1488
  };
@@ -1486,6 +1500,7 @@ const TaxAndCashDashboardIdentityVerifcationRequired = () => {
1486
1500
  noFormNeeded: false,
1487
1501
  notRegistered: true,
1488
1502
  showNewFormDialog: false,
1503
+ hasHold: false,
1489
1504
  },
1490
1505
  } }));
1491
1506
  };
@@ -1501,6 +1516,25 @@ const TaxAndCashDashboardNewTaxForm = () => {
1501
1516
  noFormNeeded: false,
1502
1517
  notRegistered: true,
1503
1518
  showNewFormDialog: true,
1519
+ hasHold: false,
1520
+ },
1521
+ } }));
1522
+ };
1523
+ const TaxAndCashDashboardPayoutsOnHold = () => {
1524
+ return (index.h("sqm-tax-and-cash-dashboard", { demoData: {
1525
+ ...dashboardProps,
1526
+ states: {
1527
+ canEditPayoutInfo: true,
1528
+ disabled: true,
1529
+ status: "ACTIVE",
1530
+ documentType: "W8BEN",
1531
+ documentTypeString: taxTypeToName("W8BEN"),
1532
+ dateSubmitted: "Jan 18th, 2025",
1533
+ noFormNeeded: false,
1534
+ indirectTaxNumber: "123456",
1535
+ country: "Slovania",
1536
+ showNewFormDialog: false,
1537
+ hasHold: true,
1504
1538
  },
1505
1539
  } }));
1506
1540
  };
@@ -1517,6 +1551,7 @@ const TaxAndCashDashboardLoading = () => {
1517
1551
  noFormNeeded: false,
1518
1552
  loading: true,
1519
1553
  showNewFormDialog: false,
1554
+ hasHold: false,
1520
1555
  },
1521
1556
  } }));
1522
1557
  };
@@ -1534,6 +1569,7 @@ const TaxAndCashDashboardWithLoadingError = () => {
1534
1569
  loading: true,
1535
1570
  loadingError: true,
1536
1571
  showNewFormDialog: false,
1572
+ hasHold: false,
1537
1573
  },
1538
1574
  } }));
1539
1575
  };
@@ -1552,6 +1588,7 @@ const TaxAndCashDashboardWithGeneralError = () => {
1552
1588
  indirectTaxType: "VAT",
1553
1589
  country: "Slovania",
1554
1590
  showNewFormDialog: false,
1591
+ hasHold: false,
1555
1592
  errors: {
1556
1593
  general: true,
1557
1594
  },
@@ -1572,6 +1609,7 @@ const TaxAndCashDashboardDisabled = () => {
1572
1609
  indirectTaxNumber: "123456",
1573
1610
  country: "Slovania",
1574
1611
  showNewFormDialog: false,
1612
+ hasHold: false,
1575
1613
  },
1576
1614
  } }));
1577
1615
  };
@@ -1640,6 +1678,7 @@ const TaxForm = /*#__PURE__*/Object.freeze({
1640
1678
  TaxAndCashDashboardIndirectTaxNotRegistered: TaxAndCashDashboardIndirectTaxNotRegistered,
1641
1679
  TaxAndCashDashboardIdentityVerifcationRequired: TaxAndCashDashboardIdentityVerifcationRequired,
1642
1680
  TaxAndCashDashboardNewTaxForm: TaxAndCashDashboardNewTaxForm,
1681
+ TaxAndCashDashboardPayoutsOnHold: TaxAndCashDashboardPayoutsOnHold,
1643
1682
  TaxAndCashDashboardLoading: TaxAndCashDashboardLoading,
1644
1683
  TaxAndCashDashboardWithLoadingError: TaxAndCashDashboardWithLoadingError,
1645
1684
  TaxAndCashDashboardWithGeneralError: TaxAndCashDashboardWithGeneralError,