@saasquatch/mint-components 1.15.5-0 → 1.15.5-3

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.
@@ -3045,8 +3045,51 @@ function useIndirectTaxForm(props) {
3045
3045
  console.error("Could not detect select change");
3046
3046
  setFormState((p) => ({ ...p, [field]: value }));
3047
3047
  };
3048
- const onSubmit = async (event) => {
3048
+ async function connectPartner(formData) {
3049
3049
  var _a, _b, _c, _d, _e;
3050
+ const vars = {
3051
+ user: {
3052
+ id: user.id,
3053
+ accountId: user.accountId,
3054
+ },
3055
+ firstName: userForm.firstName,
3056
+ lastName: userForm.lastName,
3057
+ countryCode: userForm.countryCode,
3058
+ currency: userForm.currency,
3059
+ address: userForm.address,
3060
+ city: userForm.city,
3061
+ state: userForm.state,
3062
+ postalCode: userForm.postalCode,
3063
+ phoneNumber: userForm.phoneNumber,
3064
+ phoneNumberCountryCode: userForm.phoneNumberCountryCode,
3065
+ indirectTaxCountryCode: formData.selectedRegion,
3066
+ indirectTaxRegion: formData.province || formData.subRegion,
3067
+ indirectTaxId: formData.indirectTaxNumber,
3068
+ additionalTaxId: formData.qstNumber,
3069
+ withholdingTaxId: formData.subRegionTaxNumber,
3070
+ };
3071
+ const result = await connectImpactPartner({
3072
+ vars,
3073
+ });
3074
+ if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
3075
+ throw new Error();
3076
+ if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
3077
+ // Output backend errors to console for now
3078
+ console.error("Failed to create Impact connection: ", result.createImpactConnection.validationErrors);
3079
+ throw new Error();
3080
+ }
3081
+ await refetch();
3082
+ const resultPublisher = (_e = (_d = (_c = result
3083
+ .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;
3084
+ const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
3085
+ // Fire form change event
3086
+ window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
3087
+ return {
3088
+ resultPublisher,
3089
+ hasValidCurrentDocument,
3090
+ };
3091
+ }
3092
+ const onSubmit = async (event) => {
3050
3093
  if (!option) {
3051
3094
  setErrors({ taxDetails: true });
3052
3095
  return;
@@ -3072,44 +3115,7 @@ function useIndirectTaxForm(props) {
3072
3115
  }
3073
3116
  setLoading(true);
3074
3117
  try {
3075
- const vars = {
3076
- user: {
3077
- id: user.id,
3078
- accountId: user.accountId,
3079
- },
3080
- firstName: userForm.firstName,
3081
- lastName: userForm.lastName,
3082
- countryCode: userForm.countryCode,
3083
- currency: userForm.currency,
3084
- address: userForm.address,
3085
- city: userForm.city,
3086
- state: userForm.state,
3087
- postalCode: userForm.postalCode,
3088
- phoneNumber: userForm.phoneNumber,
3089
- phoneNumberCountryCode: userForm.phoneNumberCountryCode,
3090
- indirectTaxCountryCode: formData.selectedRegion,
3091
- indirectTaxRegion: formData.province || formData.subRegion,
3092
- indirectTaxId: formData.indirectTaxNumber,
3093
- additionalTaxId: formData.qstNumber,
3094
- withholdingTaxId: formData.subRegionTaxNumber,
3095
- };
3096
- const result = await connectImpactPartner({
3097
- vars,
3098
- });
3099
- if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
3100
- throw new Error();
3101
- if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
3102
- // Output backend errors to console for now
3103
- console.error("Failed to create Impact connection: ", result.createImpactConnection
3104
- .validationErrors);
3105
- throw new Error();
3106
- }
3107
- await refetch();
3108
- const resultPublisher = (_e = (_d = (_c = result
3109
- .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;
3110
- const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
3111
- // Fire form change event
3112
- window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
3118
+ const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
3113
3119
  if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
3114
3120
  !hasValidCurrentDocument) {
3115
3121
  // Go to docusign form
@@ -5302,51 +5308,51 @@ const TaxAndCashMonolith = class {
5302
5308
  */
5303
5309
  this.dashboard_accountReviewDescription = "This process takes 48 hours, payouts are on hold until it's completed. You will receive an email from our referral provider, Impact.com, if any issues arise. It contains details on how to resolve this issue. If you need further assistance, please reach out to our {supportLink}.";
5304
5310
  /**
5305
- * @uiName Account review alert header
5311
+ * @uiName Payment on hold alert header
5306
5312
  */
5307
5313
  this.dashboard_paymentOnHoldHeader = "We are reviewing your new payout settings";
5308
5314
  /**
5309
- * @uiName Account review alert description
5315
+ * @uiName Payment on hold alert description
5310
5316
  */
5311
5317
  this.dashboard_paymentOnHoldDescription = "Your payout is temporarily on hold while we review your new payment information, this process is usually resolved within 48 hours.";
5312
5318
  /**
5313
- * @uiName Account review alert header
5319
+ * @uiName Beneficiary name invalid alert header
5314
5320
  */
5315
5321
  this.dashboard_beneficiaryNameInvalidHeader = "Your payment information does not match your tax form";
5316
5322
  /**
5317
- * @uiName Account review alert description
5323
+ * @uiName Beneficiary name invalid description
5318
5324
  */
5319
5325
  this.dashboard_beneficiaryNameInvalidDescription = "The beneficiary name in your payment information does not match what was submitted in your tax form. Please review and update your payment information or tax form so that they match exactly and do not include any invalid characters. Your payouts are on hold until this is resolved.";
5320
5326
  /**
5321
- * @uiName Account review alert header
5327
+ * @uiName Beneficiary name mismatch alert header
5322
5328
  */
5323
5329
  this.dashboard_beneficiaryNameMismatchHeader = "Your payment information does not match your tax form";
5324
5330
  /**
5325
- * @uiName Account review alert description
5331
+ * @uiName Beneficiary name mismatch alert description
5326
5332
  */
5327
5333
  this.dashboard_beneficiaryNameMismatchDescription = "The beneficiary name in your payment information does not match what was submitted in your tax form. Please review and update your payment information or tax form so that they match exactly and do not include any invalid characters. Your payouts are on hold until this is resolved.";
5328
5334
  /**
5329
- * @uiName Account review alert header
5335
+ * @uiName Bank name mismatch alert header
5330
5336
  */
5331
5337
  this.dashboard_bankNameMismatchHeader = "Your payment information does not match your tax form";
5332
5338
  /**
5333
- * @uiName Account review alert description
5339
+ * @uiName Bank name mismatch alert description
5334
5340
  */
5335
5341
  this.dashboard_bankNameMismatchDescription = "The bank name in your payment information does not match what was submitted in your tax form. Please review and update your payment information or tax form so that they match exactly and do not include any invalid characters. Your payouts are on hold until this is resolved.";
5336
5342
  /**
5337
- * @uiName Account review alert header
5343
+ * @uiName Withdrawal settings invalid alert header
5338
5344
  */
5339
5345
  this.dashboard_withdrawalSettingsInvalidHeader = "Your payment information includes invalid characters";
5340
5346
  /**
5341
- * @uiName Account review alert description
5347
+ * @uiName Withdrawal settings invalid alert description
5342
5348
  */
5343
5349
  this.dashboard_withdrawalSettingsInvalidDescription = "There are invalid characters in your payment information. Please review your information and make sure it is correct with no invalid characters. Your payouts are on hold until this is resolved.";
5344
5350
  /**
5345
- * @uiName Account review alert header
5351
+ * @uiName Payment returned alert header
5346
5352
  */
5347
5353
  this.dashboard_paymentReturnedHeader = "Payout unsuccessful";
5348
5354
  /**
5349
- * @uiName Account review alert description
5355
+ * @uiName Payment returned alert description
5350
5356
  */
5351
5357
  this.dashboard_paymentReturnedDescription = "Our recent payment attempt for your earnings was unsuccessful. Please review your payment information and make sure it is correct.";
5352
5358
  /**
@@ -7978,7 +7984,9 @@ function useUserInfoForm(props) {
7978
7984
  const countries = Fn(SORTED_COUNTRIES_NAMESPACE);
7979
7985
  const [step, setStep] = Pn(TAX_CONTEXT_NAMESPACE);
7980
7986
  const [userFormContext, setUserFormContext] = Pn(USER_FORM_CONTEXT_NAMESPACE);
7981
- const { data, loading, errors: userError, } = $n(USER_QUERY_NAMESPACE);
7987
+ const user = J();
7988
+ const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = $e(CONNECT_PARTNER);
7989
+ const { data, loading, refetch, errors: userError, } = $n(USER_QUERY_NAMESPACE);
7982
7990
  const _currencies = Fn(CURRENCIES_NAMESPACE);
7983
7991
  const currencies = useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
7984
7992
  const [countrySearch, setCountrySearch] = useState("");
@@ -8080,6 +8088,45 @@ function useUserInfoForm(props) {
8080
8088
  setFilteredCurrencies(currencies.filter((c) => c.currencyCode.toLowerCase().includes(currencySearch.toLowerCase())) || []);
8081
8089
  }
8082
8090
  }, [currencySearch, currencies]);
8091
+ async function connectPartner(formData) {
8092
+ var _a, _b, _c, _d, _e;
8093
+ const vars = {
8094
+ user: {
8095
+ id: user.id,
8096
+ accountId: user.accountId,
8097
+ },
8098
+ firstName: formData.firstName,
8099
+ lastName: formData.lastName,
8100
+ countryCode: formData.countryCode,
8101
+ currency: formData.currency,
8102
+ address: formData.address,
8103
+ city: formData.city,
8104
+ state: formData.state,
8105
+ postalCode: formData.postalCode,
8106
+ phoneNumber: formData.phoneNumber,
8107
+ phoneNumberCountryCode: formData.phoneNumberCountryCode,
8108
+ };
8109
+ const result = await connectImpactPartner({
8110
+ vars,
8111
+ });
8112
+ if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
8113
+ throw new Error();
8114
+ if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
8115
+ // Output backend errors to console for now
8116
+ console.error("Failed to create Impact connection: ", result.createImpactConnection.validationErrors);
8117
+ throw new Error();
8118
+ }
8119
+ await refetch();
8120
+ const resultPublisher = (_e = (_d = (_c = result
8121
+ .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;
8122
+ const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
8123
+ // Fire form change event
8124
+ window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
8125
+ return {
8126
+ resultPublisher,
8127
+ hasValidCurrentDocument,
8128
+ };
8129
+ }
8083
8130
  async function onSubmit(event) {
8084
8131
  let formControls = event.target.getFormControls();
8085
8132
  let formData = {};
@@ -8124,6 +8171,31 @@ function useUserInfoForm(props) {
8124
8171
  });
8125
8172
  const skipNextStep = getSkipNextStep(userData);
8126
8173
  console.log({ skipNextStep });
8174
+ if (skipNextStep) {
8175
+ try {
8176
+ const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
8177
+ if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
8178
+ !hasValidCurrentDocument) {
8179
+ // Go to docusign form
8180
+ setStep("/3");
8181
+ }
8182
+ else {
8183
+ if (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.brandedSignup) {
8184
+ // Go to banking information form
8185
+ setStep("/4");
8186
+ }
8187
+ else {
8188
+ // Go right to the dashboard
8189
+ setStep("/dashboard");
8190
+ }
8191
+ }
8192
+ return;
8193
+ }
8194
+ catch (e) {
8195
+ setErrors({ general: true });
8196
+ return;
8197
+ }
8198
+ }
8127
8199
  const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
8128
8200
  setStep(nextStep);
8129
8201
  }
@@ -8165,9 +8237,9 @@ function useUserInfoForm(props) {
8165
8237
  step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
8166
8238
  hideState: !hasStates,
8167
8239
  hideSteps: !!context.hideSteps,
8168
- disabled: loading,
8240
+ disabled: loading || connectLoading,
8169
8241
  loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
8170
- loading: loading,
8242
+ loading: loading || connectLoading,
8171
8243
  isPartner: !!((_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.publisher),
8172
8244
  isUser: !!((_f = (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.user),
8173
8245
  formState: {