@saasquatch/mint-components 1.15.5-0 → 1.15.5-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.
- package/dist/cjs/sqm-banking-info-form_17.cjs.entry.js +125 -54
- package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.js +47 -40
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +24 -24
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +71 -5
- package/dist/esm/sqm-banking-info-form_17.entry.js +125 -54
- package/dist/esm-es5/sqm-banking-info-form_17.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-37996351.system.js +1 -1
- package/dist/mint-components/p-ba14b5f7.system.entry.js +1 -0
- package/dist/mint-components/{p-28131538.entry.js → p-d0b404d5.entry.js} +2 -2
- package/dist/types/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.d.ts +31 -0
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.d.ts +12 -12
- package/dist/types/components.d.ts +24 -24
- package/docs/docs.docx +0 -0
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/mint-components/p-b24fae32.system.entry.js +0 -1
- package/dist/types/global/android.d.ts +0 -7
- package/dist/types/global/demo.d.ts +0 -2
- package/dist/types/stories/features.d.ts +0 -4
- package/dist/types/stories/templates.d.ts +0 -4
|
@@ -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
|
-
|
|
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
|
|
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
|
|
@@ -3164,6 +3170,7 @@ function useIndirectTaxForm(props) {
|
|
|
3164
3170
|
...p,
|
|
3165
3171
|
hasSubRegionTaxNumber: !p.hasSubRegionTaxNumber,
|
|
3166
3172
|
})),
|
|
3173
|
+
connectPartner,
|
|
3167
3174
|
},
|
|
3168
3175
|
data: {
|
|
3169
3176
|
esRegions: sqmInvoiceTableView.INDIRECT_TAX_SPAIN_REGIONS,
|
|
@@ -5306,51 +5313,51 @@ const TaxAndCashMonolith = class {
|
|
|
5306
5313
|
*/
|
|
5307
5314
|
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
5315
|
/**
|
|
5309
|
-
* @uiName
|
|
5316
|
+
* @uiName Payment on hold alert header
|
|
5310
5317
|
*/
|
|
5311
5318
|
this.dashboard_paymentOnHoldHeader = "We are reviewing your new payout settings";
|
|
5312
5319
|
/**
|
|
5313
|
-
* @uiName
|
|
5320
|
+
* @uiName Payment on hold alert description
|
|
5314
5321
|
*/
|
|
5315
5322
|
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
5323
|
/**
|
|
5317
|
-
* @uiName
|
|
5324
|
+
* @uiName Beneficiary name invalid alert header
|
|
5318
5325
|
*/
|
|
5319
5326
|
this.dashboard_beneficiaryNameInvalidHeader = "Your payment information does not match your tax form";
|
|
5320
5327
|
/**
|
|
5321
|
-
* @uiName
|
|
5328
|
+
* @uiName Beneficiary name invalid description
|
|
5322
5329
|
*/
|
|
5323
5330
|
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
5331
|
/**
|
|
5325
|
-
* @uiName
|
|
5332
|
+
* @uiName Beneficiary name mismatch alert header
|
|
5326
5333
|
*/
|
|
5327
5334
|
this.dashboard_beneficiaryNameMismatchHeader = "Your payment information does not match your tax form";
|
|
5328
5335
|
/**
|
|
5329
|
-
* @uiName
|
|
5336
|
+
* @uiName Beneficiary name mismatch alert description
|
|
5330
5337
|
*/
|
|
5331
5338
|
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
5339
|
/**
|
|
5333
|
-
* @uiName
|
|
5340
|
+
* @uiName Bank name mismatch alert header
|
|
5334
5341
|
*/
|
|
5335
5342
|
this.dashboard_bankNameMismatchHeader = "Your payment information does not match your tax form";
|
|
5336
5343
|
/**
|
|
5337
|
-
* @uiName
|
|
5344
|
+
* @uiName Bank name mismatch alert description
|
|
5338
5345
|
*/
|
|
5339
5346
|
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
5347
|
/**
|
|
5341
|
-
* @uiName
|
|
5348
|
+
* @uiName Withdrawal settings invalid alert header
|
|
5342
5349
|
*/
|
|
5343
5350
|
this.dashboard_withdrawalSettingsInvalidHeader = "Your payment information includes invalid characters";
|
|
5344
5351
|
/**
|
|
5345
|
-
* @uiName
|
|
5352
|
+
* @uiName Withdrawal settings invalid alert description
|
|
5346
5353
|
*/
|
|
5347
5354
|
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
5355
|
/**
|
|
5349
|
-
* @uiName
|
|
5356
|
+
* @uiName Payment returned alert header
|
|
5350
5357
|
*/
|
|
5351
5358
|
this.dashboard_paymentReturnedHeader = "Payout unsuccessful";
|
|
5352
5359
|
/**
|
|
5353
|
-
* @uiName
|
|
5360
|
+
* @uiName Payment returned alert description
|
|
5354
5361
|
*/
|
|
5355
5362
|
this.dashboard_paymentReturnedDescription = "Our recent payment attempt for your earnings was unsuccessful. Please review your payment information and make sure it is correct.";
|
|
5356
5363
|
/**
|
|
@@ -7982,7 +7989,9 @@ function useUserInfoForm(props) {
|
|
|
7982
7989
|
const countries = index_module.Fn(usePayoutStatus.SORTED_COUNTRIES_NAMESPACE);
|
|
7983
7990
|
const [step, setStep] = index_module.Pn(usePayoutStatus.TAX_CONTEXT_NAMESPACE);
|
|
7984
7991
|
const [userFormContext, setUserFormContext] = index_module.Pn(usePayoutStatus.USER_FORM_CONTEXT_NAMESPACE);
|
|
7985
|
-
const
|
|
7992
|
+
const user = index_module.J();
|
|
7993
|
+
const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = index_module.$e(CONNECT_PARTNER);
|
|
7994
|
+
const { data, loading, refetch, errors: userError, } = index_module.$n(usePayoutStatus.USER_QUERY_NAMESPACE);
|
|
7986
7995
|
const _currencies = index_module.Fn(usePayoutStatus.CURRENCIES_NAMESPACE);
|
|
7987
7996
|
const currencies = stencilHooks_module.useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
|
|
7988
7997
|
const [countrySearch, setCountrySearch] = stencilHooks_module.useState("");
|
|
@@ -8084,6 +8093,45 @@ function useUserInfoForm(props) {
|
|
|
8084
8093
|
setFilteredCurrencies(currencies.filter((c) => c.currencyCode.toLowerCase().includes(currencySearch.toLowerCase())) || []);
|
|
8085
8094
|
}
|
|
8086
8095
|
}, [currencySearch, currencies]);
|
|
8096
|
+
async function connectPartner(formData) {
|
|
8097
|
+
var _a, _b, _c, _d, _e;
|
|
8098
|
+
const vars = {
|
|
8099
|
+
user: {
|
|
8100
|
+
id: user.id,
|
|
8101
|
+
accountId: user.accountId,
|
|
8102
|
+
},
|
|
8103
|
+
firstName: formData.firstName,
|
|
8104
|
+
lastName: formData.lastName,
|
|
8105
|
+
countryCode: formData.countryCode,
|
|
8106
|
+
currency: formData.currency,
|
|
8107
|
+
address: formData.address,
|
|
8108
|
+
city: formData.city,
|
|
8109
|
+
state: formData.state,
|
|
8110
|
+
postalCode: formData.postalCode,
|
|
8111
|
+
phoneNumber: formData.phoneNumber,
|
|
8112
|
+
phoneNumberCountryCode: formData.phoneNumberCountryCode,
|
|
8113
|
+
};
|
|
8114
|
+
const result = await connectImpactPartner({
|
|
8115
|
+
vars,
|
|
8116
|
+
});
|
|
8117
|
+
if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
|
|
8118
|
+
throw new Error();
|
|
8119
|
+
if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
|
|
8120
|
+
// Output backend errors to console for now
|
|
8121
|
+
console.error("Failed to create Impact connection: ", result.createImpactConnection.validationErrors);
|
|
8122
|
+
throw new Error();
|
|
8123
|
+
}
|
|
8124
|
+
await refetch();
|
|
8125
|
+
const resultPublisher = (_e = (_d = (_c = result
|
|
8126
|
+
.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;
|
|
8127
|
+
const hasValidCurrentDocument = sqmInvoiceTableView.validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
|
|
8128
|
+
// Fire form change event
|
|
8129
|
+
window.dispatchEvent(new Event(usePayoutStatus.TAX_FORM_UPDATED_EVENT_KEY));
|
|
8130
|
+
return {
|
|
8131
|
+
resultPublisher,
|
|
8132
|
+
hasValidCurrentDocument,
|
|
8133
|
+
};
|
|
8134
|
+
}
|
|
8087
8135
|
async function onSubmit(event) {
|
|
8088
8136
|
let formControls = event.target.getFormControls();
|
|
8089
8137
|
let formData = {};
|
|
@@ -8128,6 +8176,29 @@ function useUserInfoForm(props) {
|
|
|
8128
8176
|
});
|
|
8129
8177
|
const skipNextStep = getSkipNextStep(userData);
|
|
8130
8178
|
console.log({ skipNextStep });
|
|
8179
|
+
if (skipNextStep) {
|
|
8180
|
+
try {
|
|
8181
|
+
const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
|
|
8182
|
+
if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
|
|
8183
|
+
!hasValidCurrentDocument) {
|
|
8184
|
+
// Go to docusign form
|
|
8185
|
+
setStep("/3");
|
|
8186
|
+
}
|
|
8187
|
+
else {
|
|
8188
|
+
if (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.brandedSignup) {
|
|
8189
|
+
// Go to banking information form
|
|
8190
|
+
setStep("/4");
|
|
8191
|
+
}
|
|
8192
|
+
else {
|
|
8193
|
+
// Go right to the dashboard
|
|
8194
|
+
setStep("/dashboard");
|
|
8195
|
+
}
|
|
8196
|
+
}
|
|
8197
|
+
}
|
|
8198
|
+
catch (e) {
|
|
8199
|
+
setErrors({ general: true });
|
|
8200
|
+
}
|
|
8201
|
+
}
|
|
8131
8202
|
const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
|
|
8132
8203
|
setStep(nextStep);
|
|
8133
8204
|
}
|
|
@@ -8169,9 +8240,9 @@ function useUserInfoForm(props) {
|
|
|
8169
8240
|
step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
|
|
8170
8241
|
hideState: !hasStates,
|
|
8171
8242
|
hideSteps: !!context.hideSteps,
|
|
8172
|
-
disabled: loading,
|
|
8243
|
+
disabled: loading || connectLoading,
|
|
8173
8244
|
loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
|
|
8174
|
-
loading: loading,
|
|
8245
|
+
loading: loading || connectLoading,
|
|
8175
8246
|
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
8247
|
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
8248
|
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
|
-
|
|
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
|
|
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
|
|
@@ -226,6 +232,7 @@ export function useIndirectTaxForm(props) {
|
|
|
226
232
|
...p,
|
|
227
233
|
hasSubRegionTaxNumber: !p.hasSubRegionTaxNumber,
|
|
228
234
|
})),
|
|
235
|
+
connectPartner,
|
|
229
236
|
},
|
|
230
237
|
data: {
|
|
231
238
|
esRegions: INDIRECT_TAX_SPAIN_REGIONS,
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
976
|
+
* @uiName Withdrawal settings invalid alert header
|
|
977
977
|
*/
|
|
978
978
|
this.dashboard_withdrawalSettingsInvalidHeader = "Your payment information includes invalid characters";
|
|
979
979
|
/**
|
|
980
|
-
* @uiName
|
|
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
|
|
984
|
+
* @uiName Payment returned alert header
|
|
985
985
|
*/
|
|
986
986
|
this.dashboard_paymentReturnedHeader = "Payout unsuccessful";
|
|
987
987
|
/**
|
|
988
|
-
* @uiName
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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
|
|
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,29 @@ 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
|
+
}
|
|
224
|
+
catch (e) {
|
|
225
|
+
setErrors({ general: true });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
162
228
|
const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
|
|
163
229
|
setStep(nextStep);
|
|
164
230
|
}
|
|
@@ -207,9 +273,9 @@ export function useUserInfoForm(props) {
|
|
|
207
273
|
step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
|
|
208
274
|
hideState: !hasStates,
|
|
209
275
|
hideSteps: !!context.hideSteps,
|
|
210
|
-
disabled: loading,
|
|
276
|
+
disabled: loading || connectLoading,
|
|
211
277
|
loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
|
|
212
|
-
loading: loading,
|
|
278
|
+
loading: loading || connectLoading,
|
|
213
279
|
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
280
|
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
281
|
formState: {
|