@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.
@@ -3049,8 +3049,51 @@ function useIndirectTaxForm(props) {
3049
3049
  console.error("Could not detect select change");
3050
3050
  setFormState((p) => ({ ...p, [field]: value }));
3051
3051
  };
3052
- const onSubmit = async (event) => {
3052
+ async function connectPartner(formData) {
3053
3053
  var _a, _b, _c, _d, _e;
3054
+ const vars = {
3055
+ user: {
3056
+ id: user.id,
3057
+ accountId: user.accountId,
3058
+ },
3059
+ firstName: userForm.firstName,
3060
+ lastName: userForm.lastName,
3061
+ countryCode: userForm.countryCode,
3062
+ currency: userForm.currency,
3063
+ address: userForm.address,
3064
+ city: userForm.city,
3065
+ state: userForm.state,
3066
+ postalCode: userForm.postalCode,
3067
+ phoneNumber: userForm.phoneNumber,
3068
+ phoneNumberCountryCode: userForm.phoneNumberCountryCode,
3069
+ indirectTaxCountryCode: formData.selectedRegion,
3070
+ indirectTaxRegion: formData.province || formData.subRegion,
3071
+ indirectTaxId: formData.indirectTaxNumber,
3072
+ additionalTaxId: formData.qstNumber,
3073
+ withholdingTaxId: formData.subRegionTaxNumber,
3074
+ };
3075
+ const result = await connectImpactPartner({
3076
+ vars,
3077
+ });
3078
+ if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
3079
+ throw new Error();
3080
+ if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
3081
+ // Output backend errors to console for now
3082
+ console.error("Failed to create Impact connection: ", result.createImpactConnection.validationErrors);
3083
+ throw new Error();
3084
+ }
3085
+ await refetch();
3086
+ const resultPublisher = (_e = (_d = (_c = result
3087
+ .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;
3088
+ const hasValidCurrentDocument = sqmInvoiceTableView.validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
3089
+ // Fire form change event
3090
+ window.dispatchEvent(new Event(usePayoutStatus.TAX_FORM_UPDATED_EVENT_KEY));
3091
+ return {
3092
+ resultPublisher,
3093
+ hasValidCurrentDocument,
3094
+ };
3095
+ }
3096
+ const onSubmit = async (event) => {
3054
3097
  if (!option) {
3055
3098
  setErrors({ taxDetails: true });
3056
3099
  return;
@@ -3076,44 +3119,7 @@ function useIndirectTaxForm(props) {
3076
3119
  }
3077
3120
  setLoading(true);
3078
3121
  try {
3079
- const vars = {
3080
- user: {
3081
- id: user.id,
3082
- accountId: user.accountId,
3083
- },
3084
- firstName: userForm.firstName,
3085
- lastName: userForm.lastName,
3086
- countryCode: userForm.countryCode,
3087
- currency: userForm.currency,
3088
- address: userForm.address,
3089
- city: userForm.city,
3090
- state: userForm.state,
3091
- postalCode: userForm.postalCode,
3092
- phoneNumber: userForm.phoneNumber,
3093
- phoneNumberCountryCode: userForm.phoneNumberCountryCode,
3094
- indirectTaxCountryCode: formData.selectedRegion,
3095
- indirectTaxRegion: formData.province || formData.subRegion,
3096
- indirectTaxId: formData.indirectTaxNumber,
3097
- additionalTaxId: formData.qstNumber,
3098
- withholdingTaxId: formData.subRegionTaxNumber,
3099
- };
3100
- const result = await connectImpactPartner({
3101
- vars,
3102
- });
3103
- if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
3104
- throw new Error();
3105
- if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
3106
- // Output backend errors to console for now
3107
- console.error("Failed to create Impact connection: ", result.createImpactConnection
3108
- .validationErrors);
3109
- throw new Error();
3110
- }
3111
- await refetch();
3112
- const resultPublisher = (_e = (_d = (_c = result
3113
- .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;
3114
- const hasValidCurrentDocument = sqmInvoiceTableView.validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
3115
- // Fire form change event
3116
- window.dispatchEvent(new Event(usePayoutStatus.TAX_FORM_UPDATED_EVENT_KEY));
3122
+ const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
3117
3123
  if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
3118
3124
  !hasValidCurrentDocument) {
3119
3125
  // Go to docusign form
@@ -5306,51 +5312,51 @@ const TaxAndCashMonolith = class {
5306
5312
  */
5307
5313
  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}.";
5308
5314
  /**
5309
- * @uiName Account review alert header
5315
+ * @uiName Payment on hold alert header
5310
5316
  */
5311
5317
  this.dashboard_paymentOnHoldHeader = "We are reviewing your new payout settings";
5312
5318
  /**
5313
- * @uiName Account review alert description
5319
+ * @uiName Payment on hold alert description
5314
5320
  */
5315
5321
  this.dashboard_paymentOnHoldDescription = "Your payout is temporarily on hold while we review your new payment information, this process is usually resolved within 48 hours.";
5316
5322
  /**
5317
- * @uiName Account review alert header
5323
+ * @uiName Beneficiary name invalid alert header
5318
5324
  */
5319
5325
  this.dashboard_beneficiaryNameInvalidHeader = "Your payment information does not match your tax form";
5320
5326
  /**
5321
- * @uiName Account review alert description
5327
+ * @uiName Beneficiary name invalid description
5322
5328
  */
5323
5329
  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.";
5324
5330
  /**
5325
- * @uiName Account review alert header
5331
+ * @uiName Beneficiary name mismatch alert header
5326
5332
  */
5327
5333
  this.dashboard_beneficiaryNameMismatchHeader = "Your payment information does not match your tax form";
5328
5334
  /**
5329
- * @uiName Account review alert description
5335
+ * @uiName Beneficiary name mismatch alert description
5330
5336
  */
5331
5337
  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.";
5332
5338
  /**
5333
- * @uiName Account review alert header
5339
+ * @uiName Bank name mismatch alert header
5334
5340
  */
5335
5341
  this.dashboard_bankNameMismatchHeader = "Your payment information does not match your tax form";
5336
5342
  /**
5337
- * @uiName Account review alert description
5343
+ * @uiName Bank name mismatch alert description
5338
5344
  */
5339
5345
  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.";
5340
5346
  /**
5341
- * @uiName Account review alert header
5347
+ * @uiName Withdrawal settings invalid alert header
5342
5348
  */
5343
5349
  this.dashboard_withdrawalSettingsInvalidHeader = "Your payment information includes invalid characters";
5344
5350
  /**
5345
- * @uiName Account review alert description
5351
+ * @uiName Withdrawal settings invalid alert description
5346
5352
  */
5347
5353
  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.";
5348
5354
  /**
5349
- * @uiName Account review alert header
5355
+ * @uiName Payment returned alert header
5350
5356
  */
5351
5357
  this.dashboard_paymentReturnedHeader = "Payout unsuccessful";
5352
5358
  /**
5353
- * @uiName Account review alert description
5359
+ * @uiName Payment returned alert description
5354
5360
  */
5355
5361
  this.dashboard_paymentReturnedDescription = "Our recent payment attempt for your earnings was unsuccessful. Please review your payment information and make sure it is correct.";
5356
5362
  /**
@@ -7982,7 +7988,9 @@ function useUserInfoForm(props) {
7982
7988
  const countries = index_module.Fn(usePayoutStatus.SORTED_COUNTRIES_NAMESPACE);
7983
7989
  const [step, setStep] = index_module.Pn(usePayoutStatus.TAX_CONTEXT_NAMESPACE);
7984
7990
  const [userFormContext, setUserFormContext] = index_module.Pn(usePayoutStatus.USER_FORM_CONTEXT_NAMESPACE);
7985
- const { data, loading, errors: userError, } = index_module.$n(usePayoutStatus.USER_QUERY_NAMESPACE);
7991
+ const user = index_module.J();
7992
+ const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = index_module.$e(CONNECT_PARTNER);
7993
+ const { data, loading, refetch, errors: userError, } = index_module.$n(usePayoutStatus.USER_QUERY_NAMESPACE);
7986
7994
  const _currencies = index_module.Fn(usePayoutStatus.CURRENCIES_NAMESPACE);
7987
7995
  const currencies = stencilHooks_module.useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
7988
7996
  const [countrySearch, setCountrySearch] = stencilHooks_module.useState("");
@@ -8084,6 +8092,45 @@ function useUserInfoForm(props) {
8084
8092
  setFilteredCurrencies(currencies.filter((c) => c.currencyCode.toLowerCase().includes(currencySearch.toLowerCase())) || []);
8085
8093
  }
8086
8094
  }, [currencySearch, currencies]);
8095
+ async function connectPartner(formData) {
8096
+ var _a, _b, _c, _d, _e;
8097
+ const vars = {
8098
+ user: {
8099
+ id: user.id,
8100
+ accountId: user.accountId,
8101
+ },
8102
+ firstName: formData.firstName,
8103
+ lastName: formData.lastName,
8104
+ countryCode: formData.countryCode,
8105
+ currency: formData.currency,
8106
+ address: formData.address,
8107
+ city: formData.city,
8108
+ state: formData.state,
8109
+ postalCode: formData.postalCode,
8110
+ phoneNumber: formData.phoneNumber,
8111
+ phoneNumberCountryCode: formData.phoneNumberCountryCode,
8112
+ };
8113
+ const result = await connectImpactPartner({
8114
+ vars,
8115
+ });
8116
+ if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
8117
+ throw new Error();
8118
+ if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
8119
+ // Output backend errors to console for now
8120
+ console.error("Failed to create Impact connection: ", result.createImpactConnection.validationErrors);
8121
+ throw new Error();
8122
+ }
8123
+ await refetch();
8124
+ const resultPublisher = (_e = (_d = (_c = result
8125
+ .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;
8126
+ const hasValidCurrentDocument = sqmInvoiceTableView.validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
8127
+ // Fire form change event
8128
+ window.dispatchEvent(new Event(usePayoutStatus.TAX_FORM_UPDATED_EVENT_KEY));
8129
+ return {
8130
+ resultPublisher,
8131
+ hasValidCurrentDocument,
8132
+ };
8133
+ }
8087
8134
  async function onSubmit(event) {
8088
8135
  let formControls = event.target.getFormControls();
8089
8136
  let formData = {};
@@ -8128,6 +8175,31 @@ function useUserInfoForm(props) {
8128
8175
  });
8129
8176
  const skipNextStep = getSkipNextStep(userData);
8130
8177
  console.log({ skipNextStep });
8178
+ if (skipNextStep) {
8179
+ try {
8180
+ const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
8181
+ if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
8182
+ !hasValidCurrentDocument) {
8183
+ // Go to docusign form
8184
+ setStep("/3");
8185
+ }
8186
+ else {
8187
+ if (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.brandedSignup) {
8188
+ // Go to banking information form
8189
+ setStep("/4");
8190
+ }
8191
+ else {
8192
+ // Go right to the dashboard
8193
+ setStep("/dashboard");
8194
+ }
8195
+ }
8196
+ return;
8197
+ }
8198
+ catch (e) {
8199
+ setErrors({ general: true });
8200
+ return;
8201
+ }
8202
+ }
8131
8203
  const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
8132
8204
  setStep(nextStep);
8133
8205
  }
@@ -8169,9 +8241,9 @@ function useUserInfoForm(props) {
8169
8241
  step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
8170
8242
  hideState: !hasStates,
8171
8243
  hideSteps: !!context.hideSteps,
8172
- disabled: loading,
8244
+ disabled: loading || connectLoading,
8173
8245
  loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
8174
- loading: loading,
8246
+ loading: loading || connectLoading,
8175
8247
  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),
8176
8248
  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),
8177
8249
  formState: {
@@ -6,7 +6,7 @@ import { COUNTRIES_QUERY_NAMESPACE, TAX_CONTEXT_NAMESPACE, TAX_FORM_CONTEXT_NAME
6
6
  import { INDIRECT_TAX_PROVINCES, INDIRECT_TAX_SPAIN_REGIONS, } from "../subregions";
7
7
  import { getCountryObj, validTaxDocument } from "../utils";
8
8
  import { TAX_FORM_UPDATED_EVENT_KEY } from "../eventKeys";
9
- const CONNECT_PARTNER = gql `
9
+ export const CONNECT_PARTNER = gql `
10
10
  mutation createImpactConnection($vars: ImpactConnectionInput!) {
11
11
  createImpactConnection(impactConnectionInput: $vars) {
12
12
  success
@@ -111,8 +111,51 @@ export function useIndirectTaxForm(props) {
111
111
  console.error("Could not detect select change");
112
112
  setFormState((p) => ({ ...p, [field]: value }));
113
113
  };
114
- const onSubmit = async (event) => {
114
+ async function connectPartner(formData) {
115
115
  var _a, _b, _c, _d, _e;
116
+ const vars = {
117
+ user: {
118
+ id: user.id,
119
+ accountId: user.accountId,
120
+ },
121
+ firstName: userForm.firstName,
122
+ lastName: userForm.lastName,
123
+ countryCode: userForm.countryCode,
124
+ currency: userForm.currency,
125
+ address: userForm.address,
126
+ city: userForm.city,
127
+ state: userForm.state,
128
+ postalCode: userForm.postalCode,
129
+ phoneNumber: userForm.phoneNumber,
130
+ phoneNumberCountryCode: userForm.phoneNumberCountryCode,
131
+ indirectTaxCountryCode: formData.selectedRegion,
132
+ indirectTaxRegion: formData.province || formData.subRegion,
133
+ indirectTaxId: formData.indirectTaxNumber,
134
+ additionalTaxId: formData.qstNumber,
135
+ withholdingTaxId: formData.subRegionTaxNumber,
136
+ };
137
+ const result = await connectImpactPartner({
138
+ vars,
139
+ });
140
+ if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
141
+ throw new Error();
142
+ if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
143
+ // Output backend errors to console for now
144
+ console.error("Failed to create Impact connection: ", result.createImpactConnection.validationErrors);
145
+ throw new Error();
146
+ }
147
+ await refetch();
148
+ const resultPublisher = (_e = (_d = (_c = result
149
+ .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;
150
+ const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
151
+ // Fire form change event
152
+ window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
153
+ return {
154
+ resultPublisher,
155
+ hasValidCurrentDocument,
156
+ };
157
+ }
158
+ const onSubmit = async (event) => {
116
159
  if (!option) {
117
160
  setErrors({ taxDetails: true });
118
161
  return;
@@ -138,44 +181,7 @@ export function useIndirectTaxForm(props) {
138
181
  }
139
182
  setLoading(true);
140
183
  try {
141
- const vars = {
142
- user: {
143
- id: user.id,
144
- accountId: user.accountId,
145
- },
146
- firstName: userForm.firstName,
147
- lastName: userForm.lastName,
148
- countryCode: userForm.countryCode,
149
- currency: userForm.currency,
150
- address: userForm.address,
151
- city: userForm.city,
152
- state: userForm.state,
153
- postalCode: userForm.postalCode,
154
- phoneNumber: userForm.phoneNumber,
155
- phoneNumberCountryCode: userForm.phoneNumberCountryCode,
156
- indirectTaxCountryCode: formData.selectedRegion,
157
- indirectTaxRegion: formData.province || formData.subRegion,
158
- indirectTaxId: formData.indirectTaxNumber,
159
- additionalTaxId: formData.qstNumber,
160
- withholdingTaxId: formData.subRegionTaxNumber,
161
- };
162
- const result = await connectImpactPartner({
163
- vars,
164
- });
165
- if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
166
- throw new Error();
167
- if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
168
- // Output backend errors to console for now
169
- console.error("Failed to create Impact connection: ", result.createImpactConnection
170
- .validationErrors);
171
- throw new Error();
172
- }
173
- await refetch();
174
- const resultPublisher = (_e = (_d = (_c = result
175
- .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;
176
- const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
177
- // Fire form change event
178
- window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
184
+ const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
179
185
  if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
180
186
  !hasValidCurrentDocument) {
181
187
  // Go to docusign form
@@ -941,51 +941,51 @@ export class TaxAndCashMonolith {
941
941
  */
942
942
  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}.";
943
943
  /**
944
- * @uiName Account review alert header
944
+ * @uiName Payment on hold alert header
945
945
  */
946
946
  this.dashboard_paymentOnHoldHeader = "We are reviewing your new payout settings";
947
947
  /**
948
- * @uiName Account review alert description
948
+ * @uiName Payment on hold alert description
949
949
  */
950
950
  this.dashboard_paymentOnHoldDescription = "Your payout is temporarily on hold while we review your new payment information, this process is usually resolved within 48 hours.";
951
951
  /**
952
- * @uiName Account review alert header
952
+ * @uiName Beneficiary name invalid alert header
953
953
  */
954
954
  this.dashboard_beneficiaryNameInvalidHeader = "Your payment information does not match your tax form";
955
955
  /**
956
- * @uiName Account review alert description
956
+ * @uiName Beneficiary name invalid description
957
957
  */
958
958
  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.";
959
959
  /**
960
- * @uiName Account review alert header
960
+ * @uiName Beneficiary name mismatch alert header
961
961
  */
962
962
  this.dashboard_beneficiaryNameMismatchHeader = "Your payment information does not match your tax form";
963
963
  /**
964
- * @uiName Account review alert description
964
+ * @uiName Beneficiary name mismatch alert description
965
965
  */
966
966
  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.";
967
967
  /**
968
- * @uiName Account review alert header
968
+ * @uiName Bank name mismatch alert header
969
969
  */
970
970
  this.dashboard_bankNameMismatchHeader = "Your payment information does not match your tax form";
971
971
  /**
972
- * @uiName Account review alert description
972
+ * @uiName Bank name mismatch alert description
973
973
  */
974
974
  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.";
975
975
  /**
976
- * @uiName Account review alert header
976
+ * @uiName Withdrawal settings invalid alert header
977
977
  */
978
978
  this.dashboard_withdrawalSettingsInvalidHeader = "Your payment information includes invalid characters";
979
979
  /**
980
- * @uiName Account review alert description
980
+ * @uiName Withdrawal settings invalid alert description
981
981
  */
982
982
  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.";
983
983
  /**
984
- * @uiName Account review alert header
984
+ * @uiName Payment returned alert header
985
985
  */
986
986
  this.dashboard_paymentReturnedHeader = "Payout unsuccessful";
987
987
  /**
988
- * @uiName Account review alert description
988
+ * @uiName Payment returned alert description
989
989
  */
990
990
  this.dashboard_paymentReturnedDescription = "Our recent payment attempt for your earnings was unsuccessful. Please review your payment information and make sure it is correct.";
991
991
  /**
@@ -5068,7 +5068,7 @@ export class TaxAndCashMonolith {
5068
5068
  "optional": false,
5069
5069
  "docs": {
5070
5070
  "tags": [{
5071
- "text": "Account review alert header",
5071
+ "text": "Payment on hold alert header",
5072
5072
  "name": "uiName"
5073
5073
  }],
5074
5074
  "text": ""
@@ -5089,7 +5089,7 @@ export class TaxAndCashMonolith {
5089
5089
  "optional": false,
5090
5090
  "docs": {
5091
5091
  "tags": [{
5092
- "text": "Account review alert description",
5092
+ "text": "Payment on hold alert description",
5093
5093
  "name": "uiName"
5094
5094
  }],
5095
5095
  "text": ""
@@ -5110,7 +5110,7 @@ export class TaxAndCashMonolith {
5110
5110
  "optional": false,
5111
5111
  "docs": {
5112
5112
  "tags": [{
5113
- "text": "Account review alert header",
5113
+ "text": "Beneficiary name invalid alert header",
5114
5114
  "name": "uiName"
5115
5115
  }],
5116
5116
  "text": ""
@@ -5131,7 +5131,7 @@ export class TaxAndCashMonolith {
5131
5131
  "optional": false,
5132
5132
  "docs": {
5133
5133
  "tags": [{
5134
- "text": "Account review alert description",
5134
+ "text": "Beneficiary name invalid description",
5135
5135
  "name": "uiName"
5136
5136
  }],
5137
5137
  "text": ""
@@ -5152,7 +5152,7 @@ export class TaxAndCashMonolith {
5152
5152
  "optional": false,
5153
5153
  "docs": {
5154
5154
  "tags": [{
5155
- "text": "Account review alert header",
5155
+ "text": "Beneficiary name mismatch alert header",
5156
5156
  "name": "uiName"
5157
5157
  }],
5158
5158
  "text": ""
@@ -5173,7 +5173,7 @@ export class TaxAndCashMonolith {
5173
5173
  "optional": false,
5174
5174
  "docs": {
5175
5175
  "tags": [{
5176
- "text": "Account review alert description",
5176
+ "text": "Beneficiary name mismatch alert description",
5177
5177
  "name": "uiName"
5178
5178
  }],
5179
5179
  "text": ""
@@ -5194,7 +5194,7 @@ export class TaxAndCashMonolith {
5194
5194
  "optional": false,
5195
5195
  "docs": {
5196
5196
  "tags": [{
5197
- "text": "Account review alert header",
5197
+ "text": "Bank name mismatch alert header",
5198
5198
  "name": "uiName"
5199
5199
  }],
5200
5200
  "text": ""
@@ -5215,7 +5215,7 @@ export class TaxAndCashMonolith {
5215
5215
  "optional": false,
5216
5216
  "docs": {
5217
5217
  "tags": [{
5218
- "text": "Account review alert description",
5218
+ "text": "Bank name mismatch alert description",
5219
5219
  "name": "uiName"
5220
5220
  }],
5221
5221
  "text": ""
@@ -5236,7 +5236,7 @@ export class TaxAndCashMonolith {
5236
5236
  "optional": false,
5237
5237
  "docs": {
5238
5238
  "tags": [{
5239
- "text": "Account review alert header",
5239
+ "text": "Withdrawal settings invalid alert header",
5240
5240
  "name": "uiName"
5241
5241
  }],
5242
5242
  "text": ""
@@ -5257,7 +5257,7 @@ export class TaxAndCashMonolith {
5257
5257
  "optional": false,
5258
5258
  "docs": {
5259
5259
  "tags": [{
5260
- "text": "Account review alert description",
5260
+ "text": "Withdrawal settings invalid alert description",
5261
5261
  "name": "uiName"
5262
5262
  }],
5263
5263
  "text": ""
@@ -5278,7 +5278,7 @@ export class TaxAndCashMonolith {
5278
5278
  "optional": false,
5279
5279
  "docs": {
5280
5280
  "tags": [{
5281
- "text": "Account review alert header",
5281
+ "text": "Payment returned alert header",
5282
5282
  "name": "uiName"
5283
5283
  }],
5284
5284
  "text": ""
@@ -5299,7 +5299,7 @@ export class TaxAndCashMonolith {
5299
5299
  "optional": false,
5300
5300
  "docs": {
5301
5301
  "tags": [{
5302
- "text": "Account review alert description",
5302
+ "text": "Payment returned alert description",
5303
5303
  "name": "uiName"
5304
5304
  }],
5305
5305
  "text": ""
@@ -1,9 +1,11 @@
1
1
  import { useEffect, useMemo, useRef, useState, } from "@saasquatch/universal-hooks";
2
2
  import jsonpointer from "jsonpointer";
3
3
  import { CURRENCIES_NAMESPACE, SORTED_COUNTRIES_NAMESPACE, TAX_CONTEXT_NAMESPACE, TAX_FORM_CONTEXT_NAMESPACE, USER_FORM_CONTEXT_NAMESPACE, USER_QUERY_NAMESPACE, } from "../sqm-tax-and-cash/data";
4
- import { objectIsFull } from "../utils";
5
- import { useParent, useParentQueryValue, useParentValue, } from "@saasquatch/component-boilerplate";
4
+ import { objectIsFull, validTaxDocument } from "../utils";
5
+ import { useMutation, useParent, useParentQueryValue, useParentValue, useUserIdentity, } from "@saasquatch/component-boilerplate";
6
6
  import { ADDRESS_REGIONS } from "../subregions";
7
+ import { CONNECT_PARTNER, } from "../sqm-indirect-tax-form/useIndirectTaxForm";
8
+ import { TAX_FORM_UPDATED_EVENT_KEY } from "../eventKeys";
7
9
  export function useUserInfoForm(props) {
8
10
  var _a, _b, _c, _d, _e, _f;
9
11
  const currencyRef = useRef(undefined);
@@ -13,7 +15,9 @@ export function useUserInfoForm(props) {
13
15
  const countries = useParentValue(SORTED_COUNTRIES_NAMESPACE);
14
16
  const [step, setStep] = useParent(TAX_CONTEXT_NAMESPACE);
15
17
  const [userFormContext, setUserFormContext] = useParent(USER_FORM_CONTEXT_NAMESPACE);
16
- const { data, loading, errors: userError, } = useParentQueryValue(USER_QUERY_NAMESPACE);
18
+ const user = useUserIdentity();
19
+ const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = useMutation(CONNECT_PARTNER);
20
+ const { data, loading, refetch, errors: userError, } = useParentQueryValue(USER_QUERY_NAMESPACE);
17
21
  const _currencies = useParentValue(CURRENCIES_NAMESPACE);
18
22
  const currencies = useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
19
23
  const [countrySearch, setCountrySearch] = useState("");
@@ -115,6 +119,45 @@ export function useUserInfoForm(props) {
115
119
  setFilteredCurrencies(currencies.filter((c) => c.currencyCode.toLowerCase().includes(currencySearch.toLowerCase())) || []);
116
120
  }
117
121
  }, [currencySearch, currencies]);
122
+ async function connectPartner(formData) {
123
+ var _a, _b, _c, _d, _e;
124
+ const vars = {
125
+ user: {
126
+ id: user.id,
127
+ accountId: user.accountId,
128
+ },
129
+ firstName: formData.firstName,
130
+ lastName: formData.lastName,
131
+ countryCode: formData.countryCode,
132
+ currency: formData.currency,
133
+ address: formData.address,
134
+ city: formData.city,
135
+ state: formData.state,
136
+ postalCode: formData.postalCode,
137
+ phoneNumber: formData.phoneNumber,
138
+ phoneNumberCountryCode: formData.phoneNumberCountryCode,
139
+ };
140
+ const result = await connectImpactPartner({
141
+ vars,
142
+ });
143
+ if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
144
+ throw new Error();
145
+ if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
146
+ // Output backend errors to console for now
147
+ console.error("Failed to create Impact connection: ", result.createImpactConnection.validationErrors);
148
+ throw new Error();
149
+ }
150
+ await refetch();
151
+ const resultPublisher = (_e = (_d = (_c = result
152
+ .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;
153
+ const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
154
+ // Fire form change event
155
+ window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
156
+ return {
157
+ resultPublisher,
158
+ hasValidCurrentDocument,
159
+ };
160
+ }
118
161
  async function onSubmit(event) {
119
162
  let formControls = event.target.getFormControls();
120
163
  let formData = {};
@@ -159,6 +202,31 @@ export function useUserInfoForm(props) {
159
202
  });
160
203
  const skipNextStep = getSkipNextStep(userData);
161
204
  console.log({ skipNextStep });
205
+ if (skipNextStep) {
206
+ try {
207
+ const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
208
+ if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
209
+ !hasValidCurrentDocument) {
210
+ // Go to docusign form
211
+ setStep("/3");
212
+ }
213
+ else {
214
+ if (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.brandedSignup) {
215
+ // Go to banking information form
216
+ setStep("/4");
217
+ }
218
+ else {
219
+ // Go right to the dashboard
220
+ setStep("/dashboard");
221
+ }
222
+ }
223
+ return;
224
+ }
225
+ catch (e) {
226
+ setErrors({ general: true });
227
+ return;
228
+ }
229
+ }
162
230
  const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
163
231
  setStep(nextStep);
164
232
  }
@@ -207,9 +275,9 @@ export function useUserInfoForm(props) {
207
275
  step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
208
276
  hideState: !hasStates,
209
277
  hideSteps: !!context.hideSteps,
210
- disabled: loading,
278
+ disabled: loading || connectLoading,
211
279
  loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
212
- loading: loading,
280
+ loading: loading || connectLoading,
213
281
  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),
214
282
  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),
215
283
  formState: {