@saasquatch/mint-components 2.3.0-11 → 2.3.0-13
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/{usePortalRegistrationForm-23ee2d62.js → AsYouType-d15caac8.js} +265 -223
- package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +46 -27
- package/dist/cjs/sqm-big-stat_47.cjs.entry.js +17 -13
- package/dist/cjs/sqm-portal-forgot-password_6.cjs.entry.js +3 -2
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +59 -2
- package/dist/cjs/{sqm-user-info-form-view-8f7186b8.js → sqm-user-info-form-view-60e09262.js} +1004 -8
- package/dist/cjs/subregions-3542b0b8.js +1068 -0
- package/dist/cjs/{useIndirectTaxForm-112914a0.js → useIndirectTaxForm-c439eb81.js} +6 -2
- package/dist/cjs/usePortalRegistrationForm-8a3a14ac.js +215 -0
- package/dist/collection/components/tax-and-cash/TaxForm.stories.js +3 -0
- package/dist/collection/components/tax-and-cash/phoneExtensions.js +12 -0
- package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/sqm-indirect-tax-form-view.js +8 -0
- package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/sqm-indirect-tax-form.js +2 -1
- package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.js +5 -1
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/useTaxAndCash.js +12 -9
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/UserInfoFormView.stories.js +52 -0
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +18 -5
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form.js +3 -1
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +31 -27
- package/dist/collection/components/tax-and-cash/utils.js +30 -27
- package/dist/esm/{usePortalRegistrationForm-3a1f36a2.js → AsYouType-2d56519e.js} +248 -223
- package/dist/esm/sqm-banking-info-form_10.entry.js +46 -27
- package/dist/esm/sqm-big-stat_47.entry.js +16 -12
- package/dist/esm/sqm-portal-forgot-password_6.entry.js +2 -1
- package/dist/esm/sqm-stencilbook.entry.js +59 -2
- package/dist/esm/{sqm-user-info-form-view-599a6922.js → sqm-user-info-form-view-647a2bd5.js} +1002 -6
- package/dist/esm/subregions-7c5112e8.js +1055 -0
- package/dist/esm/{useIndirectTaxForm-a6ac7e7e.js → useIndirectTaxForm-38cd984e.js} +6 -2
- package/dist/esm/usePortalRegistrationForm-78fdfd93.js +213 -0
- package/dist/esm-es5/AsYouType-2d56519e.js +1 -0
- package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
- package/dist/esm-es5/sqm-big-stat_47.entry.js +1 -1
- package/dist/esm-es5/sqm-portal-forgot-password_6.entry.js +1 -1
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/esm-es5/sqm-user-info-form-view-647a2bd5.js +1 -0
- package/dist/esm-es5/subregions-7c5112e8.js +1 -0
- package/dist/esm-es5/{useIndirectTaxForm-a6ac7e7e.js → useIndirectTaxForm-38cd984e.js} +2 -2
- package/dist/esm-es5/usePortalRegistrationForm-78fdfd93.js +1 -0
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-1f387c7b.system.js +1 -1
- package/dist/mint-components/p-34179541.system.js +1 -0
- package/dist/mint-components/p-4065ae93.entry.js +9 -0
- package/dist/mint-components/p-5c3bff99.entry.js +1 -0
- package/dist/mint-components/p-6fd8981d.system.entry.js +1 -0
- package/dist/mint-components/p-769166a5.system.js +1 -0
- package/dist/mint-components/p-7c72eeb5.js +1 -0
- package/dist/mint-components/p-8d30945a.js +1 -0
- package/dist/mint-components/p-8dcd72fe.system.entry.js +1 -0
- package/dist/mint-components/p-a08157c4.js +1 -0
- package/dist/mint-components/p-a779e577.js +13 -0
- package/dist/mint-components/{p-2d4132fb.js → p-aa2c6585.js} +7 -5
- package/dist/mint-components/{p-6ef373ed.system.js → p-aab8a207.system.js} +2 -2
- package/dist/mint-components/p-af8b8c06.system.entry.js +1 -0
- package/dist/mint-components/{p-86231add.entry.js → p-b3f25c0e.entry.js} +8 -8
- package/dist/mint-components/p-c31966e3.system.entry.js +1 -0
- package/dist/mint-components/p-d463fa82.system.js +1 -0
- package/dist/mint-components/{p-339ce676.entry.js → p-dd5c1db9.entry.js} +11 -11
- package/dist/mint-components/p-ee91aeac.system.js +1 -0
- package/dist/types/components/tax-and-cash/phoneExtensions.d.ts +12 -0
- package/dist/types/components/tax-and-cash/sqm-indirect-tax-form/sqm-indirect-tax-form-view.d.ts +1 -0
- package/dist/types/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.d.ts +1 -0
- package/dist/types/components/tax-and-cash/sqm-user-info-form/UserInfoFormView.stories.d.ts +1 -0
- package/dist/types/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.d.ts +2 -0
- package/dist/types/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.d.ts +2 -0
- package/dist/types/components/tax-and-cash/utils.d.ts +8 -2
- package/docs/docs.docx +0 -0
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/subregions-984e30d7.js +0 -1505
- package/dist/esm/subregions-7c9778d0.js +0 -1492
- package/dist/esm-es5/sqm-user-info-form-view-599a6922.js +0 -1
- package/dist/esm-es5/subregions-7c9778d0.js +0 -1
- package/dist/esm-es5/usePortalRegistrationForm-3a1f36a2.js +0 -1
- package/dist/mint-components/p-26a4ebfd.js +0 -1
- package/dist/mint-components/p-335a5736.entry.js +0 -1
- package/dist/mint-components/p-3a41b39c.js +0 -13
- package/dist/mint-components/p-40894343.entry.js +0 -9
- package/dist/mint-components/p-5fdf0286.system.js +0 -1
- package/dist/mint-components/p-7f29622d.js +0 -1
- package/dist/mint-components/p-81270b9f.system.js +0 -1
- package/dist/mint-components/p-b62d8b95.system.entry.js +0 -1
- package/dist/mint-components/p-bd03efe0.system.js +0 -1
- package/dist/mint-components/p-c9d2ccfc.system.entry.js +0 -1
- package/dist/mint-components/p-db6bf7cf.system.entry.js +0 -1
- package/dist/mint-components/p-f0ef09a0.system.entry.js +0 -1
|
@@ -3,7 +3,7 @@ import { useEffect, useMemo, useRef, useState, } from "@saasquatch/universal-hoo
|
|
|
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, validTaxDocument } from "../utils";
|
|
6
|
+
import { objectIsFull, toDomesticNumber, validTaxDocument } from "../utils";
|
|
7
7
|
import { TAX_FORM_UPDATED_EVENT_KEY } from "../eventKeys";
|
|
8
8
|
import { CONNECT_PARTNER, COMPLETE_PARTNER, } from "../sqm-indirect-tax-form/useIndirectTaxForm";
|
|
9
9
|
import { gql } from "graphql-request";
|
|
@@ -16,7 +16,7 @@ const GET_INDIRECT_TAX_COUNTRY_CODE = gql `
|
|
|
16
16
|
}
|
|
17
17
|
`;
|
|
18
18
|
export function useUserInfoForm(props) {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
20
20
|
const currencyRef = useRef(undefined);
|
|
21
21
|
const phoneCountryRef = useRef(undefined);
|
|
22
22
|
const formRef = useRef(null);
|
|
@@ -136,7 +136,7 @@ export function useUserInfoForm(props) {
|
|
|
136
136
|
}
|
|
137
137
|
}, [currencySearch, currencies]);
|
|
138
138
|
async function connectPartner(formData) {
|
|
139
|
-
var _a, _b, _c, _d;
|
|
139
|
+
var _a, _b, _c, _d, _e, _f;
|
|
140
140
|
const vars = {
|
|
141
141
|
user: {
|
|
142
142
|
id: user.id,
|
|
@@ -150,39 +150,34 @@ export function useUserInfoForm(props) {
|
|
|
150
150
|
city: formData.city,
|
|
151
151
|
state: formData.state,
|
|
152
152
|
postalCode: formData.postalCode,
|
|
153
|
-
phoneNumber: formData.phoneNumber,
|
|
153
|
+
phoneNumber: toDomesticNumber(formData.phoneNumberCountryCode, formData.phoneNumber),
|
|
154
154
|
phoneNumberCountryCode: formData.phoneNumberCountryCode,
|
|
155
155
|
};
|
|
156
|
-
//
|
|
157
|
-
//
|
|
156
|
+
// if user went through early partner creation, connectionStatus === "STARTED"
|
|
157
|
+
// otherwise trigger legacy partner creation
|
|
158
158
|
const userData = data === null || data === void 0 ? void 0 : data.user;
|
|
159
159
|
let result = null;
|
|
160
160
|
let connectionResult;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
// });
|
|
175
|
-
// connectionResult = (result as ConnectPartnerResult)
|
|
176
|
-
// ?.createImpactConnection;
|
|
177
|
-
// }
|
|
178
|
-
if (!result || ((_b = result) === null || _b === void 0 ? void 0 : _b.message))
|
|
161
|
+
if (((_a = userData === null || userData === void 0 ? void 0 : userData.impactConnection) === null || _a === void 0 ? void 0 : _a.connectionStatus) === "STARTED") {
|
|
162
|
+
result = await completeImpactPartner({
|
|
163
|
+
vars,
|
|
164
|
+
});
|
|
165
|
+
connectionResult = (_b = result) === null || _b === void 0 ? void 0 : _b.completeImpactConnection;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
result = await connectImpactPartner({
|
|
169
|
+
vars,
|
|
170
|
+
});
|
|
171
|
+
connectionResult = (_c = result) === null || _c === void 0 ? void 0 : _c.createImpactConnection;
|
|
172
|
+
}
|
|
173
|
+
if (!result || ((_d = result) === null || _d === void 0 ? void 0 : _d.message))
|
|
179
174
|
throw new Error();
|
|
180
175
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.success)) {
|
|
181
176
|
console.error("Failed to create Impact connection: ", connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.validationErrors);
|
|
182
177
|
throw new Error();
|
|
183
178
|
}
|
|
184
179
|
await refetch();
|
|
185
|
-
const resultPublisher = (
|
|
180
|
+
const resultPublisher = (_f = (_e = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.publisher;
|
|
186
181
|
const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
|
|
187
182
|
// Fire form change event
|
|
188
183
|
window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
|
|
@@ -220,12 +215,13 @@ export function useUserInfoForm(props) {
|
|
|
220
215
|
return;
|
|
221
216
|
}
|
|
222
217
|
const { allowBankingCollection, ...userData } = formData;
|
|
218
|
+
const normalizedPhoneNumber = toDomesticNumber(userData.phoneNumberCountryCode, userData.phoneNumber);
|
|
223
219
|
setUserFormContext({
|
|
224
220
|
...userFormContext,
|
|
225
221
|
firstName: userData.firstName,
|
|
226
222
|
lastName: userData.lastName,
|
|
227
223
|
phoneNumberCountryCode: userData.phoneNumberCountryCode,
|
|
228
|
-
phoneNumber:
|
|
224
|
+
phoneNumber: normalizedPhoneNumber,
|
|
229
225
|
countryCode: userData.countryCode,
|
|
230
226
|
address: userData.address,
|
|
231
227
|
city: userData.city,
|
|
@@ -236,7 +232,10 @@ export function useUserInfoForm(props) {
|
|
|
236
232
|
const skipNextStep = getSkipNextStep(userData);
|
|
237
233
|
if (skipNextStep) {
|
|
238
234
|
try {
|
|
239
|
-
const { resultPublisher, hasValidCurrentDocument } = await connectPartner(
|
|
235
|
+
const { resultPublisher, hasValidCurrentDocument } = await connectPartner({
|
|
236
|
+
...formData,
|
|
237
|
+
phoneNumber: normalizedPhoneNumber,
|
|
238
|
+
});
|
|
240
239
|
if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
|
|
241
240
|
!hasValidCurrentDocument) {
|
|
242
241
|
// Go to docusign form
|
|
@@ -312,6 +311,11 @@ export function useUserInfoForm(props) {
|
|
|
312
311
|
loading: loading || connectLoading || completeLoading,
|
|
313
312
|
isPartner: !!((_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.publisher),
|
|
314
313
|
isUser: !!((_j = (_h = data === null || data === void 0 ? void 0 : data.user) === null || _h === void 0 ? void 0 : _h.impactConnection) === null || _j === void 0 ? void 0 : _j.user),
|
|
314
|
+
// Show banner when pre-existing partner is created with legacy mutation createImpactConnection
|
|
315
|
+
isUserLegacy: !!((_l = (_k = data === null || data === void 0 ? void 0 : data.user) === null || _k === void 0 ? void 0 : _k.impactConnection) === null || _l === void 0 ? void 0 : _l.user) &&
|
|
316
|
+
((_o = (_m = data === null || data === void 0 ? void 0 : data.user) === null || _m === void 0 ? void 0 : _m.impactConnection) === null || _o === void 0 ? void 0 : _o.connectionStatus) !== "STARTED",
|
|
317
|
+
isPartnerLegacy: !!((_q = (_p = data === null || data === void 0 ? void 0 : data.user) === null || _p === void 0 ? void 0 : _p.impactConnection) === null || _q === void 0 ? void 0 : _q.publisher) &&
|
|
318
|
+
((_s = (_r = data === null || data === void 0 ? void 0 : data.user) === null || _r === void 0 ? void 0 : _r.impactConnection) === null || _s === void 0 ? void 0 : _s.connectionStatus) !== "STARTED",
|
|
315
319
|
formState: {
|
|
316
320
|
...userFormContext,
|
|
317
321
|
errors: formErrors,
|
|
@@ -1,31 +1,46 @@
|
|
|
1
|
+
import { parsePhoneNumberFromString } from "libphonenumber-js";
|
|
1
2
|
import { intl } from "../../global/global";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Normalize user input to the domestic form Impact stores: digits only,
|
|
5
|
+
* with the country dial code and trunk-zero prefix removed.
|
|
6
|
+
*/
|
|
7
|
+
export function toDomesticNumber(phoneCountryCode, input) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (!input)
|
|
10
|
+
return "";
|
|
11
|
+
const parsed = parsePhoneNumberFromString(input, phoneCountryCode === null || phoneCountryCode === void 0 ? void 0 : phoneCountryCode.toUpperCase());
|
|
12
|
+
return (_a = parsed === null || parsed === void 0 ? void 0 : parsed.nationalNumber) !== null && _a !== void 0 ? _a : input.replace(/\D/g, "");
|
|
5
13
|
}
|
|
6
14
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
15
|
+
* Validates a phone number against both libphonenumber-js's per-country
|
|
16
|
+
* pattern rules AND Impact's I18nPhoneNumber length rules, applied to the
|
|
17
|
+
* sanitized value we'll submit.
|
|
9
18
|
*/
|
|
10
19
|
export function isValidI18nPhoneNumber(phoneCountryCode, phoneNumber) {
|
|
11
|
-
var _a, _b;
|
|
12
20
|
if (!phoneCountryCode || !(phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.trim()))
|
|
13
21
|
return false;
|
|
14
22
|
const country = phoneCountryCode.toUpperCase();
|
|
15
|
-
const
|
|
23
|
+
const parsed = parsePhoneNumberFromString(phoneNumber, country);
|
|
24
|
+
if (!(parsed === null || parsed === void 0 ? void 0 : parsed.isValid()))
|
|
25
|
+
return false;
|
|
26
|
+
return passesImpactBackendLengthCheck(country, toDomesticNumber(country, phoneNumber));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Mirrors estalea.bucket.phone.I18nPhoneNumber.isValidI18nPhoneNumber()
|
|
30
|
+
* length rules on the already-sanitized (digits-only) submission value.
|
|
31
|
+
*/
|
|
32
|
+
function passesImpactBackendLengthCheck(country, digits) {
|
|
33
|
+
if (!digits)
|
|
34
|
+
return false;
|
|
16
35
|
switch (country) {
|
|
17
36
|
case "US":
|
|
18
37
|
case "CA": {
|
|
19
|
-
// strip a single leading "1", then exactly 10 digits
|
|
20
38
|
const n = digits.startsWith("1") ? digits.slice(1) : digits;
|
|
21
39
|
return n.length === 10;
|
|
22
40
|
}
|
|
23
41
|
case "AU":
|
|
24
|
-
// 9 or 10 digits
|
|
25
42
|
return digits.length === 9 || digits.length === 10;
|
|
26
43
|
case "NZ": {
|
|
27
|
-
// trim "640" country prefix or leading "0" (only when >9 digits),
|
|
28
|
-
// then 8–10 digits
|
|
29
44
|
let n = digits;
|
|
30
45
|
if (n.length > 9) {
|
|
31
46
|
if (n.startsWith("640"))
|
|
@@ -35,25 +50,13 @@ export function isValidI18nPhoneNumber(phoneCountryCode, phoneNumber) {
|
|
|
35
50
|
}
|
|
36
51
|
return n.length >= 8 && n.length <= 10;
|
|
37
52
|
}
|
|
38
|
-
|
|
39
|
-
// >= 6 digits after stripping a single leading "0", no dialing-code check
|
|
53
|
+
default:
|
|
40
54
|
return stripLeadingZero(digits).length >= 6;
|
|
41
|
-
default: {
|
|
42
|
-
// All other countries: strip a single leading "0", then >= 6 digits
|
|
43
|
-
if (stripLeadingZero(digits).length < 6)
|
|
44
|
-
return false;
|
|
45
|
-
// If input starts with "+", the dialing code (first whitespace-split
|
|
46
|
-
// token) must match the selected country exactly. Splits on first
|
|
47
|
-
// whitespace, so "+4420 7946 0958" supplies "4420" (not "44") and fails.
|
|
48
|
-
if (phoneNumber.trim().startsWith("+")) {
|
|
49
|
-
const supplied = phoneNumber.trim().split(/\s/)[0].slice(1);
|
|
50
|
-
const expected = (_b = (_a = PHONE_EXTENSIONS[country]) === null || _a === void 0 ? void 0 : _a.dial_code) === null || _b === void 0 ? void 0 : _b.replace(/^\+/, "");
|
|
51
|
-
return expected === supplied;
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
function stripLeadingZero(digits) {
|
|
58
|
+
return digits.startsWith("0") ? digits.slice(1) : digits;
|
|
59
|
+
}
|
|
57
60
|
export function validTaxDocument(requiredType) {
|
|
58
61
|
const validTypes = ["W9", "W8BENE", "W8BEN"];
|
|
59
62
|
if (validTypes.includes(requiredType))
|