@saasquatch/mint-components 1.8.3-2 → 1.8.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.
- package/dist/cjs/{ShadowViewAddon-7b5c40eb.js → ShadowViewAddon-a9bac47c.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-banking-info-form_16.cjs.entry.js +1237 -36
- package/dist/cjs/sqm-big-stat_38.cjs.entry.js +1 -3
- package/dist/cjs/{sqm-invoice-table-view-035d5aed.js → sqm-invoice-table-view-2e93ac53.js} +368 -7
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +3 -3
- package/dist/collection/components/sqm-leaderboard/sqm-leaderboard.js +0 -3
- package/dist/collection/components/sqm-portal-footer/sqm-portal-footer.js +0 -8
- package/dist/collection/components/tax-and-cash/TaxForm.stories.js +16 -0
- package/dist/collection/components/tax-and-cash/phoneExtensions.js +970 -0
- package/dist/collection/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.js +1 -1
- package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.js +33 -14
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/data.js +10 -2
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +234 -0
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.js +1 -1
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/small-views/IndirectTaxDetailsView.js +6 -6
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +87 -12
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form.js +233 -1
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +52 -7
- package/dist/collection/components/tax-and-cash/subregions.js +338 -0
- package/dist/collection/components/tax-and-cash/utils.js +6 -1
- package/dist/collection/components/views/copy-text-view.js +2 -2
- package/dist/esm/{ShadowViewAddon-d9424229.js → ShadowViewAddon-352dc73a.js} +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-banking-info-form_16.entry.js +1237 -36
- package/dist/esm/sqm-big-stat_38.entry.js +1 -3
- package/dist/esm/{sqm-invoice-table-view-1115795f.js → sqm-invoice-table-view-e925c4db.js} +366 -7
- package/dist/esm/sqm-stencilbook.entry.js +3 -3
- package/dist/esm-es5/ShadowViewAddon-352dc73a.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mint-components.js +1 -1
- package/dist/esm-es5/sqm-banking-info-form_16.entry.js +1 -1
- package/dist/esm-es5/sqm-big-stat_38.entry.js +1 -1
- package/dist/esm-es5/sqm-invoice-table-view-e925c4db.js +1 -0
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/{p-f37b7296.entry.js → p-12c2757a.entry.js} +2 -2
- package/dist/mint-components/p-1ee63bff.entry.js +168 -0
- package/dist/mint-components/{p-89995fd0.js → p-26258333.js} +1 -1
- package/dist/mint-components/p-2ca2b028.system.js +1 -0
- package/dist/mint-components/p-4d45d92d.js +1 -0
- package/dist/mint-components/p-5d030951.system.entry.js +1 -0
- package/dist/mint-components/p-7eb6fab2.system.js +1 -1
- package/dist/mint-components/{p-2ee988c7.entry.js → p-8a174905.entry.js} +1 -1
- package/dist/mint-components/p-8e2274a8.system.js +1 -0
- package/dist/mint-components/{p-92b99bb2.system.entry.js → p-95a23c8f.system.entry.js} +1 -1
- package/dist/mint-components/{p-f4a6e490.system.entry.js → p-d3d04e96.system.entry.js} +1 -1
- package/dist/types/components/sqm-leaderboard/sqm-leaderboard.d.ts +0 -3
- package/dist/types/components/sqm-portal-footer/sqm-portal-footer.d.ts +0 -2
- package/dist/types/components/tax-and-cash/phoneExtensions.d.ts +970 -0
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash/data.d.ts +16 -2
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.d.ts +42 -0
- package/dist/types/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.d.ts +39 -6
- package/dist/types/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form.d.ts +40 -0
- package/dist/types/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.d.ts +20 -0
- package/dist/types/components/tax-and-cash/subregions.d.ts +8 -0
- package/dist/types/components/tax-and-cash/utils.d.ts +2 -1
- package/dist/types/components.d.ts +158 -4
- package/docs/UserFormFastFollow--2024-04-26--14-31-04.xlsx +0 -0
- package/docs/docs.docx +0 -0
- package/docs/raisins.json +1 -1
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/ShadowViewAddon-d9424229.js +0 -1
- package/dist/esm-es5/sqm-invoice-table-view-1115795f.js +0 -1
- package/dist/mint-components/p-58d2e9cb.entry.js +0 -153
- package/dist/mint-components/p-5ff96052.system.entry.js +0 -1
- package/dist/mint-components/p-67b91751.system.js +0 -1
- package/dist/mint-components/p-79fc68b0.js +0 -1
- package/dist/mint-components/p-9755ab8f.system.js +0 -1
- package/docs/TaxAndCash--2024-03-14--14-20-26.xlsx +0 -0
|
@@ -29,6 +29,34 @@ export class TaxForm {
|
|
|
29
29
|
* @uiName Country field label
|
|
30
30
|
*/
|
|
31
31
|
this.country = "Country";
|
|
32
|
+
/**
|
|
33
|
+
* @uiName Phone number field label
|
|
34
|
+
*/
|
|
35
|
+
this.phoneNumber = "Phone number";
|
|
36
|
+
/**
|
|
37
|
+
* @uiName Address field label
|
|
38
|
+
*/
|
|
39
|
+
this.address = "Address";
|
|
40
|
+
/**
|
|
41
|
+
* @uiName City field label
|
|
42
|
+
*/
|
|
43
|
+
this.city = "City";
|
|
44
|
+
/**
|
|
45
|
+
* @uiName State field label
|
|
46
|
+
*/
|
|
47
|
+
this.state = "State";
|
|
48
|
+
/**
|
|
49
|
+
* @uiName State field label
|
|
50
|
+
*/
|
|
51
|
+
this.province = "Province";
|
|
52
|
+
/**
|
|
53
|
+
* @uiName State field label
|
|
54
|
+
*/
|
|
55
|
+
this.region = "Region";
|
|
56
|
+
/**
|
|
57
|
+
* @uiName Postal code field label
|
|
58
|
+
*/
|
|
59
|
+
this.postalCode = "Postal code";
|
|
32
60
|
/**
|
|
33
61
|
* @uiName Currency field label
|
|
34
62
|
*/
|
|
@@ -99,6 +127,16 @@ export class TaxForm {
|
|
|
99
127
|
* @uiName Empty form field error message
|
|
100
128
|
*/
|
|
101
129
|
this.fieldRequiredError = "{fieldName} is required";
|
|
130
|
+
/**
|
|
131
|
+
* Displayed under a field when it has an invalid entry.
|
|
132
|
+
* @uiName Form field error message
|
|
133
|
+
*/
|
|
134
|
+
this.fieldInvalidError = "{fieldName} is invalid";
|
|
135
|
+
/**
|
|
136
|
+
* Displayed under Address or City fields that includes invalid characters (non-ASCII).
|
|
137
|
+
* @uiName Invalid character error message
|
|
138
|
+
*/
|
|
139
|
+
this.invalidCharacterError = "{fieldName} includes characters that aren't supported.";
|
|
102
140
|
/**
|
|
103
141
|
* Part of the alert displayed at the top of the page.
|
|
104
142
|
* @uiName Page load error message title
|
|
@@ -125,10 +163,12 @@ export class TaxForm {
|
|
|
125
163
|
...props,
|
|
126
164
|
error: {
|
|
127
165
|
fieldRequiredError: props.fieldRequiredError,
|
|
166
|
+
fieldInvalidError: props.fieldInvalidError,
|
|
128
167
|
generalTitle: props.generalErrorTitle,
|
|
129
168
|
generalDescription: props.generalErrorDescription,
|
|
130
169
|
loadingErrorAlertHeader: props.loadingErrorAlertHeader,
|
|
131
170
|
loadingErrorAlertDescription: props.loadingErrorAlertDescription,
|
|
171
|
+
invalidCharacterError: props.invalidCharacterError,
|
|
132
172
|
},
|
|
133
173
|
};
|
|
134
174
|
}
|
|
@@ -229,6 +269,153 @@ export class TaxForm {
|
|
|
229
269
|
"reflect": false,
|
|
230
270
|
"defaultValue": "\"Country\""
|
|
231
271
|
},
|
|
272
|
+
"phoneNumber": {
|
|
273
|
+
"type": "string",
|
|
274
|
+
"mutable": false,
|
|
275
|
+
"complexType": {
|
|
276
|
+
"original": "string",
|
|
277
|
+
"resolved": "string",
|
|
278
|
+
"references": {}
|
|
279
|
+
},
|
|
280
|
+
"required": false,
|
|
281
|
+
"optional": false,
|
|
282
|
+
"docs": {
|
|
283
|
+
"tags": [{
|
|
284
|
+
"text": "Phone number field label",
|
|
285
|
+
"name": "uiName"
|
|
286
|
+
}],
|
|
287
|
+
"text": ""
|
|
288
|
+
},
|
|
289
|
+
"attribute": "phone-number",
|
|
290
|
+
"reflect": false,
|
|
291
|
+
"defaultValue": "\"Phone number\""
|
|
292
|
+
},
|
|
293
|
+
"address": {
|
|
294
|
+
"type": "string",
|
|
295
|
+
"mutable": false,
|
|
296
|
+
"complexType": {
|
|
297
|
+
"original": "string",
|
|
298
|
+
"resolved": "string",
|
|
299
|
+
"references": {}
|
|
300
|
+
},
|
|
301
|
+
"required": false,
|
|
302
|
+
"optional": false,
|
|
303
|
+
"docs": {
|
|
304
|
+
"tags": [{
|
|
305
|
+
"text": "Address field label",
|
|
306
|
+
"name": "uiName"
|
|
307
|
+
}],
|
|
308
|
+
"text": ""
|
|
309
|
+
},
|
|
310
|
+
"attribute": "address",
|
|
311
|
+
"reflect": false,
|
|
312
|
+
"defaultValue": "\"Address\""
|
|
313
|
+
},
|
|
314
|
+
"city": {
|
|
315
|
+
"type": "string",
|
|
316
|
+
"mutable": false,
|
|
317
|
+
"complexType": {
|
|
318
|
+
"original": "string",
|
|
319
|
+
"resolved": "string",
|
|
320
|
+
"references": {}
|
|
321
|
+
},
|
|
322
|
+
"required": false,
|
|
323
|
+
"optional": false,
|
|
324
|
+
"docs": {
|
|
325
|
+
"tags": [{
|
|
326
|
+
"text": "City field label",
|
|
327
|
+
"name": "uiName"
|
|
328
|
+
}],
|
|
329
|
+
"text": ""
|
|
330
|
+
},
|
|
331
|
+
"attribute": "city",
|
|
332
|
+
"reflect": false,
|
|
333
|
+
"defaultValue": "\"City\""
|
|
334
|
+
},
|
|
335
|
+
"state": {
|
|
336
|
+
"type": "string",
|
|
337
|
+
"mutable": false,
|
|
338
|
+
"complexType": {
|
|
339
|
+
"original": "string",
|
|
340
|
+
"resolved": "string",
|
|
341
|
+
"references": {}
|
|
342
|
+
},
|
|
343
|
+
"required": false,
|
|
344
|
+
"optional": false,
|
|
345
|
+
"docs": {
|
|
346
|
+
"tags": [{
|
|
347
|
+
"text": "State field label",
|
|
348
|
+
"name": "uiName"
|
|
349
|
+
}],
|
|
350
|
+
"text": ""
|
|
351
|
+
},
|
|
352
|
+
"attribute": "state",
|
|
353
|
+
"reflect": false,
|
|
354
|
+
"defaultValue": "\"State\""
|
|
355
|
+
},
|
|
356
|
+
"province": {
|
|
357
|
+
"type": "string",
|
|
358
|
+
"mutable": false,
|
|
359
|
+
"complexType": {
|
|
360
|
+
"original": "string",
|
|
361
|
+
"resolved": "string",
|
|
362
|
+
"references": {}
|
|
363
|
+
},
|
|
364
|
+
"required": false,
|
|
365
|
+
"optional": false,
|
|
366
|
+
"docs": {
|
|
367
|
+
"tags": [{
|
|
368
|
+
"text": "State field label",
|
|
369
|
+
"name": "uiName"
|
|
370
|
+
}],
|
|
371
|
+
"text": ""
|
|
372
|
+
},
|
|
373
|
+
"attribute": "province",
|
|
374
|
+
"reflect": false,
|
|
375
|
+
"defaultValue": "\"Province\""
|
|
376
|
+
},
|
|
377
|
+
"region": {
|
|
378
|
+
"type": "string",
|
|
379
|
+
"mutable": false,
|
|
380
|
+
"complexType": {
|
|
381
|
+
"original": "string",
|
|
382
|
+
"resolved": "string",
|
|
383
|
+
"references": {}
|
|
384
|
+
},
|
|
385
|
+
"required": false,
|
|
386
|
+
"optional": false,
|
|
387
|
+
"docs": {
|
|
388
|
+
"tags": [{
|
|
389
|
+
"text": "State field label",
|
|
390
|
+
"name": "uiName"
|
|
391
|
+
}],
|
|
392
|
+
"text": ""
|
|
393
|
+
},
|
|
394
|
+
"attribute": "region",
|
|
395
|
+
"reflect": false,
|
|
396
|
+
"defaultValue": "\"Region\""
|
|
397
|
+
},
|
|
398
|
+
"postalCode": {
|
|
399
|
+
"type": "string",
|
|
400
|
+
"mutable": false,
|
|
401
|
+
"complexType": {
|
|
402
|
+
"original": "string",
|
|
403
|
+
"resolved": "string",
|
|
404
|
+
"references": {}
|
|
405
|
+
},
|
|
406
|
+
"required": false,
|
|
407
|
+
"optional": false,
|
|
408
|
+
"docs": {
|
|
409
|
+
"tags": [{
|
|
410
|
+
"text": "Postal code field label",
|
|
411
|
+
"name": "uiName"
|
|
412
|
+
}],
|
|
413
|
+
"text": ""
|
|
414
|
+
},
|
|
415
|
+
"attribute": "postal-code",
|
|
416
|
+
"reflect": false,
|
|
417
|
+
"defaultValue": "\"Postal code\""
|
|
418
|
+
},
|
|
232
419
|
"currency": {
|
|
233
420
|
"type": "string",
|
|
234
421
|
"mutable": false,
|
|
@@ -538,6 +725,48 @@ export class TaxForm {
|
|
|
538
725
|
"reflect": false,
|
|
539
726
|
"defaultValue": "\"{fieldName} is required\""
|
|
540
727
|
},
|
|
728
|
+
"fieldInvalidError": {
|
|
729
|
+
"type": "string",
|
|
730
|
+
"mutable": false,
|
|
731
|
+
"complexType": {
|
|
732
|
+
"original": "string",
|
|
733
|
+
"resolved": "string",
|
|
734
|
+
"references": {}
|
|
735
|
+
},
|
|
736
|
+
"required": false,
|
|
737
|
+
"optional": false,
|
|
738
|
+
"docs": {
|
|
739
|
+
"tags": [{
|
|
740
|
+
"text": "Form field error message",
|
|
741
|
+
"name": "uiName"
|
|
742
|
+
}],
|
|
743
|
+
"text": "Displayed under a field when it has an invalid entry."
|
|
744
|
+
},
|
|
745
|
+
"attribute": "field-invalid-error",
|
|
746
|
+
"reflect": false,
|
|
747
|
+
"defaultValue": "\"{fieldName} is invalid\""
|
|
748
|
+
},
|
|
749
|
+
"invalidCharacterError": {
|
|
750
|
+
"type": "string",
|
|
751
|
+
"mutable": false,
|
|
752
|
+
"complexType": {
|
|
753
|
+
"original": "string",
|
|
754
|
+
"resolved": "string",
|
|
755
|
+
"references": {}
|
|
756
|
+
},
|
|
757
|
+
"required": false,
|
|
758
|
+
"optional": false,
|
|
759
|
+
"docs": {
|
|
760
|
+
"tags": [{
|
|
761
|
+
"text": "Invalid character error message",
|
|
762
|
+
"name": "uiName"
|
|
763
|
+
}],
|
|
764
|
+
"text": "Displayed under Address or City fields that includes invalid characters (non-ASCII)."
|
|
765
|
+
},
|
|
766
|
+
"attribute": "invalid-character-error",
|
|
767
|
+
"reflect": false,
|
|
768
|
+
"defaultValue": "\"{fieldName} includes characters that aren't supported.\""
|
|
769
|
+
},
|
|
541
770
|
"loadingErrorAlertHeader": {
|
|
542
771
|
"type": "string",
|
|
543
772
|
"mutable": false,
|
|
@@ -612,7 +841,7 @@ export class TaxForm {
|
|
|
612
841
|
"mutable": false,
|
|
613
842
|
"complexType": {
|
|
614
843
|
"original": "DemoData<UseUserInfoFormResult>",
|
|
615
|
-
"resolved": "{ states?: { step: string; hideSteps: boolean; disabled: boolean; loadingError: boolean; loading: boolean; isPartner: boolean; isUser: boolean; formState: { errors: {}; firstName: string; lastName: string; email: string; countryCode: string; currency: string; }; }; refs?: { formRef: Ref<HTMLFormElement>; currencyRef: Ref<HTMLSelectElement>; }; data?: { currencies: { displayName: string; currencyCode: string; }[]; countries: TaxCountry[]; allCurrencies: { displayName: string; currencyCode: string; }[]; allCountries: TaxCountry[]; }; setStep?: (value: string) => void; onSubmit?: (event: any) => Promise<void>; }",
|
|
844
|
+
"resolved": "{ states?: { step: string; hideState: boolean; hideSteps: boolean; disabled: boolean; loadingError: boolean; loading: boolean; isPartner: boolean; isUser: boolean; formState: { errors: {}; firstName: string; lastName: string; email: string; phoneNumberCountryCode: string; phoneNumber: string; countryCode: string; currency: string; address: string; city: string; state: string; postalCode: string; }; }; refs?: { formRef: Ref<HTMLFormElement>; currencyRef: Ref<HTMLSelectElement>; phoneCountryRef: Ref<HTMLSelectElement>; }; data?: { currencies: { displayName: string; currencyCode: string; }[]; countries: TaxCountry[]; phoneCountries: TaxCountry[]; allCurrencies: { displayName: string; currencyCode: string; }[]; allCountries: TaxCountry[]; regionLabelEnum: \"STATE\" | \"PROVINCE\" | \"REGION\"; regions: { label: string; value: string; }[]; }; setStep?: (value: string) => void; onSubmit?: (event: any) => Promise<void>; }",
|
|
616
845
|
"references": {
|
|
617
846
|
"DemoData": {
|
|
618
847
|
"location": "import",
|
|
@@ -654,16 +883,19 @@ function useDemoUserInfoForm(props) {
|
|
|
654
883
|
refs: {
|
|
655
884
|
formRef: { current: null },
|
|
656
885
|
currencyRef: { current: null },
|
|
886
|
+
phoneCountryRef: { current: null },
|
|
657
887
|
},
|
|
658
888
|
data: {
|
|
659
889
|
currencies: [{ currencyCode: "CAD", displayName: "CAD" }],
|
|
660
890
|
allCurrencies: [{ currencyCode: "CAD", displayName: "CAD" }],
|
|
661
891
|
countries: [{ countryCode: "CA", displayName: "Canada" }],
|
|
892
|
+
phoneCountries: [{ countryCode: "CA", displayName: "Canada" }],
|
|
662
893
|
allCountries: [{ countryCode: "CA", displayName: "Canada" }],
|
|
663
894
|
},
|
|
664
895
|
callbacks: {
|
|
665
896
|
setCurrencySearch: (c) => console.log(c),
|
|
666
897
|
setCountrySearch: (c) => console.log(c),
|
|
898
|
+
setPhoneCountrySearch: (c) => console.log(c),
|
|
667
899
|
onFormChange: () => { },
|
|
668
900
|
},
|
|
669
901
|
states: {
|
|
@@ -2,10 +2,12 @@ import { useEffect, useMemo, useRef, useState, } from "@saasquatch/universal-hoo
|
|
|
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
4
|
import { objectIsFull } from "../utils";
|
|
5
|
-
import { useParent, useParentQueryValue, useParentValue } from "@saasquatch/component-boilerplate";
|
|
5
|
+
import { useParent, useParentQueryValue, useParentValue, } from "@saasquatch/component-boilerplate";
|
|
6
|
+
import { ADDRESS_REGIONS } from "../subregions";
|
|
6
7
|
export function useUserInfoForm(props) {
|
|
7
8
|
var _a, _b, _c, _d;
|
|
8
9
|
const currencyRef = useRef(undefined);
|
|
10
|
+
const phoneCountryRef = useRef(undefined);
|
|
9
11
|
const formRef = useRef(null);
|
|
10
12
|
const context = useParentValue(TAX_FORM_CONTEXT_NAMESPACE);
|
|
11
13
|
const countries = useParentValue(SORTED_COUNTRIES_NAMESPACE);
|
|
@@ -15,12 +17,14 @@ export function useUserInfoForm(props) {
|
|
|
15
17
|
const _currencies = useParentValue(CURRENCIES_NAMESPACE);
|
|
16
18
|
const currencies = useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
|
|
17
19
|
const [countrySearch, setCountrySearch] = useState("");
|
|
20
|
+
const [phoneCountrySearch, setPhoneCountrySearch] = useState("");
|
|
18
21
|
const [filteredCountries, setFilteredCountries] = useState(countries || []);
|
|
22
|
+
const [filteredPhoneCountries, setFilteredPhoneCountries] = useState(countries || []);
|
|
19
23
|
const [currencySearch, setCurrencySearch] = useState("");
|
|
20
24
|
const [filteredCurrencies, setFilteredCurrencies] = useState(currencies || []);
|
|
21
25
|
const [formErrors, setErrors] = useState({});
|
|
22
26
|
useEffect(() => {
|
|
23
|
-
var _a, _b, _c;
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
24
28
|
const user = data === null || data === void 0 ? void 0 : data.user;
|
|
25
29
|
if (!user || step !== "/1")
|
|
26
30
|
return;
|
|
@@ -35,6 +39,12 @@ export function useUserInfoForm(props) {
|
|
|
35
39
|
lastName: user.impactConnection.user.lastName,
|
|
36
40
|
countryCode: user.impactConnection.publisher.countryCode,
|
|
37
41
|
currency: user.impactConnection.publisher.currency,
|
|
42
|
+
phoneNumberCountryCode: user.impactConnection.publisher.phoneNumberCountryCode,
|
|
43
|
+
phoneNumber: user.impactConnection.publisher.phoneNumber,
|
|
44
|
+
address: user.impactConnection.publisher.billingAddress,
|
|
45
|
+
city: user.impactConnection.publisher.billingCity,
|
|
46
|
+
state: user.impactConnection.publisher.billingState,
|
|
47
|
+
postalCode: user.impactConnection.publisher.billingPostalCode,
|
|
38
48
|
});
|
|
39
49
|
}
|
|
40
50
|
else if (!(userFormContext === null || userFormContext === void 0 ? void 0 : userFormContext.email)) {
|
|
@@ -45,6 +55,12 @@ export function useUserInfoForm(props) {
|
|
|
45
55
|
lastName: user.lastName,
|
|
46
56
|
countryCode: user.countryCode || "US",
|
|
47
57
|
currency: (_c = user.customFields) === null || _c === void 0 ? void 0 : _c.currency,
|
|
58
|
+
phoneNumberCountryCode: ((_d = user.customFields) === null || _d === void 0 ? void 0 : _d.phoneNumberCountryCode) || "US",
|
|
59
|
+
phoneNumber: (_e = user.customFields) === null || _e === void 0 ? void 0 : _e.phoneNumber,
|
|
60
|
+
address: (_f = user.customFields) === null || _f === void 0 ? void 0 : _f.address,
|
|
61
|
+
city: (_g = user.customFields) === null || _g === void 0 ? void 0 : _g.city,
|
|
62
|
+
state: (_h = user.customFields) === null || _h === void 0 ? void 0 : _h.state,
|
|
63
|
+
postalCode: (_j = user.customFields) === null || _j === void 0 ? void 0 : _j.postalCode,
|
|
48
64
|
});
|
|
49
65
|
}
|
|
50
66
|
}, [data, step, userFormContext]);
|
|
@@ -57,8 +73,10 @@ export function useUserInfoForm(props) {
|
|
|
57
73
|
...userFormContext,
|
|
58
74
|
[field]: value,
|
|
59
75
|
});
|
|
60
|
-
if (field === "countryCode")
|
|
76
|
+
if (field === "countryCode") {
|
|
77
|
+
phoneCountryRef.current.value = value;
|
|
61
78
|
currencyRef.current.value = "";
|
|
79
|
+
}
|
|
62
80
|
};
|
|
63
81
|
useEffect(() => {
|
|
64
82
|
if (!(countries === null || countries === void 0 ? void 0 : countries.length))
|
|
@@ -70,6 +88,16 @@ export function useUserInfoForm(props) {
|
|
|
70
88
|
setFilteredCountries(countries.filter((c) => c.displayName.toLowerCase().includes(countrySearch.toLowerCase())) || []);
|
|
71
89
|
}
|
|
72
90
|
}, [countrySearch, countries]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!(countries === null || countries === void 0 ? void 0 : countries.length))
|
|
93
|
+
return;
|
|
94
|
+
if (phoneCountrySearch.trim() === "") {
|
|
95
|
+
setFilteredPhoneCountries(countries || []);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
setFilteredPhoneCountries(countries.filter((c) => c.displayName.toLowerCase().includes(phoneCountrySearch.toLowerCase())) || []);
|
|
99
|
+
}
|
|
100
|
+
}, [phoneCountrySearch, countries]);
|
|
73
101
|
useEffect(() => {
|
|
74
102
|
if (!(currencies === null || currencies === void 0 ? void 0 : currencies.length))
|
|
75
103
|
return;
|
|
@@ -89,10 +117,6 @@ export function useUserInfoForm(props) {
|
|
|
89
117
|
return;
|
|
90
118
|
const key = control.name;
|
|
91
119
|
const value = control.value;
|
|
92
|
-
// required validation
|
|
93
|
-
if (control.required && !value) {
|
|
94
|
-
jsonpointer.set(errors, key, props.fieldRequiredError);
|
|
95
|
-
}
|
|
96
120
|
// custom validation
|
|
97
121
|
if (typeof control.validationError === "function") {
|
|
98
122
|
const validate = control.validationError;
|
|
@@ -100,6 +124,11 @@ export function useUserInfoForm(props) {
|
|
|
100
124
|
if (validationError)
|
|
101
125
|
jsonpointer.set(errors, key, validationError);
|
|
102
126
|
}
|
|
127
|
+
// required validation
|
|
128
|
+
if (control.required) {
|
|
129
|
+
if (!value || (typeof value === "string" && value.trim() === ""))
|
|
130
|
+
jsonpointer.set(errors, key, props.fieldRequiredError);
|
|
131
|
+
}
|
|
103
132
|
jsonpointer.set(formData, key, value);
|
|
104
133
|
});
|
|
105
134
|
if (Object.keys(errors).length) {
|
|
@@ -110,12 +139,22 @@ export function useUserInfoForm(props) {
|
|
|
110
139
|
const { allowBankingCollection, ...userData } = formData;
|
|
111
140
|
setUserFormContext({
|
|
112
141
|
...userFormContext,
|
|
142
|
+
phoneNumberCountryCode: userData.phoneNumberCountryCode,
|
|
143
|
+
phoneNumber: userData.phoneNumber,
|
|
113
144
|
countryCode: userData.countryCode,
|
|
145
|
+
address: userData.address,
|
|
146
|
+
city: userData.city,
|
|
147
|
+
state: userData.state,
|
|
148
|
+
postalCode: userData.postalCode,
|
|
114
149
|
currency: userData.currency,
|
|
115
150
|
});
|
|
116
151
|
const nextStep = context.overrideNextStep || "/2";
|
|
117
152
|
setStep(nextStep);
|
|
118
153
|
}
|
|
154
|
+
const hasStates = ["ES", "AU", "US", "CA"].includes(userFormContext.countryCode);
|
|
155
|
+
const regionObj = hasStates
|
|
156
|
+
? ADDRESS_REGIONS[userFormContext === null || userFormContext === void 0 ? void 0 : userFormContext.countryCode]
|
|
157
|
+
: {};
|
|
119
158
|
return {
|
|
120
159
|
setStep: setStep,
|
|
121
160
|
onSubmit,
|
|
@@ -123,20 +162,26 @@ export function useUserInfoForm(props) {
|
|
|
123
162
|
callbacks: {
|
|
124
163
|
setCurrencySearch,
|
|
125
164
|
setCountrySearch,
|
|
165
|
+
setPhoneCountrySearch,
|
|
126
166
|
onFormChange,
|
|
127
167
|
},
|
|
128
168
|
refs: {
|
|
129
169
|
formRef,
|
|
130
170
|
currencyRef,
|
|
171
|
+
phoneCountryRef,
|
|
131
172
|
},
|
|
132
173
|
data: {
|
|
133
174
|
currencies: filteredCurrencies,
|
|
134
175
|
countries: filteredCountries,
|
|
176
|
+
phoneCountries: filteredPhoneCountries,
|
|
135
177
|
allCurrencies: currencies,
|
|
136
178
|
allCountries: countries,
|
|
179
|
+
regionLabelEnum: regionObj === null || regionObj === void 0 ? void 0 : regionObj.labelEnum,
|
|
180
|
+
regions: (regionObj === null || regionObj === void 0 ? void 0 : regionObj.regions) || [],
|
|
137
181
|
},
|
|
138
182
|
states: {
|
|
139
183
|
step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
|
|
184
|
+
hideState: !hasStates,
|
|
140
185
|
hideSteps: !!context.hideSteps,
|
|
141
186
|
disabled: loading,
|
|
142
187
|
loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
|