@mirai/core 0.3.170 → 0.3.173
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/build/components/Checkout/Checkout.js +3 -19
- package/build/components/Checkout/Checkout.js.map +1 -1
- package/build/components/Checkout/Checkout.module.css +0 -4
- package/build/components/Checkout/helpers/getFieldProps.js +0 -1
- package/build/components/Checkout/helpers/getFieldProps.js.map +1 -1
- package/build/components/Checkout/partials/Checkout.Confirmation.js +7 -11
- package/build/components/Checkout/partials/Checkout.Confirmation.js.map +1 -1
- package/build/components/Checkout/partials/Checkout.Form.js +2 -6
- package/build/components/Checkout/partials/Checkout.Form.js.map +1 -1
- package/build/components/Checkout/partials/__tests__/__snapshots__/Checkout.Form.test.js.snap +0 -44
- package/build/components/Profile/components/Settings/Settings.Account.js +8 -26
- package/build/components/Profile/components/Settings/Settings.Account.js.map +1 -1
- package/build/components/Profile/components/Settings/Settings.module.css +0 -4
- package/build/components/Signup/Signup.js +6 -24
- package/build/components/Signup/Signup.js.map +1 -1
- package/build/components/Signup/Signup.module.css +0 -4
- package/build/components/Signup/__tests__/__snapshots__/Signup.test.js.snap +9 -24
- package/build/components/__shared__/Payment/__tests__/__snapshots__/Payment.test.js.snap +0 -12
- package/build/components/__shared__/Payment/components/Card/Card.js +0 -4
- package/build/components/__shared__/Payment/components/Card/Card.js.map +1 -1
- package/build/components/__shared__/Payment/components/Card/__tests__/__snapshots__/Card.test.js.snap +0 -23
- package/build/components/__shared__/Payment/components/Card/helpers/formatValues.js +0 -2
- package/build/components/__shared__/Payment/components/Card/helpers/formatValues.js.map +1 -1
- package/build/components/__shared__/Payment/components/PCI/helpers/formatValues.js +0 -2
- package/build/components/__shared__/Payment/components/PCI/helpers/formatValues.js.map +1 -1
- package/build/components/__shared__/Payment/helpers/index.js +0 -11
- package/build/components/__shared__/Payment/helpers/index.js.map +1 -1
- package/build/components/__shared__/index.js +0 -11
- package/build/components/__shared__/index.js.map +1 -1
- package/package.json +1 -1
- package/build/components/__shared__/NotificationRequiredFields/NotificationRequiredFields.js +0 -52
- package/build/components/__shared__/NotificationRequiredFields/NotificationRequiredFields.js.map +0 -1
- package/build/components/__shared__/NotificationRequiredFields/NotificationRequiredFields.l10n.js +0 -62
- package/build/components/__shared__/NotificationRequiredFields/NotificationRequiredFields.l10n.js.map +0 -1
- package/build/components/__shared__/NotificationRequiredFields/NotificationRequiredFields.module.css +0 -8
- package/build/components/__shared__/NotificationRequiredFields/index.js +0 -17
- package/build/components/__shared__/NotificationRequiredFields/index.js.map +0 -1
- package/build/components/__shared__/Payment/helpers/formatExpire.js +0 -15
- package/build/components/__shared__/Payment/helpers/formatExpire.js.map +0 -1
package/build/components/Checkout/partials/__tests__/__snapshots__/Checkout.Form.test.js.snap
CHANGED
|
@@ -39,7 +39,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
39
39
|
</span>
|
|
40
40
|
<input
|
|
41
41
|
class="input input withLabel"
|
|
42
|
-
id="checkout-firstName"
|
|
43
42
|
name="firstName"
|
|
44
43
|
required=""
|
|
45
44
|
type="text"
|
|
@@ -69,7 +68,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
69
68
|
</span>
|
|
70
69
|
<input
|
|
71
70
|
class="input input withLabel"
|
|
72
|
-
id="checkout-lastName"
|
|
73
71
|
name="lastName"
|
|
74
72
|
required=""
|
|
75
73
|
type="text"
|
|
@@ -99,7 +97,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
99
97
|
</span>
|
|
100
98
|
<input
|
|
101
99
|
class="input input withLabel"
|
|
102
|
-
id="checkout-email"
|
|
103
100
|
name="email"
|
|
104
101
|
required=""
|
|
105
102
|
type="email"
|
|
@@ -127,7 +124,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
127
124
|
</span>
|
|
128
125
|
<select
|
|
129
126
|
class="select empty input prefix withLabel empty"
|
|
130
|
-
id="checkout-phone"
|
|
131
127
|
name="phone-prefix"
|
|
132
128
|
required=""
|
|
133
129
|
>
|
|
@@ -1212,7 +1208,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
1212
1208
|
</span>
|
|
1213
1209
|
<input
|
|
1214
1210
|
class="input input withLabel"
|
|
1215
|
-
id="checkout-phone"
|
|
1216
1211
|
maxlength="12"
|
|
1217
1212
|
name="phone-phone"
|
|
1218
1213
|
required=""
|
|
@@ -1239,7 +1234,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
1239
1234
|
</span>
|
|
1240
1235
|
<input
|
|
1241
1236
|
class="input input withLabel"
|
|
1242
|
-
id="checkout-company"
|
|
1243
1237
|
name="company"
|
|
1244
1238
|
type="text"
|
|
1245
1239
|
value=""
|
|
@@ -1263,7 +1257,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
1263
1257
|
</span>
|
|
1264
1258
|
<textarea
|
|
1265
1259
|
class="input input withLabel multiLine"
|
|
1266
|
-
id="checkout-comments"
|
|
1267
1260
|
name="comments"
|
|
1268
1261
|
/>
|
|
1269
1262
|
</div>
|
|
@@ -1277,7 +1270,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
1277
1270
|
<span
|
|
1278
1271
|
class="text small"
|
|
1279
1272
|
hint=""
|
|
1280
|
-
id="checkout-undefined"
|
|
1281
1273
|
label="undefined"
|
|
1282
1274
|
name="undefined"
|
|
1283
1275
|
>
|
|
@@ -1286,7 +1278,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
1286
1278
|
<div
|
|
1287
1279
|
class="pressable inputOption"
|
|
1288
1280
|
hint=""
|
|
1289
|
-
id="checkout-hotel_future_offers"
|
|
1290
1281
|
>
|
|
1291
1282
|
<div
|
|
1292
1283
|
class="checkbox"
|
|
@@ -1307,7 +1298,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
1307
1298
|
<div
|
|
1308
1299
|
class="pressable inputOption"
|
|
1309
1300
|
hint=""
|
|
1310
|
-
id="checkout-joinClub"
|
|
1311
1301
|
>
|
|
1312
1302
|
<div
|
|
1313
1303
|
class="checkbox"
|
|
@@ -1328,7 +1318,6 @@ exports[`component:<Checkout> partial:<Form> inherit:className 1`] = `
|
|
|
1328
1318
|
<div
|
|
1329
1319
|
class="pressable inputOption"
|
|
1330
1320
|
hint=""
|
|
1331
|
-
id="checkout-privacyPolicy"
|
|
1332
1321
|
>
|
|
1333
1322
|
<div
|
|
1334
1323
|
class="checkbox"
|
|
@@ -1465,7 +1454,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
1465
1454
|
</span>
|
|
1466
1455
|
<input
|
|
1467
1456
|
class="input input withLabel"
|
|
1468
|
-
id="checkout-firstName"
|
|
1469
1457
|
name="firstName"
|
|
1470
1458
|
required=""
|
|
1471
1459
|
type="text"
|
|
@@ -1495,7 +1483,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
1495
1483
|
</span>
|
|
1496
1484
|
<input
|
|
1497
1485
|
class="input input withLabel"
|
|
1498
|
-
id="checkout-lastName"
|
|
1499
1486
|
name="lastName"
|
|
1500
1487
|
required=""
|
|
1501
1488
|
type="text"
|
|
@@ -1525,7 +1512,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
1525
1512
|
</span>
|
|
1526
1513
|
<input
|
|
1527
1514
|
class="input input withLabel"
|
|
1528
|
-
id="checkout-email"
|
|
1529
1515
|
name="email"
|
|
1530
1516
|
required=""
|
|
1531
1517
|
type="email"
|
|
@@ -1553,7 +1539,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
1553
1539
|
</span>
|
|
1554
1540
|
<select
|
|
1555
1541
|
class="select empty input prefix withLabel empty"
|
|
1556
|
-
id="checkout-phone"
|
|
1557
1542
|
name="phone-prefix"
|
|
1558
1543
|
required=""
|
|
1559
1544
|
>
|
|
@@ -2638,7 +2623,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
2638
2623
|
</span>
|
|
2639
2624
|
<input
|
|
2640
2625
|
class="input input withLabel"
|
|
2641
|
-
id="checkout-phone"
|
|
2642
2626
|
maxlength="12"
|
|
2643
2627
|
name="phone-phone"
|
|
2644
2628
|
required=""
|
|
@@ -2665,7 +2649,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
2665
2649
|
</span>
|
|
2666
2650
|
<input
|
|
2667
2651
|
class="input input withLabel"
|
|
2668
|
-
id="checkout-company"
|
|
2669
2652
|
name="company"
|
|
2670
2653
|
type="text"
|
|
2671
2654
|
value=""
|
|
@@ -2689,7 +2672,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
2689
2672
|
</span>
|
|
2690
2673
|
<textarea
|
|
2691
2674
|
class="input input withLabel multiLine"
|
|
2692
|
-
id="checkout-comments"
|
|
2693
2675
|
name="comments"
|
|
2694
2676
|
/>
|
|
2695
2677
|
</div>
|
|
@@ -2703,7 +2685,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
2703
2685
|
<span
|
|
2704
2686
|
class="text small"
|
|
2705
2687
|
hint=""
|
|
2706
|
-
id="checkout-undefined"
|
|
2707
2688
|
label="undefined"
|
|
2708
2689
|
name="undefined"
|
|
2709
2690
|
>
|
|
@@ -2712,7 +2693,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
2712
2693
|
<div
|
|
2713
2694
|
class="pressable inputOption"
|
|
2714
2695
|
hint=""
|
|
2715
|
-
id="checkout-hotel_future_offers"
|
|
2716
2696
|
>
|
|
2717
2697
|
<div
|
|
2718
2698
|
class="checkbox"
|
|
@@ -2733,7 +2713,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
2733
2713
|
<div
|
|
2734
2714
|
class="pressable inputOption"
|
|
2735
2715
|
hint=""
|
|
2736
|
-
id="checkout-joinClub"
|
|
2737
2716
|
>
|
|
2738
2717
|
<div
|
|
2739
2718
|
class="checkbox"
|
|
@@ -2754,7 +2733,6 @@ exports[`component:<Checkout> partial:<Form> renders 1`] = `
|
|
|
2754
2733
|
<div
|
|
2755
2734
|
class="pressable inputOption"
|
|
2756
2735
|
hint=""
|
|
2757
|
-
id="checkout-privacyPolicy"
|
|
2758
2736
|
>
|
|
2759
2737
|
<div
|
|
2760
2738
|
class="checkbox"
|
|
@@ -2892,7 +2870,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
2892
2870
|
</span>
|
|
2893
2871
|
<input
|
|
2894
2872
|
class="input input withLabel"
|
|
2895
|
-
id="checkout-firstName"
|
|
2896
2873
|
name="firstName"
|
|
2897
2874
|
required=""
|
|
2898
2875
|
type="text"
|
|
@@ -2922,7 +2899,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
2922
2899
|
</span>
|
|
2923
2900
|
<input
|
|
2924
2901
|
class="input input withLabel"
|
|
2925
|
-
id="checkout-lastName"
|
|
2926
2902
|
name="lastName"
|
|
2927
2903
|
required=""
|
|
2928
2904
|
type="text"
|
|
@@ -2952,7 +2928,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
2952
2928
|
</span>
|
|
2953
2929
|
<input
|
|
2954
2930
|
class="input input withLabel"
|
|
2955
|
-
id="checkout-email"
|
|
2956
2931
|
name="email"
|
|
2957
2932
|
required=""
|
|
2958
2933
|
type="email"
|
|
@@ -2980,7 +2955,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
2980
2955
|
</span>
|
|
2981
2956
|
<select
|
|
2982
2957
|
class="select empty input prefix withLabel empty"
|
|
2983
|
-
id="checkout-phone"
|
|
2984
2958
|
name="phone-prefix"
|
|
2985
2959
|
required=""
|
|
2986
2960
|
>
|
|
@@ -4065,7 +4039,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
4065
4039
|
</span>
|
|
4066
4040
|
<input
|
|
4067
4041
|
class="input input withLabel"
|
|
4068
|
-
id="checkout-phone"
|
|
4069
4042
|
maxlength="12"
|
|
4070
4043
|
name="phone-phone"
|
|
4071
4044
|
required=""
|
|
@@ -4092,7 +4065,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
4092
4065
|
</span>
|
|
4093
4066
|
<input
|
|
4094
4067
|
class="input input withLabel"
|
|
4095
|
-
id="checkout-company"
|
|
4096
4068
|
name="company"
|
|
4097
4069
|
type="text"
|
|
4098
4070
|
value=""
|
|
@@ -4116,7 +4088,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
4116
4088
|
</span>
|
|
4117
4089
|
<textarea
|
|
4118
4090
|
class="input input withLabel multiLine"
|
|
4119
|
-
id="checkout-comments"
|
|
4120
4091
|
name="comments"
|
|
4121
4092
|
/>
|
|
4122
4093
|
</div>
|
|
@@ -4130,7 +4101,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
4130
4101
|
<span
|
|
4131
4102
|
class="text small"
|
|
4132
4103
|
hint=""
|
|
4133
|
-
id="checkout-undefined"
|
|
4134
4104
|
label="undefined"
|
|
4135
4105
|
name="undefined"
|
|
4136
4106
|
>
|
|
@@ -4139,7 +4109,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
4139
4109
|
<div
|
|
4140
4110
|
class="pressable inputOption"
|
|
4141
4111
|
hint=""
|
|
4142
|
-
id="checkout-hotel_future_offers"
|
|
4143
4112
|
>
|
|
4144
4113
|
<div
|
|
4145
4114
|
class="checkbox"
|
|
@@ -4160,7 +4129,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
4160
4129
|
<div
|
|
4161
4130
|
class="pressable inputOption"
|
|
4162
4131
|
hint=""
|
|
4163
|
-
id="checkout-joinClub"
|
|
4164
4132
|
>
|
|
4165
4133
|
<div
|
|
4166
4134
|
class="checkbox"
|
|
@@ -4181,7 +4149,6 @@ exports[`component:<Checkout> partial:<Form> testID 1`] = `
|
|
|
4181
4149
|
<div
|
|
4182
4150
|
class="pressable inputOption"
|
|
4183
4151
|
hint=""
|
|
4184
|
-
id="checkout-privacyPolicy"
|
|
4185
4152
|
>
|
|
4186
4153
|
<div
|
|
4187
4154
|
class="checkbox"
|
|
@@ -4318,7 +4285,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
4318
4285
|
</span>
|
|
4319
4286
|
<input
|
|
4320
4287
|
class="input input withLabel"
|
|
4321
|
-
id="checkout-firstName"
|
|
4322
4288
|
name="firstName"
|
|
4323
4289
|
required=""
|
|
4324
4290
|
type="text"
|
|
@@ -4348,7 +4314,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
4348
4314
|
</span>
|
|
4349
4315
|
<input
|
|
4350
4316
|
class="input input withLabel"
|
|
4351
|
-
id="checkout-lastName"
|
|
4352
4317
|
name="lastName"
|
|
4353
4318
|
required=""
|
|
4354
4319
|
type="text"
|
|
@@ -4378,7 +4343,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
4378
4343
|
</span>
|
|
4379
4344
|
<input
|
|
4380
4345
|
class="input input withLabel"
|
|
4381
|
-
id="checkout-email"
|
|
4382
4346
|
name="email"
|
|
4383
4347
|
required=""
|
|
4384
4348
|
type="email"
|
|
@@ -4406,7 +4370,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
4406
4370
|
</span>
|
|
4407
4371
|
<select
|
|
4408
4372
|
class="select empty input prefix withLabel empty"
|
|
4409
|
-
id="checkout-phone"
|
|
4410
4373
|
name="phone-prefix"
|
|
4411
4374
|
required=""
|
|
4412
4375
|
>
|
|
@@ -5491,7 +5454,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
5491
5454
|
</span>
|
|
5492
5455
|
<input
|
|
5493
5456
|
class="input input withLabel"
|
|
5494
|
-
id="checkout-phone"
|
|
5495
5457
|
maxlength="12"
|
|
5496
5458
|
name="phone-phone"
|
|
5497
5459
|
required=""
|
|
@@ -5518,7 +5480,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
5518
5480
|
</span>
|
|
5519
5481
|
<input
|
|
5520
5482
|
class="input input withLabel"
|
|
5521
|
-
id="checkout-company"
|
|
5522
5483
|
name="company"
|
|
5523
5484
|
type="text"
|
|
5524
5485
|
value=""
|
|
@@ -5542,7 +5503,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
5542
5503
|
</span>
|
|
5543
5504
|
<textarea
|
|
5544
5505
|
class="input input withLabel multiLine"
|
|
5545
|
-
id="checkout-comments"
|
|
5546
5506
|
name="comments"
|
|
5547
5507
|
/>
|
|
5548
5508
|
</div>
|
|
@@ -5556,7 +5516,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
5556
5516
|
<span
|
|
5557
5517
|
class="text small"
|
|
5558
5518
|
hint=""
|
|
5559
|
-
id="checkout-undefined"
|
|
5560
5519
|
label="undefined"
|
|
5561
5520
|
name="undefined"
|
|
5562
5521
|
>
|
|
@@ -5565,7 +5524,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
5565
5524
|
<div
|
|
5566
5525
|
class="pressable inputOption"
|
|
5567
5526
|
hint=""
|
|
5568
|
-
id="checkout-hotel_future_offers"
|
|
5569
5527
|
>
|
|
5570
5528
|
<div
|
|
5571
5529
|
class="checkbox"
|
|
@@ -5586,7 +5544,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
5586
5544
|
<div
|
|
5587
5545
|
class="pressable inputOption"
|
|
5588
5546
|
hint=""
|
|
5589
|
-
id="checkout-joinClub"
|
|
5590
5547
|
>
|
|
5591
5548
|
<div
|
|
5592
5549
|
class="checkbox"
|
|
@@ -5607,7 +5564,6 @@ exports[`component:<Checkout> partial:<Form> with a store 1`] = `
|
|
|
5607
5564
|
<div
|
|
5608
5565
|
class="pressable inputOption"
|
|
5609
5566
|
hint=""
|
|
5610
|
-
id="checkout-privacyPolicy"
|
|
5611
5567
|
>
|
|
5612
5568
|
<div
|
|
5613
5569
|
class="checkbox"
|
|
@@ -32,7 +32,6 @@ const Account = () => {
|
|
|
32
32
|
const [countries, setCountries] = (0, _react.useState)({});
|
|
33
33
|
const [form, setForm] = (0, _react.useState)(session);
|
|
34
34
|
const [formError, setFormError] = (0, _react.useState)({});
|
|
35
|
-
const [requiredFields, setRequiredFields] = (0, _react.useState)();
|
|
36
35
|
const [responseError, setResponseError] = (0, _react.useState)();
|
|
37
36
|
const formatDate = (0, _locale.getDateFormat)(locale);
|
|
38
37
|
(0, _react.useEffect)(() => {
|
|
@@ -55,16 +54,7 @@ const Account = () => {
|
|
|
55
54
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
55
|
}, [locale]);
|
|
57
56
|
const handleSubmit = async form => {
|
|
58
|
-
const hasErrors = Object.keys(formError).length !== 0;
|
|
59
|
-
if (hasErrors) {
|
|
60
|
-
window.scrollTo({
|
|
61
|
-
top: 0,
|
|
62
|
-
behavior: 'smooth'
|
|
63
|
-
});
|
|
64
|
-
return setRequiredFields(formError);
|
|
65
|
-
}
|
|
66
57
|
setBusy(true);
|
|
67
|
-
setRequiredFields();
|
|
68
58
|
setResponseError(undefined);
|
|
69
59
|
const parameters = {
|
|
70
60
|
...form,
|
|
@@ -93,21 +83,17 @@ const Account = () => {
|
|
|
93
83
|
const countryCode = (0, _helpers.getCountryCode)(form.country, countries);
|
|
94
84
|
const has = {
|
|
95
85
|
changes: _Settings.ACCOUNT_FIELDS.some(key => form[key] !== session[key]) || countryCode !== session.country,
|
|
96
|
-
dateOfBirth: (_form$dateOfBirth = form.dateOfBirth) === null || _form$dateOfBirth === void 0 ? void 0 : _form$dateOfBirth.length
|
|
86
|
+
dateOfBirth: (_form$dateOfBirth = form.dateOfBirth) === null || _form$dateOfBirth === void 0 ? void 0 : _form$dateOfBirth.length,
|
|
87
|
+
errors: Object.keys(formError).length !== 0
|
|
97
88
|
};
|
|
98
|
-
const hasRequiredFields = Object.keys(requiredFields || {}).length > 0;
|
|
99
89
|
return /*#__PURE__*/_react.default.createElement(_ui.Form, {
|
|
100
90
|
validateOnMount: true,
|
|
101
91
|
onChange: setForm,
|
|
102
92
|
onError: setFormError,
|
|
103
93
|
onSubmit: handleSubmit
|
|
104
|
-
},
|
|
105
|
-
form: "account",
|
|
106
|
-
values: requiredFields
|
|
107
|
-
}), /*#__PURE__*/_react.default.createElement(_ui.Text, {
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Text, {
|
|
108
95
|
wide: true
|
|
109
96
|
}, translate(_Settings2.L10N.DESCRIPTION_ACCOUNT)), /*#__PURE__*/_react.default.createElement(_shared__.TextRequiredFields, null), /*#__PURE__*/_react.default.createElement(_ui.InputText, {
|
|
110
|
-
id: "account-firstName",
|
|
111
97
|
name: "firstName",
|
|
112
98
|
error: formError.firstName,
|
|
113
99
|
label: translate(_Settings2.L10N.FIRSTNAME_LABEL),
|
|
@@ -116,7 +102,6 @@ const Account = () => {
|
|
|
116
102
|
success: form.firstName !== session.firstName,
|
|
117
103
|
value: form.firstName
|
|
118
104
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputText, {
|
|
119
|
-
id: "account-lastName",
|
|
120
105
|
name: "lastName",
|
|
121
106
|
error: formError.lastName,
|
|
122
107
|
label: translate(_Settings2.L10N.LASTNAME_LABEL),
|
|
@@ -125,7 +110,6 @@ const Account = () => {
|
|
|
125
110
|
success: form.lastName !== session.lastName,
|
|
126
111
|
value: form.lastName
|
|
127
112
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputText, {
|
|
128
|
-
id: "account-email",
|
|
129
113
|
name: "email",
|
|
130
114
|
disabled: true,
|
|
131
115
|
label: translate(_Settings2.L10N.EMAIL_LABEL),
|
|
@@ -134,7 +118,6 @@ const Account = () => {
|
|
|
134
118
|
type: "email",
|
|
135
119
|
value: form.email
|
|
136
120
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputDate, {
|
|
137
|
-
id: "account-dateOfBirth",
|
|
138
121
|
name: "dateOfBirth",
|
|
139
122
|
error: has.dateOfBirth && !!formError.dateOfBirth,
|
|
140
123
|
hint: has.dateOfBirth && (_formError$dateOfBirt = formError.dateOfBirth) !== null && _formError$dateOfBirt !== void 0 && _formError$dateOfBirt.max ? translate(_Settings2.L10N.DATEOFBIRTH_ERROR) : undefined,
|
|
@@ -149,14 +132,12 @@ const Account = () => {
|
|
|
149
132
|
type: "inputDate",
|
|
150
133
|
value: form.dateOfBirth
|
|
151
134
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputSelect, {
|
|
152
|
-
id: "account-country",
|
|
153
135
|
name: "country",
|
|
154
136
|
label: translate(_Settings2.L10N.COUNTRY_LABEL),
|
|
155
137
|
placeholder: translate(_Settings2.L10N.COUNTRY_PLACEHOLDER),
|
|
156
|
-
options: Object.values(countries)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
,
|
|
138
|
+
options: Object.values(countries),
|
|
139
|
+
required: true,
|
|
140
|
+
showRequired: true,
|
|
160
141
|
success: countryCode !== session.country,
|
|
161
142
|
value: form.country
|
|
162
143
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputOption, {
|
|
@@ -171,9 +152,10 @@ const Account = () => {
|
|
|
171
152
|
className: style.notification
|
|
172
153
|
}, translate(_Settings2.L10N.ERROR)), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
173
154
|
busy: busy,
|
|
155
|
+
disabled: busy || has.errors || !has.changes,
|
|
174
156
|
large: true,
|
|
175
157
|
wide: true,
|
|
176
|
-
|
|
158
|
+
type: "submit"
|
|
177
159
|
}, translate(_Settings2.L10N.CTA_ACCOUNT)));
|
|
178
160
|
};
|
|
179
161
|
exports.Account = Account;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.Account.js","names":["_dataSources","require","_locale","_services","_ui","_react","_interopRequireWildcard","_Settings","_Settings2","style","_shared__","_helpers","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Account","_form$dateOfBirth","_formError$dateOfBirt","value","locale","session","useStore","translate","useLocale","busy","setBusy","useState","countries","setCountries","form","setForm","formError","setFormError","requiredFields","setRequiredFields","responseError","setResponseError","formatDate","getDateFormat","useEffect","profile","next","ServiceCountry","list","country","handleSubmit","hasErrors","keys","length","window","scrollTo","top","behavior","undefined","parameters","getCountryCode","dateOfBirth","dateFormat","parseDate","format","response","ServiceUser","update","catch","error","Event","publish","EVENT","NOTIFICATION","success","L10N","SUCCESS_ACCOUNT","countryCode","changes","ACCOUNT_FIELDS","some","key","hasRequiredFields","createElement","Form","validateOnMount","onChange","onError","onSubmit","NotificationRequiredFields","values","Text","wide","DESCRIPTION_ACCOUNT","TextRequiredFields","InputText","id","name","firstName","label","FIRSTNAME_LABEL","required","showRequired","lastName","LASTNAME_LABEL","disabled","EMAIL_LABEL","type","email","InputDate","hint","max","DATEOFBIRTH_ERROR","DATEOFBIRTH_LABEL","dateCalc","Date","InputSelect","COUNTRY_LABEL","placeholder","COUNTRY_PLACEHOLDER","options","InputOption","checked","subscribed","SUBSCRIBED_LABEL","small","Notification","className","notification","ERROR","Button","large","onPress","CTA_ACCOUNT","exports","displayName","propTypes"],"sources":["../../../../../src/components/Profile/components/Settings/Settings.Account.jsx"],"sourcesContent":["import { Event, useStore } from '@mirai/data-sources';\nimport { dateCalc, dateFormat, getDateFormat, parseDate, useLocale } from '@mirai/locale';\nimport { ServiceCountry, ServiceUser } from '@mirai/services';\nimport { Button, Form, InputDate, InputOption, InputSelect, InputText, Notification, Text } from '@mirai/ui';\nimport React, { useEffect, useState } from 'react';\n\nimport { ACCOUNT_FIELDS } from './Settings.constants';\nimport { L10N } from './Settings.l10n';\nimport * as style from './Settings.module.css';\nimport { NotificationRequiredFields, TextRequiredFields } from '../../../__shared__';\nimport { EVENT, getCountryCode } from '../../../helpers';\n\nconst Account = () => {\n const {\n set,\n value: { locale, session = {} },\n } = useStore();\n const { translate } = useLocale();\n\n const [busy, setBusy] = useState(false);\n const [countries, setCountries] = useState({});\n const [form, setForm] = useState(session);\n const [formError, setFormError] = useState({});\n const [requiredFields, setRequiredFields] = useState();\n const [responseError, setResponseError] = useState();\n\n const formatDate = getDateFormat(locale);\n\n useEffect(() => {\n setResponseError();\n set({ profile: form });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [form]);\n\n useEffect(() => {\n (async () => {\n const next = (await ServiceCountry.list(locale)) || {};\n\n setCountries(next);\n setForm({ ...form, country: next[session.country] });\n })();\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [locale]);\n\n const handleSubmit = async (form) => {\n const hasErrors = Object.keys(formError).length !== 0;\n if (hasErrors) {\n window.scrollTo({ top: 0, behavior: 'smooth' });\n return setRequiredFields(formError);\n }\n\n setBusy(true);\n setRequiredFields();\n setResponseError(undefined);\n\n const parameters = {\n ...form,\n country: getCountryCode(form.country, countries),\n dateOfBirth: dateFormat(parseDate(form.dateOfBirth, formatDate), { format: 'DD/MM/YYYY' }),\n };\n\n const response = await ServiceUser.update(parameters).catch((error) => {\n setResponseError(error);\n });\n\n if (response) {\n Event.publish(EVENT.NOTIFICATION, { success: true, ...L10N.SUCCESS_ACCOUNT });\n set({ session: { ...session, ...parameters } });\n }\n setBusy(false);\n };\n\n const countryCode = getCountryCode(form.country, countries);\n const has = {\n changes: ACCOUNT_FIELDS.some((key) => form[key] !== session[key]) || countryCode !== session.country,\n dateOfBirth: form.dateOfBirth?.length,\n };\n const hasRequiredFields = Object.keys(requiredFields || {}).length > 0;\n\n return (\n <Form validateOnMount onChange={setForm} onError={setFormError} onSubmit={handleSubmit}>\n {hasRequiredFields && <NotificationRequiredFields form=\"account\" values={requiredFields} />}\n\n <Text wide>{translate(L10N.DESCRIPTION_ACCOUNT)}</Text>\n <TextRequiredFields />\n <InputText\n id=\"account-firstName\"\n name=\"firstName\"\n error={formError.firstName}\n label={translate(L10N.FIRSTNAME_LABEL)}\n required\n showRequired\n success={form.firstName !== session.firstName}\n value={form.firstName}\n />\n <InputText\n id=\"account-lastName\"\n name=\"lastName\"\n error={formError.lastName}\n label={translate(L10N.LASTNAME_LABEL)}\n required\n showRequired\n success={form.lastName !== session.lastName}\n value={form.lastName}\n />\n <InputText\n id=\"account-email\"\n name=\"email\"\n disabled\n label={translate(L10N.EMAIL_LABEL)}\n required\n showRequired\n type=\"email\"\n value={form.email}\n />\n <InputDate\n id=\"account-dateOfBirth\"\n name=\"dateOfBirth\"\n error={has.dateOfBirth && !!formError.dateOfBirth}\n hint={has.dateOfBirth && formError.dateOfBirth?.max ? translate(L10N.DATEOFBIRTH_ERROR) : undefined}\n format={formatDate}\n label={translate(L10N.DATEOFBIRTH_LABEL)}\n max={dateFormat(dateCalc(new Date(), -18, 'years'), { format: formatDate })}\n required\n showRequired\n success={form.dateOfBirth !== session.dateOfBirth}\n type=\"inputDate\"\n value={form.dateOfBirth}\n />\n <InputSelect\n id=\"account-country\"\n name=\"country\"\n label={translate(L10N.COUNTRY_LABEL)}\n placeholder={translate(L10N.COUNTRY_PLACEHOLDER)}\n options={Object.values(countries)}\n // required\n // showRequired\n success={countryCode !== session.country}\n value={form.country}\n />\n <InputOption\n name=\"subscribed\"\n checked={form.subscribed}\n type=\"checkbox\"\n label={translate(L10N.SUBSCRIBED_LABEL)}\n small\n value={form.subscribed}\n />\n\n {responseError && (\n <Notification error className={style.notification}>\n {translate(L10N.ERROR)}\n </Notification>\n )}\n\n <Button busy={busy} large wide onPress={handleSubmit}>\n {translate(L10N.CTA_ACCOUNT)}\n </Button>\n </Form>\n );\n};\n\nAccount.displayName = 'Mirai:Core:Profile:Account';\n\nAccount.propTypes = {};\n\nexport { Account };\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE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AI,EAAC,UAAU;IACfR,KAAK,EAAExE,SAAS,CAACgD,eAAI,CAACiD,gBAAgB,CAAE;IACxCC,KAAK;IACLtG,KAAK,EAAEW,IAAI,CAACyF;EAAW,CACxB,CAAC,EAEDnF,aAAa,iBACZhD,MAAA,CAAAa,OAAA,CAAA8E,aAAA,CAAC5F,GAAA,CAAAuI,YAAY;IAACzD,KAAK;IAAC0D,SAAS,EAAEnI,KAAK,CAACoI;EAAa,GAC/CrG,SAAS,CAACgD,eAAI,CAACsD,KAAK,CACT,CACf,eAEDzI,MAAA,CAAAa,OAAA,CAAA8E,aAAA,CAAC5F,GAAA,CAAA2I,MAAM;IAACrG,IAAI,EAAEA,IAAK;IAACsG,KAAK;IAACvC,IAAI;IAACwC,OAAO,EAAElF;EAAa,GAClDvB,SAAS,CAACgD,eAAI,CAAC0D,WAAW,CACrB,CACJ,CAAC;AAEX,CAAC;AAACC,OAAA,CAAAlH,OAAA,GAAAA,OAAA;AAEFA,OAAO,CAACmH,WAAW,GAAG,4BAA4B;AAElDnH,OAAO,CAACoH,SAAS,GAAG,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Settings.Account.js","names":["_dataSources","require","_locale","_services","_ui","_react","_interopRequireWildcard","_Settings","_Settings2","style","_shared__","_helpers","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Account","_form$dateOfBirth","_formError$dateOfBirt","value","locale","session","useStore","translate","useLocale","busy","setBusy","useState","countries","setCountries","form","setForm","formError","setFormError","responseError","setResponseError","formatDate","getDateFormat","useEffect","profile","next","ServiceCountry","list","country","handleSubmit","undefined","parameters","getCountryCode","dateOfBirth","dateFormat","parseDate","format","response","ServiceUser","update","catch","error","Event","publish","EVENT","NOTIFICATION","success","L10N","SUCCESS_ACCOUNT","countryCode","changes","ACCOUNT_FIELDS","some","key","length","errors","keys","createElement","Form","validateOnMount","onChange","onError","onSubmit","Text","wide","DESCRIPTION_ACCOUNT","TextRequiredFields","InputText","name","firstName","label","FIRSTNAME_LABEL","required","showRequired","lastName","LASTNAME_LABEL","disabled","EMAIL_LABEL","type","email","InputDate","hint","max","DATEOFBIRTH_ERROR","DATEOFBIRTH_LABEL","dateCalc","Date","InputSelect","COUNTRY_LABEL","placeholder","COUNTRY_PLACEHOLDER","options","values","InputOption","checked","subscribed","SUBSCRIBED_LABEL","small","Notification","className","notification","ERROR","Button","large","CTA_ACCOUNT","exports","displayName","propTypes"],"sources":["../../../../../src/components/Profile/components/Settings/Settings.Account.jsx"],"sourcesContent":["import { Event, useStore } from '@mirai/data-sources';\nimport { dateCalc, dateFormat, getDateFormat, parseDate, useLocale } from '@mirai/locale';\nimport { ServiceCountry, ServiceUser } from '@mirai/services';\nimport { Button, Form, InputDate, InputOption, InputSelect, InputText, Notification, Text } from '@mirai/ui';\nimport React, { useEffect, useState } from 'react';\n\nimport { ACCOUNT_FIELDS } from './Settings.constants';\nimport { L10N } from './Settings.l10n';\nimport * as style from './Settings.module.css';\nimport { TextRequiredFields } from '../../../__shared__';\nimport { EVENT, getCountryCode } from '../../../helpers';\n\nconst Account = () => {\n const {\n set,\n value: { locale, session = {} },\n } = useStore();\n const { translate } = useLocale();\n\n const [busy, setBusy] = useState(false);\n const [countries, setCountries] = useState({});\n const [form, setForm] = useState(session);\n const [formError, setFormError] = useState({});\n const [responseError, setResponseError] = useState();\n\n const formatDate = getDateFormat(locale);\n\n useEffect(() => {\n setResponseError();\n set({ profile: form });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [form]);\n\n useEffect(() => {\n (async () => {\n const next = (await ServiceCountry.list(locale)) || {};\n\n setCountries(next);\n setForm({ ...form, country: next[session.country] });\n })();\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [locale]);\n\n const handleSubmit = async (form) => {\n setBusy(true);\n setResponseError(undefined);\n\n const parameters = {\n ...form,\n country: getCountryCode(form.country, countries),\n dateOfBirth: dateFormat(parseDate(form.dateOfBirth, formatDate), { format: 'DD/MM/YYYY' }),\n };\n\n const response = await ServiceUser.update(parameters).catch((error) => {\n setResponseError(error);\n });\n\n if (response) {\n Event.publish(EVENT.NOTIFICATION, { success: true, ...L10N.SUCCESS_ACCOUNT });\n set({ session: { ...session, ...parameters } });\n }\n setBusy(false);\n };\n\n const countryCode = getCountryCode(form.country, countries);\n const has = {\n changes: ACCOUNT_FIELDS.some((key) => form[key] !== session[key]) || countryCode !== session.country,\n dateOfBirth: form.dateOfBirth?.length,\n errors: Object.keys(formError).length !== 0,\n };\n\n return (\n <Form validateOnMount onChange={setForm} onError={setFormError} onSubmit={handleSubmit}>\n <Text wide>{translate(L10N.DESCRIPTION_ACCOUNT)}</Text>\n <TextRequiredFields />\n <InputText\n name=\"firstName\"\n error={formError.firstName}\n label={translate(L10N.FIRSTNAME_LABEL)}\n required\n showRequired\n success={form.firstName !== session.firstName}\n value={form.firstName}\n />\n <InputText\n name=\"lastName\"\n error={formError.lastName}\n label={translate(L10N.LASTNAME_LABEL)}\n required\n showRequired\n success={form.lastName !== session.lastName}\n value={form.lastName}\n />\n <InputText\n name=\"email\"\n disabled\n label={translate(L10N.EMAIL_LABEL)}\n required\n showRequired\n type=\"email\"\n value={form.email}\n />\n <InputDate\n name=\"dateOfBirth\"\n error={has.dateOfBirth && !!formError.dateOfBirth}\n hint={has.dateOfBirth && formError.dateOfBirth?.max ? translate(L10N.DATEOFBIRTH_ERROR) : undefined}\n format={formatDate}\n label={translate(L10N.DATEOFBIRTH_LABEL)}\n max={dateFormat(dateCalc(new Date(), -18, 'years'), { format: formatDate })}\n required\n showRequired\n success={form.dateOfBirth !== session.dateOfBirth}\n type=\"inputDate\"\n value={form.dateOfBirth}\n />\n <InputSelect\n name=\"country\"\n label={translate(L10N.COUNTRY_LABEL)}\n placeholder={translate(L10N.COUNTRY_PLACEHOLDER)}\n options={Object.values(countries)}\n required\n showRequired\n success={countryCode !== session.country}\n value={form.country}\n />\n <InputOption\n name=\"subscribed\"\n checked={form.subscribed}\n type=\"checkbox\"\n label={translate(L10N.SUBSCRIBED_LABEL)}\n small\n value={form.subscribed}\n />\n\n {responseError && (\n <Notification error className={style.notification}>\n {translate(L10N.ERROR)}\n </Notification>\n )}\n\n <Button busy={busy} disabled={busy || has.errors || !has.changes} large wide type=\"submit\">\n {translate(L10N.CTA_ACCOUNT)}\n </Button>\n </Form>\n );\n};\n\nAccount.displayName = 'Mirai:Core:Profile:Account';\n\nAccount.propTypes = {};\n\nexport { Account };\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,GAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAC,uBAAA,CAAAL,OAAA;AAEA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAH,uBAAA,CAAAL,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAAyD,SAAAW,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,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1H,KAAK,CAAC2H;EAAa,GAC/C5F,SAAS,CAACuC,eAAI,CAACsD,KAAK,CACT,CACf,eAEDhI,MAAA,CAAAa,OAAA,CAAAuE,aAAA,CAACrF,GAAA,CAAAkI,MAAM;IAAC5F,IAAI,EAAEA,IAAK;IAACkE,QAAQ,EAAElE,IAAI,IAAIvB,GAAG,CAACoE,MAAM,IAAI,CAACpE,GAAG,CAAC+D,OAAQ;IAACqD,KAAK;IAACvC,IAAI;IAACc,IAAI,EAAC;EAAQ,GACvFtE,SAAS,CAACuC,eAAI,CAACyD,WAAW,CACrB,CACJ,CAAC;AAEX,CAAC;AAACC,OAAA,CAAAxG,OAAA,GAAAA,OAAA;AAEFA,OAAO,CAACyG,WAAW,GAAG,4BAA4B;AAElDzG,OAAO,CAAC0G,SAAS,GAAG,CAAC,CAAC"}
|
|
@@ -34,7 +34,6 @@ const Signup = others => {
|
|
|
34
34
|
subscribed: true
|
|
35
35
|
});
|
|
36
36
|
const [formError, setFormError] = (0, _react.useState)({});
|
|
37
|
-
const [requiredFields, setRequiredFields] = (0, _react.useState)();
|
|
38
37
|
const [response, setResponse] = (0, _react.useState)();
|
|
39
38
|
const [responseError, setResponseError] = (0, _react.useState)();
|
|
40
39
|
const [language, country] = locale.split('-');
|
|
@@ -57,17 +56,8 @@ const Signup = others => {
|
|
|
57
56
|
|
|
58
57
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
58
|
}, [locale]);
|
|
60
|
-
const handleSubmit = async
|
|
61
|
-
const hasErrors = Object.keys(formError).length !== 0;
|
|
62
|
-
if (hasErrors) {
|
|
63
|
-
window.scrollTo({
|
|
64
|
-
top: 0,
|
|
65
|
-
behavior: 'smooth'
|
|
66
|
-
});
|
|
67
|
-
return setRequiredFields(formError);
|
|
68
|
-
}
|
|
59
|
+
const handleSubmit = async form => {
|
|
69
60
|
setBusy(true);
|
|
70
|
-
setRequiredFields();
|
|
71
61
|
setResponseError(undefined);
|
|
72
62
|
const response = await _services.ServiceUser.signup({
|
|
73
63
|
...form,
|
|
@@ -84,7 +74,7 @@ const Signup = others => {
|
|
|
84
74
|
setResponse(response);
|
|
85
75
|
setBusy(false);
|
|
86
76
|
};
|
|
87
|
-
const
|
|
77
|
+
const hasErrors = Object.keys(formError).length !== 0;
|
|
88
78
|
return /*#__PURE__*/_react.default.createElement(_ui.View, {
|
|
89
79
|
role: "signup",
|
|
90
80
|
className: style.container
|
|
@@ -101,17 +91,14 @@ const Signup = others => {
|
|
|
101
91
|
className: style.description
|
|
102
92
|
}, translate(_Signup.L10N.DESCRIPTION, {
|
|
103
93
|
clubName: club.name
|
|
104
|
-
}))),
|
|
105
|
-
form: "signup",
|
|
106
|
-
values: requiredFields
|
|
107
|
-
}), !response && /*#__PURE__*/_react.default.createElement(_ui.Form, {
|
|
94
|
+
}))), !response && /*#__PURE__*/_react.default.createElement(_ui.Form, {
|
|
108
95
|
validateOnMount: true,
|
|
109
96
|
onChange: setForm,
|
|
110
97
|
onError: setFormError,
|
|
98
|
+
onSubmit: handleSubmit,
|
|
111
99
|
testId: others.testId,
|
|
112
100
|
className: (0, _ui.styles)(style.form, others.className)
|
|
113
101
|
}, /*#__PURE__*/_react.default.createElement(_shared__.TextRequiredFields, null), /*#__PURE__*/_react.default.createElement(_ui.InputText, {
|
|
114
|
-
id: "signup-firstName",
|
|
115
102
|
name: "firstName",
|
|
116
103
|
label: translate(_Signup.L10N.FIRSTNAME_LABEL),
|
|
117
104
|
required: true,
|
|
@@ -119,7 +106,6 @@ const Signup = others => {
|
|
|
119
106
|
success: ((_form$firstName = form.firstName) === null || _form$firstName === void 0 ? void 0 : _form$firstName.length) && !formError.firstName,
|
|
120
107
|
value: form.firstName
|
|
121
108
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputText, {
|
|
122
|
-
id: "signup-lastName",
|
|
123
109
|
name: "lastName",
|
|
124
110
|
label: translate(_Signup.L10N.LASTNAME_LABEL),
|
|
125
111
|
required: true,
|
|
@@ -127,7 +113,6 @@ const Signup = others => {
|
|
|
127
113
|
success: ((_form$lastName = form.lastName) === null || _form$lastName === void 0 ? void 0 : _form$lastName.length) && !formError.lastName,
|
|
128
114
|
value: form.lastName
|
|
129
115
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputText, {
|
|
130
|
-
id: "signup-email",
|
|
131
116
|
name: "email",
|
|
132
117
|
error: ((_form$email = form.email) === null || _form$email === void 0 ? void 0 : _form$email.length) && !!formError.email,
|
|
133
118
|
label: translate(_Signup.L10N.EMAIL_LABEL),
|
|
@@ -137,7 +122,6 @@ const Signup = others => {
|
|
|
137
122
|
type: "email",
|
|
138
123
|
value: form.email
|
|
139
124
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputDate, {
|
|
140
|
-
id: "signup-dateOfBirth",
|
|
141
125
|
name: "dateOfBirth",
|
|
142
126
|
error: ((_form$dateOfBirth = form.dateOfBirth) === null || _form$dateOfBirth === void 0 ? void 0 : _form$dateOfBirth.length) && !!formError.dateOfBirth,
|
|
143
127
|
hint: (_form$dateOfBirth2 = form.dateOfBirth) !== null && _form$dateOfBirth2 !== void 0 && _form$dateOfBirth2.length && (_formError$dateOfBirt = formError.dateOfBirth) !== null && _formError$dateOfBirt !== void 0 && _formError$dateOfBirt.max ? translate(_Signup.L10N.DATEOFBIRTH_ERROR) : undefined,
|
|
@@ -152,7 +136,6 @@ const Signup = others => {
|
|
|
152
136
|
type: "inputDate",
|
|
153
137
|
value: form.dateOfBirth
|
|
154
138
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputSelect, {
|
|
155
|
-
id: "signup-country",
|
|
156
139
|
name: "country",
|
|
157
140
|
label: translate(_Signup.L10N.COUNTRY_LABEL),
|
|
158
141
|
placeholder: translate(_Signup.L10N.COUNTRY_PLACEHOLDER),
|
|
@@ -162,7 +145,6 @@ const Signup = others => {
|
|
|
162
145
|
success: ((_form$country = form.country) === null || _form$country === void 0 ? void 0 : _form$country.length) && !formError.country,
|
|
163
146
|
value: form.country
|
|
164
147
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputText, {
|
|
165
|
-
id: "signup-password",
|
|
166
148
|
name: "password",
|
|
167
149
|
error: ((_form$password = form.password) === null || _form$password === void 0 ? void 0 : _form$password.length) && ((_formError$password = formError.password) === null || _formError$password === void 0 ? void 0 : _formError$password.test),
|
|
168
150
|
hint: translate(_Signup.L10N.PASSWORD_HINT),
|
|
@@ -180,7 +162,6 @@ const Signup = others => {
|
|
|
180
162
|
small: true,
|
|
181
163
|
value: form.subscribed
|
|
182
164
|
}), /*#__PURE__*/_react.default.createElement(_ui.InputOption, {
|
|
183
|
-
id: "signup-privacy",
|
|
184
165
|
name: "privacy",
|
|
185
166
|
checked: form.privacy,
|
|
186
167
|
label: translate(_Signup.L10N.PRIVACY_LABEL, {
|
|
@@ -210,9 +191,10 @@ const Signup = others => {
|
|
|
210
191
|
className: style.notification
|
|
211
192
|
}, translate(_Signup.L10N.NOTIFICATION_ERROR)), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
212
193
|
busy: busy,
|
|
194
|
+
disabled: busy || hasErrors || !form.privacy,
|
|
213
195
|
large: true,
|
|
214
196
|
wide: true,
|
|
215
|
-
|
|
197
|
+
type: "submit",
|
|
216
198
|
className: style.button
|
|
217
199
|
}, translate(_Signup.L10N.CTA))), !busy && response && /*#__PURE__*/_react.default.createElement(_ui.Notification, {
|
|
218
200
|
large: true,
|