@lideralia/alife-uikit 1.3.16 → 1.3.17
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/organisms/Cards/PayInfo.js +19 -13
- package/package.json +1 -1
|
@@ -80,7 +80,10 @@ CardPayInfo.Content = props => {
|
|
|
80
80
|
customTextColor,
|
|
81
81
|
labelTermsAndConditions,
|
|
82
82
|
handleSubmit,
|
|
83
|
-
isDeliverable
|
|
83
|
+
isDeliverable,
|
|
84
|
+
countryIso,
|
|
85
|
+
deliveryCountryIso,
|
|
86
|
+
invoiceRequested
|
|
84
87
|
} = props;
|
|
85
88
|
const [isCompletedPayment, setIsCompletedPayment] = (0, _react.useState)(false);
|
|
86
89
|
const [cardComplete, setCardComplete] = (0, _react.useState)({
|
|
@@ -90,10 +93,11 @@ CardPayInfo.Content = props => {
|
|
|
90
93
|
});
|
|
91
94
|
const stripe = (0, _reactStripeJs.useStripe)();
|
|
92
95
|
const elements = (0, _reactStripeJs.useElements)();
|
|
93
|
-
const [isNeedInvoice, setIsNeedInvoice] = (0, _react.useState)(false);
|
|
96
|
+
const [isNeedInvoice, setIsNeedInvoice] = (0, _react.useState)(invoiceRequested || false);
|
|
94
97
|
const [infoState, setInfoState] = (0, _react.useState)({
|
|
95
98
|
payment_method_id: '',
|
|
96
|
-
invoice_requested: false,
|
|
99
|
+
invoice_requested: isNeedInvoice || false,
|
|
100
|
+
invoice_with_same_delivery_address: !!(invoiceRequested && isDeliverable),
|
|
97
101
|
alias: '',
|
|
98
102
|
surname: '',
|
|
99
103
|
dni: '',
|
|
@@ -103,7 +107,7 @@ CardPayInfo.Content = props => {
|
|
|
103
107
|
cp: '',
|
|
104
108
|
province: '',
|
|
105
109
|
country: '',
|
|
106
|
-
country_iso: '',
|
|
110
|
+
country_iso: countryIso || '',
|
|
107
111
|
delivery_alias: '',
|
|
108
112
|
delivery_surname: '',
|
|
109
113
|
delivery_nif_cif: '',
|
|
@@ -113,7 +117,7 @@ CardPayInfo.Content = props => {
|
|
|
113
117
|
delivery_cp: '',
|
|
114
118
|
delivery_province: '',
|
|
115
119
|
delivery_country: '',
|
|
116
|
-
delivery_country_iso: ''
|
|
120
|
+
delivery_country_iso: deliveryCountryIso || ''
|
|
117
121
|
});
|
|
118
122
|
const [formValid, setFormValid] = (0, _react.useState)({
|
|
119
123
|
form_valid: true
|
|
@@ -123,7 +127,7 @@ CardPayInfo.Content = props => {
|
|
|
123
127
|
});
|
|
124
128
|
(0, _react.useEffect)(() => {
|
|
125
129
|
const emailRe = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
126
|
-
const deliveryValid = !isDeliverable || (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_alias) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_alias) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_nif_cif) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_nif_cif) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_email) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_email) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_address) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_address) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_location) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_location) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_cp) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_cp) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_province) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_province) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.
|
|
130
|
+
const deliveryValid = !isDeliverable || (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_alias) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_alias) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_nif_cif) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_nif_cif) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_email) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_email) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_address) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_address) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_location) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_location) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_cp) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_cp) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_province) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_province) !== '' && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_country_iso) && (infoState === null || infoState === void 0 ? void 0 : infoState.delivery_country_iso) !== '';
|
|
127
131
|
|
|
128
132
|
if (!(infoState !== null && infoState !== void 0 && infoState.invoice_requested) || infoState !== null && infoState !== void 0 && infoState.invoice_with_same_delivery_address) {
|
|
129
133
|
setFormValid({
|
|
@@ -146,7 +150,7 @@ CardPayInfo.Content = props => {
|
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
|
|
149
|
-
if (infoState !== null && infoState !== void 0 && infoState.dni && (infoState === null || infoState === void 0 ? void 0 : infoState.dni) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.dni) !== '' && infoState !== null && infoState !== void 0 && infoState.email && (infoState === null || infoState === void 0 ? void 0 : infoState.email) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.email) !== '' && infoState !== null && infoState !== void 0 && infoState.address && (infoState === null || infoState === void 0 ? void 0 : infoState.address) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.address) !== '' && infoState !== null && infoState !== void 0 && infoState.location && (infoState === null || infoState === void 0 ? void 0 : infoState.location) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.location) !== '' && infoState !== null && infoState !== void 0 && infoState.cp && (infoState === null || infoState === void 0 ? void 0 : infoState.cp) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.cp) !== '' && infoState !== null && infoState !== void 0 && infoState.province && (infoState === null || infoState === void 0 ? void 0 : infoState.province) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.province) !== '' && infoState !== null && infoState !== void 0 && infoState.
|
|
153
|
+
if (infoState !== null && infoState !== void 0 && infoState.dni && (infoState === null || infoState === void 0 ? void 0 : infoState.dni) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.dni) !== '' && infoState !== null && infoState !== void 0 && infoState.email && (infoState === null || infoState === void 0 ? void 0 : infoState.email) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.email) !== '' && infoState !== null && infoState !== void 0 && infoState.address && (infoState === null || infoState === void 0 ? void 0 : infoState.address) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.address) !== '' && infoState !== null && infoState !== void 0 && infoState.location && (infoState === null || infoState === void 0 ? void 0 : infoState.location) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.location) !== '' && infoState !== null && infoState !== void 0 && infoState.cp && (infoState === null || infoState === void 0 ? void 0 : infoState.cp) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.cp) !== '' && infoState !== null && infoState !== void 0 && infoState.province && (infoState === null || infoState === void 0 ? void 0 : infoState.province) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.province) !== '' && infoState !== null && infoState !== void 0 && infoState.country_iso && (infoState === null || infoState === void 0 ? void 0 : infoState.country_iso) !== null && (infoState === null || infoState === void 0 ? void 0 : infoState.country_iso) !== '') {
|
|
150
154
|
if (emailRe.test(infoState.email)) {
|
|
151
155
|
setFormValid({
|
|
152
156
|
form_valid: !!deliveryValid
|
|
@@ -346,7 +350,7 @@ CardPayInfo.Body = props => {
|
|
|
346
350
|
emailValid,
|
|
347
351
|
isDeliverable
|
|
348
352
|
} = props;
|
|
349
|
-
const [invoiceWithSameDeliveryAddress, setInvoiceWithSameDeliveryAddress] = (0, _react.useState)(
|
|
353
|
+
const [invoiceWithSameDeliveryAddress, setInvoiceWithSameDeliveryAddress] = (0, _react.useState)(!!isDeliverable);
|
|
350
354
|
|
|
351
355
|
const handleChangeInputs = (nameInput, value) => {
|
|
352
356
|
setInfoState(_objectSpread(_objectSpread({}, infoState), {}, {
|
|
@@ -378,7 +382,7 @@ CardPayInfo.Body = props => {
|
|
|
378
382
|
onClick: () => {
|
|
379
383
|
const enabling = !isNeedInvoice;
|
|
380
384
|
setIsNeedInvoice(enabling);
|
|
381
|
-
setInvoiceWithSameDeliveryAddress(
|
|
385
|
+
setInvoiceWithSameDeliveryAddress(!!isDeliverable);
|
|
382
386
|
setInfoState(_objectSpread(_objectSpread({}, infoState), {}, {
|
|
383
387
|
invoice_requested: enabling,
|
|
384
388
|
invoice_with_same_delivery_address: !!(enabling && isDeliverable),
|
|
@@ -513,13 +517,15 @@ CardPayInfo.Body = props => {
|
|
|
513
517
|
country_iso: content.value
|
|
514
518
|
})),
|
|
515
519
|
sizeInput: "big",
|
|
516
|
-
defaultValue: infoState.
|
|
520
|
+
defaultValue: (optionsCountry === null || optionsCountry === void 0 ? void 0 : optionsCountry.find(o => o.value === infoState.country_iso)) || null,
|
|
517
521
|
options: optionsCountry,
|
|
518
522
|
menuPlacement: "top"
|
|
519
523
|
})))))));
|
|
520
524
|
};
|
|
521
525
|
|
|
522
526
|
CardPayInfo.Delivery = props => {
|
|
527
|
+
var _ref2;
|
|
528
|
+
|
|
523
529
|
const {
|
|
524
530
|
isDeliverable,
|
|
525
531
|
labelDelivery,
|
|
@@ -650,13 +656,13 @@ CardPayInfo.Delivery = props => {
|
|
|
650
656
|
delivery_country_iso: content.value
|
|
651
657
|
})),
|
|
652
658
|
sizeInput: "big",
|
|
653
|
-
defaultValue: infoState.
|
|
659
|
+
defaultValue: ((_ref2 = optionsDeliveryCountry || optionsCountry) === null || _ref2 === void 0 ? void 0 : _ref2.find(o => o.value === infoState.delivery_country_iso)) || null,
|
|
654
660
|
options: optionsDeliveryCountry || optionsCountry,
|
|
655
661
|
menuPlacement: "top"
|
|
656
662
|
}))));
|
|
657
663
|
};
|
|
658
664
|
|
|
659
|
-
CardPayInfo.Footer =
|
|
665
|
+
CardPayInfo.Footer = _ref3 => {
|
|
660
666
|
let {
|
|
661
667
|
labelButton,
|
|
662
668
|
buttonDisabled,
|
|
@@ -667,7 +673,7 @@ CardPayInfo.Footer = _ref2 => {
|
|
|
667
673
|
customTextColor,
|
|
668
674
|
labelTermsAndConditions,
|
|
669
675
|
isCompletedPayment
|
|
670
|
-
} =
|
|
676
|
+
} = _ref3;
|
|
671
677
|
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_Layout.Box, {
|
|
672
678
|
padding: 3,
|
|
673
679
|
borderTopColor: "black12",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lideralia/alife-uikit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17",
|
|
4
4
|
"description": "Librería y documentación de componentes, basada en el Design System de Alife.",
|
|
5
5
|
"homepage": "https://github.com/lideralia/alife-frontend-components#readme",
|
|
6
6
|
"bugs": {
|