@saasquatch/mint-components 2.0.2 → 2.0.3-2

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 (82) hide show
  1. package/dist/cjs/{ShadowViewAddon-fbc33c53.js → ShadowViewAddon-ae3a32c3.js} +3 -3
  2. package/dist/cjs/{data-16106637.js → data-44260010.js} +29 -2
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/mint-components.cjs.js +1 -1
  5. package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +341 -76
  6. package/dist/cjs/sqm-big-stat_47.cjs.entry.js +213 -12
  7. package/dist/cjs/sqm-header-logo.cjs.entry.js +15 -2
  8. package/dist/cjs/sqm-stencilbook.cjs.entry.js +24 -3
  9. package/dist/collection/components/sqm-header-logo/sqm-header-logo.js +85 -5
  10. package/dist/collection/components/sqm-portal-footer/sqm-portal-footer-view.js +3 -3
  11. package/dist/collection/components/tax-and-cash/TaxForm.stories.js +1 -0
  12. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/useBankingInfoForm.js +10 -5
  13. package/dist/collection/components/tax-and-cash/sqm-docusign-form/useDocusignForm.js +11 -5
  14. package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.js +46 -40
  15. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.js +13 -0
  16. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.js +95 -1
  17. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.js +360 -7
  18. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.js +29 -2
  19. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +311 -11
  20. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.js +96 -1
  21. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.js +310 -10
  22. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/useTaxAndCashDashboard.js +7 -1
  23. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +23 -12
  24. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form.js +1 -1
  25. package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +100 -9
  26. package/dist/esm/{ShadowViewAddon-7a242b65.js → ShadowViewAddon-78a1c35c.js} +3 -3
  27. package/dist/esm/{data-acdb790f.js → data-68816061.js} +29 -2
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/esm/mint-components.js +1 -1
  30. package/dist/esm/sqm-banking-info-form_10.entry.js +341 -76
  31. package/dist/esm/sqm-big-stat_47.entry.js +213 -12
  32. package/dist/esm/sqm-header-logo.entry.js +15 -2
  33. package/dist/esm/sqm-stencilbook.entry.js +24 -3
  34. package/dist/esm-es5/{ShadowViewAddon-7a242b65.js → ShadowViewAddon-78a1c35c.js} +1 -1
  35. package/dist/esm-es5/{data-acdb790f.js → data-68816061.js} +2 -2
  36. package/dist/esm-es5/loader.js +1 -1
  37. package/dist/esm-es5/mint-components.js +1 -1
  38. package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
  39. package/dist/esm-es5/sqm-big-stat_47.entry.js +1 -1
  40. package/dist/esm-es5/sqm-header-logo.entry.js +1 -1
  41. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  42. package/dist/mint-components/mint-components.esm.js +1 -1
  43. package/dist/mint-components/p-18790f90.entry.js +106 -0
  44. package/dist/mint-components/p-38a100b4.system.entry.js +1 -0
  45. package/dist/mint-components/p-3f661133.system.entry.js +1 -0
  46. package/dist/mint-components/p-775214ef.entry.js +273 -0
  47. package/dist/mint-components/p-7e550c3b.system.entry.js +1 -0
  48. package/dist/mint-components/p-92b5c376.js +157 -0
  49. package/dist/mint-components/p-947bacd1.system.js +1 -1
  50. package/dist/mint-components/p-9a3ff9b9.entry.js +9 -0
  51. package/dist/mint-components/p-a2dbc9ad.system.js +6 -0
  52. package/dist/mint-components/p-bdb6194c.entry.js +1 -0
  53. package/dist/mint-components/p-c7ac295d.system.entry.js +1 -0
  54. package/dist/mint-components/{p-d7635535.system.js → p-e3ee8c37.system.js} +1 -1
  55. package/dist/mint-components/{p-ffc3cd7c.js → p-ee83de0e.js} +1 -1
  56. package/dist/types/components/sqm-header-logo/sqm-header-logo.d.ts +17 -2
  57. package/dist/types/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.d.ts +24 -0
  58. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.d.ts +7 -0
  59. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.d.ts +16 -0
  60. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.d.ts +57 -0
  61. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.d.ts +3 -1
  62. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.d.ts +48 -0
  63. package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.d.ts +12 -0
  64. package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.d.ts +48 -0
  65. package/dist/types/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.d.ts +2 -0
  66. package/dist/types/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.d.ts +1 -0
  67. package/dist/types/components.d.ts +335 -3
  68. package/docs/docs.docx +0 -0
  69. package/docs/raisins.json +1 -1
  70. package/grapesjs/grapesjs.js +1 -1
  71. package/package.json +1 -1
  72. package/dist/mint-components/p-012d31bc.entry.js +0 -99
  73. package/dist/mint-components/p-2ea6e2fa.entry.js +0 -273
  74. package/dist/mint-components/p-303b84d7.system.entry.js +0 -1
  75. package/dist/mint-components/p-469a6450.system.js +0 -6
  76. package/dist/mint-components/p-6976099f.entry.js +0 -9
  77. package/dist/mint-components/p-752ede25.system.entry.js +0 -1
  78. package/dist/mint-components/p-97747228.system.entry.js +0 -1
  79. package/dist/mint-components/p-a7ee19dc.entry.js +0 -1
  80. package/dist/mint-components/p-e1e7d01c.js +0 -157
  81. package/dist/mint-components/p-eea87fdc.system.entry.js +0 -1
  82. package/shoelace/assets/icons/twitter-x.svg +0 -4
@@ -1,11 +1,22 @@
1
- import { useParent, useParentQueryValue, useParentValue, } from "@saasquatch/component-boilerplate";
1
+ import { useMutation, useParent, useParentQueryValue, useParentValue, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
2
  import { useEffect, useMemo, useRef, useState, } from "@saasquatch/universal-hooks";
3
3
  import jsonpointer from "jsonpointer";
4
4
  import { CURRENCIES_NAMESPACE, SORTED_COUNTRIES_NAMESPACE, TAX_CONTEXT_NAMESPACE, TAX_FORM_CONTEXT_NAMESPACE, USER_FORM_CONTEXT_NAMESPACE, USER_QUERY_NAMESPACE, } from "../data";
5
5
  import { ADDRESS_REGIONS } from "../subregions";
6
- import { objectIsFull } from "../utils";
6
+ import { objectIsFull, validTaxDocument } from "../utils";
7
+ import { TAX_FORM_UPDATED_EVENT_KEY } from "../eventKeys";
8
+ import { CONNECT_PARTNER, } from "../sqm-indirect-tax-form/useIndirectTaxForm";
9
+ import { gql } from "graphql-request";
10
+ const GET_INDIRECT_TAX_COUNTRY_CODE = gql `
11
+ query getIndirectTaxCountryCode {
12
+ tenantSettings {
13
+ impactBrandCountryCode
14
+ impactBrandIndirectTaxCountryCode
15
+ }
16
+ }
17
+ `;
7
18
  export function useUserInfoForm(props) {
8
- var _a, _b, _c, _d;
19
+ var _a, _b, _c, _d, _e, _f, _g;
9
20
  const currencyRef = useRef(undefined);
10
21
  const phoneCountryRef = useRef(undefined);
11
22
  const formRef = useRef(null);
@@ -13,7 +24,10 @@ export function useUserInfoForm(props) {
13
24
  const countries = useParentValue(SORTED_COUNTRIES_NAMESPACE);
14
25
  const [step, setStep] = useParent(TAX_CONTEXT_NAMESPACE);
15
26
  const [userFormContext, setUserFormContext] = useParent(USER_FORM_CONTEXT_NAMESPACE);
16
- const { data, loading, errors: userError, } = useParentQueryValue(USER_QUERY_NAMESPACE);
27
+ const user = useUserIdentity();
28
+ const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = useMutation(CONNECT_PARTNER);
29
+ const { data: tenantData } = useQuery(GET_INDIRECT_TAX_COUNTRY_CODE, {});
30
+ const { data, loading, refetch, errors: userError, } = useParentQueryValue(USER_QUERY_NAMESPACE);
17
31
  const _currencies = useParentValue(CURRENCIES_NAMESPACE);
18
32
  const currencies = useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
19
33
  const [countrySearch, setCountrySearch] = useState("");
@@ -115,6 +129,45 @@ export function useUserInfoForm(props) {
115
129
  setFilteredCurrencies(currencies.filter((c) => c.currencyCode.toLowerCase().includes(currencySearch.toLowerCase())) || []);
116
130
  }
117
131
  }, [currencySearch, currencies]);
132
+ async function connectPartner(formData) {
133
+ var _a, _b, _c, _d, _e;
134
+ const vars = {
135
+ user: {
136
+ id: user.id,
137
+ accountId: user.accountId,
138
+ },
139
+ firstName: formData.firstName,
140
+ lastName: formData.lastName,
141
+ countryCode: formData.countryCode,
142
+ currency: formData.currency,
143
+ address: formData.address,
144
+ city: formData.city,
145
+ state: formData.state,
146
+ postalCode: formData.postalCode,
147
+ phoneNumber: formData.phoneNumber,
148
+ phoneNumberCountryCode: formData.phoneNumberCountryCode,
149
+ };
150
+ const result = await connectImpactPartner({
151
+ vars,
152
+ });
153
+ if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
154
+ throw new Error();
155
+ if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
156
+ // Output backend errors to console for now
157
+ console.error("Failed to create Impact connection: ", result.createImpactConnection.validationErrors);
158
+ throw new Error();
159
+ }
160
+ await refetch();
161
+ const resultPublisher = (_e = (_d = (_c = result
162
+ .createImpactConnection) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher;
163
+ const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
164
+ // Fire form change event
165
+ window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
166
+ return {
167
+ resultPublisher,
168
+ hasValidCurrentDocument,
169
+ };
170
+ }
118
171
  async function onSubmit(event) {
119
172
  let formControls = event.target.getFormControls();
120
173
  let formData = {};
@@ -157,9 +210,46 @@ export function useUserInfoForm(props) {
157
210
  postalCode: userData.postalCode,
158
211
  currency: userData.currency,
159
212
  });
160
- const nextStep = context.overrideNextStep || "/2";
213
+ const skipNextStep = getSkipNextStep(userData);
214
+ if (skipNextStep) {
215
+ try {
216
+ const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
217
+ if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
218
+ !hasValidCurrentDocument) {
219
+ // Go to docusign form
220
+ setStep("/3");
221
+ }
222
+ else {
223
+ if (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.brandedSignup) {
224
+ // Go to banking information form
225
+ setStep("/4");
226
+ }
227
+ else {
228
+ // Go right to the dashboard
229
+ setStep("/dashboard");
230
+ }
231
+ }
232
+ return;
233
+ }
234
+ catch (e) {
235
+ setErrors({ general: true });
236
+ return;
237
+ }
238
+ }
239
+ const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
161
240
  setStep(nextStep);
162
241
  }
242
+ const indirectTaxCountry = (_a = tenantData === null || tenantData === void 0 ? void 0 : tenantData.tenantSettings) === null || _a === void 0 ? void 0 : _a.impactBrandIndirectTaxCountryCode;
243
+ const hasIndirectTax = !!indirectTaxCountry;
244
+ function getSkipNextStep(userData) {
245
+ if (!hasIndirectTax)
246
+ return true;
247
+ if (userData.countryCode === "US")
248
+ return true;
249
+ if (hasIndirectTax && userData.countryCode !== indirectTaxCountry)
250
+ return true;
251
+ return false;
252
+ }
163
253
  const hasStates = ["ES", "AU", "US", "CA"].includes(userFormContext.countryCode);
164
254
  const regionObj = hasStates
165
255
  ? ADDRESS_REGIONS[userFormContext === null || userFormContext === void 0 ? void 0 : userFormContext.countryCode]
@@ -187,16 +277,17 @@ export function useUserInfoForm(props) {
187
277
  allCountries: countries,
188
278
  regionLabelEnum: regionObj === null || regionObj === void 0 ? void 0 : regionObj.labelEnum,
189
279
  regions: (regionObj === null || regionObj === void 0 ? void 0 : regionObj.regions) || [],
280
+ partnerData: (_c = (_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.impactConnection) === null || _c === void 0 ? void 0 : _c.publisher,
190
281
  },
191
282
  states: {
192
283
  step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
193
284
  hideState: !hasStates,
194
285
  hideSteps: !!context.hideSteps,
195
- disabled: loading,
286
+ disabled: loading || connectLoading,
196
287
  loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
197
- loading: loading,
198
- isPartner: !!((_b = (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.impactConnection) === null || _b === void 0 ? void 0 : _b.publisher),
199
- isUser: !!((_d = (_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.impactConnection) === null || _d === void 0 ? void 0 : _d.user),
288
+ loading: loading || connectLoading,
289
+ isPartner: !!((_e = (_d = data === null || data === void 0 ? void 0 : data.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher),
290
+ isUser: !!((_g = (_f = data === null || data === void 0 ? void 0 : data.user) === null || _f === void 0 ? void 0 : _f.impactConnection) === null || _g === void 0 ? void 0 : _g.user),
200
291
  formState: {
201
292
  ...userFormContext,
202
293
  errors: formErrors,
@@ -2849,14 +2849,14 @@ function ChangeMarktingView(props) {
2849
2849
  }
2850
2850
 
2851
2851
  const vanillaStyle$5 = `
2852
- :host{
2852
+ :host {
2853
2853
  margin: 0 auto;
2854
2854
  width: 100%;
2855
2855
  }
2856
- a{
2856
+ a {
2857
2857
  cursor:pointer;
2858
2858
  color: var(--sqm-text-subdued);
2859
- text-decoration: none ;
2859
+ text-decoration: none;
2860
2860
  }
2861
2861
  `;
2862
2862
  function PortalFooterView(props) {
@@ -1000,7 +1000,7 @@ const GET_TAX_SETTING = dist.gql `
1000
1000
  }
1001
1001
  `;
1002
1002
  function getStatus(data) {
1003
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1003
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
1004
1004
  const account = (_b = (_a = data.user.impactConnection) === null || _a === void 0 ? void 0 : _a.publisher) === null || _b === void 0 ? void 0 : _b.payoutsAccount;
1005
1005
  const hasTransferredReward = (_e = (_d = (_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.rewards) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.find((reward) => reward.statuses.includes("REDEEMED") &&
1006
1006
  reward.partnerFundsTransfer.status === "TRANSFERRED");
@@ -1017,8 +1017,23 @@ function getStatus(data) {
1017
1017
  return "VERIFICATION:REVIEW";
1018
1018
  if ((_p = account.holdReasons) === null || _p === void 0 ? void 0 : _p.includes("IDV_CHECK_FAILED_INTERNAL"))
1019
1019
  return "VERIFICATION:FAILED";
1020
+ // only show banner for NEW_PAYEE_REVIEW if a PFT was created
1020
1021
  if (((_q = account.holdReasons) === null || _q === void 0 ? void 0 : _q.includes("NEW_PAYEE_REVIEW")) && hasTransferredReward)
1021
- return "ACCOUNT_REVIEW";
1022
+ return "NEW_PAYEE_REVIEW";
1023
+ if ((_r = account.holdReasons) === null || _r === void 0 ? void 0 : _r.includes("NEW_PAYEE_REVIEW"))
1024
+ return "DONE";
1025
+ if ((_s = account.holdReasons) === null || _s === void 0 ? void 0 : _s.includes("PAYMENT_HOLD_ON_CHANGE"))
1026
+ return "PAYMENT_HOLD_ON_CHANGE";
1027
+ if ((_t = account.holdReasons) === null || _t === void 0 ? void 0 : _t.includes("BENEFICIARY_NAME_INVALID"))
1028
+ return "BENEFICIARY_NAME_INVALID";
1029
+ if ((_u = account.holdReasons) === null || _u === void 0 ? void 0 : _u.includes("BENEFICIARY_NAME_MISMATCH"))
1030
+ return "BENEFICIARY_NAME_MISMATCH";
1031
+ if ((_v = account.holdReasons) === null || _v === void 0 ? void 0 : _v.includes("BANK_TAX_NAME_MISMATCH"))
1032
+ return "BANK_TAX_NAME_MISMATCH";
1033
+ if ((_w = account.holdReasons) === null || _w === void 0 ? void 0 : _w.includes("WITHDRAWAL_SETTINGS_INVALID"))
1034
+ return "WITHDRAWAL_SETTINGS_INVALID";
1035
+ if ((_x = account.holdReasons) === null || _x === void 0 ? void 0 : _x.includes("PAYMENT_RETURNED"))
1036
+ return "PAYMENT_RETURNED";
1022
1037
  if (account.hold)
1023
1038
  return "HOLD";
1024
1039
  return "DONE";
@@ -1057,6 +1072,16 @@ function usePayoutStatus(props) {
1057
1072
  url += "#3";
1058
1073
  window.history.pushState(null, "", url);
1059
1074
  };
1075
+ const onPaymentInfoClick = () => {
1076
+ let url = props.cashPayoutsPageUrl;
1077
+ url += "#4";
1078
+ window.history.pushState(null, "", url);
1079
+ };
1080
+ const onNewFormClick = () => {
1081
+ let url = props.cashPayoutsPageUrl;
1082
+ url += "#3";
1083
+ window.history.pushState(null, "", url);
1084
+ };
1060
1085
  return {
1061
1086
  states: {
1062
1087
  loading,
@@ -1070,6 +1095,8 @@ function usePayoutStatus(props) {
1070
1095
  callbacks: {
1071
1096
  onTermsClick,
1072
1097
  onClick: render,
1098
+ onPaymentInfoClick,
1099
+ onNewFormClick,
1073
1100
  },
1074
1101
  };
1075
1102
  }