ordering-ui-external 11.0.11 → 12.0.1
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/_bundles/{0.ordering-ui.f6ab4fd53f85792a6e5f.js → 0.ordering-ui.fe5a82ad23cc1b2ed119.js} +1 -1
- package/_bundles/{7.ordering-ui.f6ab4fd53f85792a6e5f.js → 7.ordering-ui.fe5a82ad23cc1b2ed119.js} +1 -1
- package/_bundles/{ordering-ui.f6ab4fd53f85792a6e5f.js → ordering-ui.fe5a82ad23cc1b2ed119.js} +2 -2
- package/_modules/themes/callcenterOriginal/src/components/Orders/OrdersTable/styles.js +1 -1
- package/_modules/themes/five/src/components/BusinessController/styles.js +2 -2
- package/_modules/themes/five/src/components/Cart/index.js +7 -7
- package/_modules/themes/five/src/components/Checkout/index.js +108 -87
- package/_modules/themes/five/src/components/MultiCheckout/index.js +65 -20
- package/_modules/themes/five/src/components/ProductOptionSubOption/index.js +2 -2
- package/_modules/themes/five/src/components/UserDetails/index.js +2 -2
- package/_modules/themes/five/src/components/UserFormDetails/index.js +59 -49
- package/_modules/utils/index.js +4 -3
- package/package.json +2 -2
- package/src/themes/callcenterOriginal/src/components/Orders/OrdersTable/styles.js +1 -1
- package/src/themes/five/src/components/BusinessController/styles.js +4 -4
- package/src/themes/five/src/components/Cart/index.js +6 -6
- package/src/themes/five/src/components/Checkout/index.js +75 -66
- package/src/themes/five/src/components/MultiCheckout/index.js +53 -21
- package/src/themes/five/src/components/ProductOptionSubOption/index.js +2 -2
- package/src/themes/five/src/components/UserDetails/index.js +2 -2
- package/src/themes/five/src/components/UserFormDetails/index.js +75 -66
- package/src/utils/index.js +3 -3
- /package/_bundles/{1.ordering-ui.f6ab4fd53f85792a6e5f.js → 1.ordering-ui.fe5a82ad23cc1b2ed119.js} +0 -0
- /package/_bundles/{2.ordering-ui.f6ab4fd53f85792a6e5f.js → 2.ordering-ui.fe5a82ad23cc1b2ed119.js} +0 -0
- /package/_bundles/{4.ordering-ui.f6ab4fd53f85792a6e5f.js → 4.ordering-ui.fe5a82ad23cc1b2ed119.js} +0 -0
- /package/_bundles/{5.ordering-ui.f6ab4fd53f85792a6e5f.js → 5.ordering-ui.fe5a82ad23cc1b2ed119.js} +0 -0
- /package/_bundles/{6.ordering-ui.f6ab4fd53f85792a6e5f.js → 6.ordering-ui.fe5a82ad23cc1b2ed119.js} +0 -0
- /package/_bundles/{7.ordering-ui.f6ab4fd53f85792a6e5f.js.LICENSE.txt → 7.ordering-ui.fe5a82ad23cc1b2ed119.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-ui.f6ab4fd53f85792a6e5f.js → 8.ordering-ui.fe5a82ad23cc1b2ed119.js} +0 -0
- /package/_bundles/{9.ordering-ui.f6ab4fd53f85792a6e5f.js → 9.ordering-ui.fe5a82ad23cc1b2ed119.js} +0 -0
- /package/_bundles/{ordering-ui.f6ab4fd53f85792a6e5f.js.LICENSE.txt → ordering-ui.fe5a82ad23cc1b2ed119.js.LICENSE.txt} +0 -0
|
@@ -45,7 +45,7 @@ var mapConfigs = {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
48
|
-
var _Object$values, _cartGroup$result, _paymethodSelected$pa, _cardList$cards, _configs$checkout_mul, _configs$driver_tip_o, _configs$driver_tip_o2, _configs$driver_tip_o3, _configs$multi_busine, _configs$driver_tip_o4, _configs$driver_tip_o5, _cartGroup$result2, _loyaltyPlansState$re, _creditPointPlan$busi, _creditPointPlan$busi2, _loyaltyPlansState$re2, _creditPointGeneralPl, _creditPointGeneralPl2, _configs$cash_wallet, _configs$wallet_enabl, _configs$wallet_cash_, _configs$wallet_credi, _configs$google_maps_, _customerState$user, _cartGroup$result3, _cartGroup$result4, _validationFields$
|
|
48
|
+
var _Object$values, _cartGroup$result, _paymethodSelected$pa, _cardList$cards, _configs$checkout_mul, _configs$driver_tip_o, _configs$driver_tip_o2, _configs$driver_tip_o3, _configs$multi_busine, _configs$driver_tip_o4, _configs$driver_tip_o5, _cartGroup$result2, _loyaltyPlansState$re, _creditPointPlan$busi, _creditPointPlan$busi2, _loyaltyPlansState$re2, _creditPointGeneralPl, _creditPointGeneralPl2, _configs$cash_wallet, _configs$wallet_enabl, _configs$wallet_cash_, _configs$wallet_credi, _theme, _theme$split, _orderState$options6, _configs$google_maps_, _customerState$user, _cartGroup$result3, _cartGroup$result4, _validationFields$fie, _configs$multi_busine2, _validationFields$fie2, _configs$driver_tip_t, _configs$driver_tip_u, _configs$driver_tip_t2, _openCarts$, _configs$multi_busine6, _configs$multi_busine7, _customerState$user2;
|
|
49
49
|
var placing = props.placing,
|
|
50
50
|
isCustomerMode = props.isCustomerMode,
|
|
51
51
|
openCarts = props.openCarts,
|
|
@@ -60,7 +60,8 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
60
60
|
cartUuid = props.cartUuid,
|
|
61
61
|
totalCartsFee = props.totalCartsFee,
|
|
62
62
|
walletState = props.walletState,
|
|
63
|
-
handleSearchRedirect = props.handleSearchRedirect
|
|
63
|
+
handleSearchRedirect = props.handleSearchRedirect,
|
|
64
|
+
checkoutFieldsState = props.checkoutFieldsState;
|
|
64
65
|
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
65
66
|
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
66
67
|
t = _useLanguage2[1];
|
|
@@ -78,7 +79,9 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
78
79
|
validationFields = _useValidationFields2[0];
|
|
79
80
|
var _useSession = (0, _orderingComponentsExternal.useSession)(),
|
|
80
81
|
_useSession2 = _slicedToArray(_useSession, 2),
|
|
81
|
-
|
|
82
|
+
_useSession2$ = _useSession2[0],
|
|
83
|
+
user = _useSession2$.user,
|
|
84
|
+
userLoading = _useSession2$.loading,
|
|
82
85
|
login = _useSession2[1].login;
|
|
83
86
|
var _useOrder = (0, _orderingComponentsExternal.useOrder)(),
|
|
84
87
|
_useOrder2 = _slicedToArray(_useOrder, 1),
|
|
@@ -139,6 +142,7 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
139
142
|
return (cart === null || cart === void 0 ? void 0 : cart.products) && (cart === null || cart === void 0 || (_cart$products = cart.products) === null || _cart$products === void 0 ? void 0 : _cart$products.length) && (cart === null || cart === void 0 ? void 0 : cart.status) !== 2 && (cart === null || cart === void 0 ? void 0 : cart.valid_schedule) && (cart === null || cart === void 0 ? void 0 : cart.valid_products) && (cart === null || cart === void 0 ? void 0 : cart.valid_address) && (cart === null || cart === void 0 ? void 0 : cart.valid_maximum) && (cart === null || cart === void 0 ? void 0 : cart.valid_minimum) && (cart === null || cart === void 0 ? void 0 : cart.wallets);
|
|
140
143
|
})) || null || [];
|
|
141
144
|
var isDisablePlaceOrderButton = (cartGroup === null || cartGroup === void 0 ? void 0 : cartGroup.loading) || !(paymethodSelected !== null && paymethodSelected !== void 0 && paymethodSelected.paymethod_id || paymethodSelected !== null && paymethodSelected !== void 0 && paymethodSelected.wallet_id) && (cartGroup === null || cartGroup === void 0 || (_cartGroup$result = cartGroup.result) === null || _cartGroup$result === void 0 ? void 0 : _cartGroup$result.balance) > 0 || (paymethodSelected === null || paymethodSelected === void 0 || (_paymethodSelected$pa = paymethodSelected.paymethod) === null || _paymethodSelected$pa === void 0 ? void 0 : _paymethodSelected$pa.gateway) === 'stripe' && !(paymethodSelected !== null && paymethodSelected !== void 0 && paymethodSelected.paymethod_data) || (paymethodSelected === null || paymethodSelected === void 0 ? void 0 : paymethodSelected.gateway) === 'stripe' && (cardList === null || cardList === void 0 || (_cardList$cards = cardList.cards) === null || _cardList$cards === void 0 ? void 0 : _cardList$cards.length) === 0 || walletCarts.length > 0;
|
|
145
|
+
var notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments'];
|
|
142
146
|
var isMultiDriverTips = (configs === null || configs === void 0 || (_configs$checkout_mul = configs.checkout_multi_business_enabled) === null || _configs$checkout_mul === void 0 ? void 0 : _configs$checkout_mul.value) === '1';
|
|
143
147
|
var driverTipsOptions = typeof (configs === null || configs === void 0 || (_configs$driver_tip_o = configs.driver_tip_options) === null || _configs$driver_tip_o === void 0 ? void 0 : _configs$driver_tip_o.value) === 'string' ? JSON.parse(configs === null || configs === void 0 || (_configs$driver_tip_o2 = configs.driver_tip_options) === null || _configs$driver_tip_o2 === void 0 ? void 0 : _configs$driver_tip_o2.value) || [] : (configs === null || configs === void 0 || (_configs$driver_tip_o3 = configs.driver_tip_options) === null || _configs$driver_tip_o3 === void 0 ? void 0 : _configs$driver_tip_o3.value) || [];
|
|
144
148
|
var totalFeeEnabled = (configs === null || configs === void 0 || (_configs$multi_busine = configs.multi_business_checkout_show_combined_delivery_fee) === null || _configs$multi_busine === void 0 ? void 0 : _configs$multi_busine.value) === '1' ? JSON.parse(configs === null || configs === void 0 || (_configs$driver_tip_o4 = configs.driver_tip_options) === null || _configs$driver_tip_o4 === void 0 ? void 0 : _configs$driver_tip_o4.value) || [] : (configs === null || configs === void 0 || (_configs$driver_tip_o5 = configs.driver_tip_options) === null || _configs$driver_tip_o5 === void 0 ? void 0 : _configs$driver_tip_o5.value) || [];
|
|
@@ -166,6 +170,15 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
166
170
|
return b.accumulates;
|
|
167
171
|
})) !== null && _creditPointGeneralPl !== void 0 ? _creditPointGeneralPl : [];
|
|
168
172
|
var isWalletEnabled = (configs === null || configs === void 0 || (_configs$cash_wallet = configs.cash_wallet) === null || _configs$cash_wallet === void 0 ? void 0 : _configs$cash_wallet.value) && (configs === null || configs === void 0 || (_configs$wallet_enabl = configs.wallet_enabled) === null || _configs$wallet_enabl === void 0 ? void 0 : _configs$wallet_enabl.value) === '1' && ((configs === null || configs === void 0 || (_configs$wallet_cash_ = configs.wallet_cash_enabled) === null || _configs$wallet_cash_ === void 0 ? void 0 : _configs$wallet_cash_.value) === '1' || (configs === null || configs === void 0 || (_configs$wallet_credi = configs.wallet_credit_point_enabled) === null || _configs$wallet_credi === void 0 ? void 0 : _configs$wallet_credi.value) === '1');
|
|
173
|
+
var checkoutFields = (0, _react.useMemo)(function () {
|
|
174
|
+
var _checkoutFieldsState$;
|
|
175
|
+
return checkoutFieldsState === null || checkoutFieldsState === void 0 || (_checkoutFieldsState$ = checkoutFieldsState.fields) === null || _checkoutFieldsState$ === void 0 ? void 0 : _checkoutFieldsState$.filter(function (field) {
|
|
176
|
+
var _orderState$options;
|
|
177
|
+
return field.order_type_id === (orderState === null || orderState === void 0 || (_orderState$options = orderState.options) === null || _orderState$options === void 0 ? void 0 : _orderState$options.type);
|
|
178
|
+
});
|
|
179
|
+
}, [checkoutFieldsState, orderState === null || orderState === void 0 ? void 0 : orderState.options]);
|
|
180
|
+
var hexTest = /[0-9A-Fa-f]{6}/g;
|
|
181
|
+
var primaryColor = (_theme = theme) === null || _theme === void 0 || (_theme = _theme.colors) === null || _theme === void 0 || (_theme = _theme.primary) === null || _theme === void 0 || (_theme$split = _theme.split) === null || _theme$split === void 0 || (_theme$split = _theme$split.call(_theme, '#')) === null || _theme$split === void 0 ? void 0 : _theme$split[1];
|
|
169
182
|
var accumulationRateBusiness = function accumulationRateBusiness(businessId) {
|
|
170
183
|
var _loyalBusinessAvailab, _loyalBusinessAvailab2, _creditPointGeneralPl3;
|
|
171
184
|
var value = (_loyalBusinessAvailab = loyalBusinessAvailable === null || loyalBusinessAvailable === void 0 || (_loyalBusinessAvailab2 = loyalBusinessAvailable.find(function (loyal) {
|
|
@@ -199,7 +212,7 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
199
212
|
}));
|
|
200
213
|
return;
|
|
201
214
|
}
|
|
202
|
-
if (!userErrors.length &&
|
|
215
|
+
if (!userErrors.length && !(requiredFields !== null && requiredFields !== void 0 && requiredFields.length)) {
|
|
203
216
|
handleGroupPlaceOrder && handleGroupPlaceOrder();
|
|
204
217
|
return;
|
|
205
218
|
}
|
|
@@ -226,28 +239,54 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
226
239
|
});
|
|
227
240
|
setIsUserDetailsEdit(false);
|
|
228
241
|
};
|
|
242
|
+
var checkGuestValidationFields = function checkGuestValidationFields() {
|
|
243
|
+
var _checkoutFieldsState$2, _configs$verification;
|
|
244
|
+
var userSelected = isCustomerMode ? customerState.user : user;
|
|
245
|
+
var _requiredFields = checkoutFieldsState === null || checkoutFieldsState === void 0 ? void 0 : checkoutFieldsState.fields.filter(function (field) {
|
|
246
|
+
var _orderState$options2, _field$validation_fie, _field$validation_fie2;
|
|
247
|
+
return (field === null || field === void 0 ? void 0 : field.order_type_id) === (orderState === null || orderState === void 0 || (_orderState$options2 = orderState.options) === null || _orderState$options2 === void 0 ? void 0 : _orderState$options2.type) && (field === null || field === void 0 ? void 0 : field.enabled) && (field === null || field === void 0 ? void 0 : field.required_with_guest) && !notFields.includes(field === null || field === void 0 || (_field$validation_fie = field.validation_field) === null || _field$validation_fie === void 0 ? void 0 : _field$validation_fie.code) && userSelected && !userSelected[field === null || field === void 0 || (_field$validation_fie2 = field.validation_field) === null || _field$validation_fie2 === void 0 ? void 0 : _field$validation_fie2.code];
|
|
248
|
+
});
|
|
249
|
+
var requiredFieldsCode = _requiredFields.map(function (item) {
|
|
250
|
+
var _item$validation_fiel;
|
|
251
|
+
return item === null || item === void 0 || (_item$validation_fiel = item.validation_field) === null || _item$validation_fiel === void 0 ? void 0 : _item$validation_fiel.code;
|
|
252
|
+
});
|
|
253
|
+
var guestCheckoutCellPhone = checkoutFieldsState === null || checkoutFieldsState === void 0 || (_checkoutFieldsState$2 = checkoutFieldsState.fields) === null || _checkoutFieldsState$2 === void 0 ? void 0 : _checkoutFieldsState$2.find(function (field) {
|
|
254
|
+
var _orderState$options3, _field$validation_fie3;
|
|
255
|
+
return field.order_type_id === (orderState === null || orderState === void 0 || (_orderState$options3 = orderState.options) === null || _orderState$options3 === void 0 ? void 0 : _orderState$options3.type) && (field === null || field === void 0 || (_field$validation_fie3 = field.validation_field) === null || _field$validation_fie3 === void 0 ? void 0 : _field$validation_fie3.code) === 'mobile_phone';
|
|
256
|
+
});
|
|
257
|
+
if (userSelected && !(userSelected !== null && userSelected !== void 0 && userSelected.cellphone) && (guestCheckoutCellPhone !== null && guestCheckoutCellPhone !== void 0 && guestCheckoutCellPhone.enabled && guestCheckoutCellPhone !== null && guestCheckoutCellPhone !== void 0 && guestCheckoutCellPhone.required_with_guest || (configs === null || configs === void 0 || (_configs$verification = configs.verification_phone_required) === null || _configs$verification === void 0 ? void 0 : _configs$verification.value) === '1')) {
|
|
258
|
+
requiredFieldsCode.push('cellphone');
|
|
259
|
+
}
|
|
260
|
+
setRequiredFields(requiredFieldsCode);
|
|
261
|
+
};
|
|
229
262
|
var checkValidationFields = function checkValidationFields() {
|
|
230
|
-
var
|
|
263
|
+
var _Object$values2, _configs$verification2;
|
|
231
264
|
setUserErrors([]);
|
|
232
265
|
var errors = [];
|
|
233
|
-
var notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes'];
|
|
234
266
|
var userSelected = isCustomerMode ? customerState.user : user;
|
|
235
267
|
var _requiredFields = [];
|
|
236
|
-
Object.values(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
268
|
+
Object.values(checkoutFieldsState === null || checkoutFieldsState === void 0 ? void 0 : checkoutFieldsState.fields).map(function (field) {
|
|
269
|
+
var _orderState$options4, _field$validation_fie4;
|
|
270
|
+
if (((_orderState$options4 = orderState.options) === null || _orderState$options4 === void 0 ? void 0 : _orderState$options4.type) === (field === null || field === void 0 ? void 0 : field.order_type_id) && field !== null && field !== void 0 && field.enabled && field !== null && field !== void 0 && field.required && !notFields.includes(field === null || field === void 0 || (_field$validation_fie4 = field.validation_field) === null || _field$validation_fie4 === void 0 ? void 0 : _field$validation_fie4.code)) {
|
|
271
|
+
var _field$validation_fie5;
|
|
272
|
+
if (userSelected && !userSelected[field === null || field === void 0 || (_field$validation_fie5 = field.validation_field) === null || _field$validation_fie5 === void 0 ? void 0 : _field$validation_fie5.code]) {
|
|
273
|
+
var _field$validation_fie6;
|
|
274
|
+
_requiredFields.push(field === null || field === void 0 || (_field$validation_fie6 = field.validation_field) === null || _field$validation_fie6 === void 0 ? void 0 : _field$validation_fie6.code);
|
|
240
275
|
}
|
|
241
276
|
}
|
|
242
277
|
});
|
|
243
|
-
|
|
278
|
+
var mobilePhoneField = (_Object$values2 = Object.values(checkoutFieldsState === null || checkoutFieldsState === void 0 ? void 0 : checkoutFieldsState.fields)) === null || _Object$values2 === void 0 ? void 0 : _Object$values2.find(function (field) {
|
|
279
|
+
var _orderState$options5, _field$validation_fie7;
|
|
280
|
+
return (field === null || field === void 0 ? void 0 : field.order_type_id) === (orderState === null || orderState === void 0 || (_orderState$options5 = orderState.options) === null || _orderState$options5 === void 0 ? void 0 : _orderState$options5.type) && (field === null || field === void 0 || (_field$validation_fie7 = field.validation_field) === null || _field$validation_fie7 === void 0 ? void 0 : _field$validation_fie7.code) === 'mobile_phone';
|
|
281
|
+
});
|
|
282
|
+
if (userSelected && !(userSelected !== null && userSelected !== void 0 && userSelected.cellphone) && (mobilePhoneField !== null && mobilePhoneField !== void 0 && mobilePhoneField.enabled && mobilePhoneField !== null && mobilePhoneField !== void 0 && mobilePhoneField.required || (configs === null || configs === void 0 || (_configs$verification2 = configs.verification_phone_required) === null || _configs$verification2 === void 0 ? void 0 : _configs$verification2.value) === '1')) {
|
|
244
283
|
_requiredFields.push('cellphone');
|
|
245
284
|
}
|
|
246
285
|
setRequiredFields(_requiredFields);
|
|
247
286
|
if (userSelected && userSelected !== null && userSelected !== void 0 && userSelected.cellphone) {
|
|
248
287
|
if (userSelected !== null && userSelected !== void 0 && userSelected.country_phone_code) {
|
|
249
288
|
var phone = null;
|
|
250
|
-
phone = "+".concat(userSelected === null || userSelected === void 0 ? void 0 : userSelected.country_phone_code).concat(userSelected === null || userSelected === void 0 ? void 0 : userSelected.cellphone);
|
|
289
|
+
phone = "+".concat(userSelected === null || userSelected === void 0 ? void 0 : userSelected.country_phone_code).concat(userSelected === null || userSelected === void 0 ? void 0 : userSelected.cellphone.replace("+".concat(userSelected === null || userSelected === void 0 ? void 0 : userSelected.country_phone_code), ''));
|
|
251
290
|
var phoneNumber = (0, _libphonenumberJs.default)(phone);
|
|
252
291
|
if (!(phoneNumber !== null && phoneNumber !== void 0 && phoneNumber.isValid())) {
|
|
253
292
|
errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_INVALID', 'The field Phone number is invalid.'));
|
|
@@ -276,11 +315,13 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
276
315
|
}));
|
|
277
316
|
};
|
|
278
317
|
(0, _react.useEffect)(function () {
|
|
279
|
-
|
|
280
|
-
if (
|
|
318
|
+
if (checkoutFieldsState !== null && checkoutFieldsState !== void 0 && checkoutFieldsState.loading || customerState.loading || userLoading) return;
|
|
319
|
+
if (user !== null && user !== void 0 && user.guest_id) {
|
|
320
|
+
checkGuestValidationFields();
|
|
321
|
+
} else {
|
|
281
322
|
checkValidationFields();
|
|
282
323
|
}
|
|
283
|
-
}, [
|
|
324
|
+
}, [checkoutFieldsState, user, customerState, orderState === null || orderState === void 0 || (_orderState$options6 = orderState.options) === null || _orderState$options6 === void 0 ? void 0 : _orderState$options6.type]);
|
|
284
325
|
(0, _react.useEffect)(function () {
|
|
285
326
|
if (openCarts.length || cartGroup.loading) {
|
|
286
327
|
if (openCarts.length === 1) {
|
|
@@ -353,14 +394,16 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
353
394
|
}
|
|
354
395
|
}, t('CONTINUE_AS_GUEST', 'Continue as guest'))) : /*#__PURE__*/_react.default.createElement(_UserDetails.UserDetails, {
|
|
355
396
|
isUserDetailsEdit: isUserDetailsEdit,
|
|
356
|
-
useValidationFields: true,
|
|
357
397
|
useDefualtSessionManager: true,
|
|
358
398
|
useSessionUser: !isCustomerMode,
|
|
359
399
|
isCustomerMode: isCustomerMode,
|
|
360
400
|
userData: isCustomerMode && customerState.user,
|
|
361
401
|
userId: isCustomerMode && (customerState === null || customerState === void 0 || (_customerState$user = customerState.user) === null || _customerState$user === void 0 ? void 0 : _customerState$user.id),
|
|
362
402
|
isCheckout: true,
|
|
363
|
-
isSuccess: isSuccess
|
|
403
|
+
isSuccess: isSuccess,
|
|
404
|
+
isOrderTypeValidationField: true,
|
|
405
|
+
requiredFields: requiredFields,
|
|
406
|
+
checkoutFields: checkoutFields
|
|
364
407
|
}))), /*#__PURE__*/_react.default.createElement(_styles.PaymentMethodContainer, null, /*#__PURE__*/_react.default.createElement("h1", null, t('PAYMENT_METHODS', 'Payment Methods')), /*#__PURE__*/_react.default.createElement(_MultiCartsPaymethodsAndWallets.MultiCartsPaymethodsAndWallets, {
|
|
365
408
|
userId: props.userId,
|
|
366
409
|
openCarts: openCarts,
|
|
@@ -375,7 +418,7 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
375
418
|
cartGroup: cartGroup,
|
|
376
419
|
setCardList: setCardList,
|
|
377
420
|
handlePlaceOrder: handlePlaceOrder
|
|
378
|
-
})), (validationFields === null || validationFields === void 0 || (_validationFields$
|
|
421
|
+
})), (validationFields === null || validationFields === void 0 || (_validationFields$fie = validationFields.fields) === null || _validationFields$fie === void 0 || (_validationFields$fie = _validationFields$fie.checkout) === null || _validationFields$fie === void 0 || (_validationFields$fie = _validationFields$fie.coupon) === null || _validationFields$fie === void 0 ? void 0 : _validationFields$fie.enabled) && openCarts.every(function (cart) {
|
|
379
422
|
return cart.business_id && cart.status !== 2;
|
|
380
423
|
}) && (configs === null || configs === void 0 || (_configs$multi_busine2 = configs.multi_business_checkout_coupon_input_style) === null || _configs$multi_busine2 === void 0 ? void 0 : _configs$multi_busine2.value) === 'group' && /*#__PURE__*/_react.default.createElement(_styles.DriverTipContainer, null, /*#__PURE__*/_react.default.createElement("h1", null, t('DISCOUNT_COUPON', 'Discount coupon')), /*#__PURE__*/_react.default.createElement(_styles.CouponContainer, null, /*#__PURE__*/_react.default.createElement(_CouponControl.CouponControl, {
|
|
381
424
|
carts: openCarts,
|
|
@@ -385,7 +428,7 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
385
428
|
price: openCarts.reduce(function (total, cart) {
|
|
386
429
|
return total + cart.total;
|
|
387
430
|
}, 0)
|
|
388
|
-
}))), isMultiDriverTips && (orderState === null || orderState === void 0 ? void 0 : orderState.options.type) === 1 && (validationFields === null || validationFields === void 0 || (_validationFields$
|
|
431
|
+
}))), isMultiDriverTips && (orderState === null || orderState === void 0 ? void 0 : orderState.options.type) === 1 && (validationFields === null || validationFields === void 0 || (_validationFields$fie2 = validationFields.fields) === null || _validationFields$fie2 === void 0 || (_validationFields$fie2 = _validationFields$fie2.checkout) === null || _validationFields$fie2 === void 0 || (_validationFields$fie2 = _validationFields$fie2.driver_tip) === null || _validationFields$fie2 === void 0 ? void 0 : _validationFields$fie2.enabled) && openCarts.every(function (cart) {
|
|
389
432
|
return cart.business_id && cart.status !== 2;
|
|
390
433
|
}) && driverTipsOptions.length > 0 && /*#__PURE__*/_react.default.createElement(_styles.DriverTipContainer, null, /*#__PURE__*/_react.default.createElement("h1", null, t('DRIVER_TIPS', 'Driver Tips')), /*#__PURE__*/_react.default.createElement("p", null, t('100%_OF_THE_TIP_YOUR_DRIVER', '100% of the tip goes to your driver')), /*#__PURE__*/_react.default.createElement(_DriverTips.DriverTips, {
|
|
391
434
|
isMulti: true,
|
|
@@ -447,13 +490,15 @@ var MultiCheckoutUI = function MultiCheckoutUI(props) {
|
|
|
447
490
|
}
|
|
448
491
|
}, /*#__PURE__*/_react.default.createElement(_UserDetails.UserDetails, {
|
|
449
492
|
isUserDetailsEdit: isUserDetailsEdit,
|
|
450
|
-
useValidationFields: true,
|
|
451
493
|
useDefualtSessionManager: true,
|
|
452
494
|
useSessionUser: !isCustomerMode,
|
|
453
495
|
isCustomerMode: isCustomerMode,
|
|
454
496
|
userData: isCustomerMode && customerState.user,
|
|
455
497
|
userId: isCustomerMode && (customerState === null || customerState === void 0 || (_customerState$user2 = customerState.user) === null || _customerState$user2 === void 0 ? void 0 : _customerState$user2.id),
|
|
456
498
|
requiredFields: requiredFields,
|
|
499
|
+
isOrderTypeValidationField: true,
|
|
500
|
+
checkoutFields: checkoutFields,
|
|
501
|
+
isCheckoutPlace: true,
|
|
457
502
|
setIsSuccess: setIsSuccess,
|
|
458
503
|
isCheckout: true,
|
|
459
504
|
isEdit: true,
|
|
@@ -115,7 +115,7 @@ var ProductOptionSubOptionUI = /*#__PURE__*/_react.default.memo(function (props)
|
|
|
115
115
|
disabled: true
|
|
116
116
|
})), suboption.image && suboption.image !== '-' && /*#__PURE__*/_react.default.createElement(_styles.SubOptionThumbnail, {
|
|
117
117
|
src: suboption.image
|
|
118
|
-
}), /*#__PURE__*/_react.default.createElement(_styles.Text, null, /*#__PURE__*/_react.default.createElement("div", null, suboption === null || suboption === void 0 ? void 0 : suboption.name))), /*#__PURE__*/_react.default.createElement(_styles.RightOptionContainer, null, /*#__PURE__*/_react.default.createElement(_styles.QuantityControl, null, (option === null || option === void 0 ? void 0 : option.allow_suboption_quantity) && (state === null || state === void 0 ? void 0 : state.selected) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_BsDashCircle.default, {
|
|
118
|
+
}), /*#__PURE__*/_react.default.createElement(_styles.Text, null, /*#__PURE__*/_react.default.createElement("div", null, suboption === null || suboption === void 0 ? void 0 : suboption.name))), /*#__PURE__*/_react.default.createElement(_styles.RightOptionContainer, null, /*#__PURE__*/_react.default.createElement(_styles.QuantityControl, null, !((option === null || option === void 0 ? void 0 : option.max) === 1 && (option === null || option === void 0 ? void 0 : option.min) === 1) && (option === null || option === void 0 ? void 0 : option.allow_suboption_quantity) && (state === null || state === void 0 ? void 0 : state.selected) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_BsDashCircle.default, {
|
|
119
119
|
disabled: state.quantity === 0 || isSoldOut,
|
|
120
120
|
onClick: handleDecrement
|
|
121
121
|
}), state.quantity, /*#__PURE__*/_react.default.createElement(_BsPlusCircle.default, {
|
|
@@ -129,7 +129,7 @@ var ProductOptionSubOptionUI = /*#__PURE__*/_react.default.memo(function (props)
|
|
|
129
129
|
return handlePosition(e, 'left');
|
|
130
130
|
}
|
|
131
131
|
}), /*#__PURE__*/_react.default.createElement(_BsCircleFill.default, {
|
|
132
|
-
className: [(pizzaState === null || pizzaState === void 0 || (_pizzaState3 = pizzaState["option:".concat(option === null || option === void 0 ? void 0 : option.id)]) === null || _pizzaState3 === void 0 ? void 0 : _pizzaState3.value) === (option === null || option === void 0 ? void 0 : option.max) ? 'disabled' : '', state.selected && state.position === 'whole' ? 'selected' : null].filter(function (classname) {
|
|
132
|
+
className: [(pizzaState === null || pizzaState === void 0 || (_pizzaState3 = pizzaState["option:".concat(option === null || option === void 0 ? void 0 : option.id)]) === null || _pizzaState3 === void 0 ? void 0 : _pizzaState3.value) === (option === null || option === void 0 ? void 0 : option.max) && !((option === null || option === void 0 ? void 0 : option.max) === 1 && (option === null || option === void 0 ? void 0 : option.min) === 1) ? 'disabled' : '', state.selected && state.position === 'whole' ? 'selected' : null].filter(function (classname) {
|
|
133
133
|
return classname;
|
|
134
134
|
}).join(' '),
|
|
135
135
|
onClick: function onClick(e) {
|
|
@@ -165,11 +165,11 @@ var UserDetailsUI = function UserDetailsUI(props) {
|
|
|
165
165
|
height: 25
|
|
166
166
|
})), !(validationFields.loading || formState.loading || userState.loading) && /*#__PURE__*/_react.default.createElement(_styles.Container, null, isModal && /*#__PURE__*/_react.default.createElement(_styles.TitleContainer, {
|
|
167
167
|
isAddressFormOpen: isAddressFormOpen && !isEdit
|
|
168
|
-
}, !
|
|
168
|
+
}, !isCheckoutPlace && /*#__PURE__*/_react.default.createElement(_styles.ModalIcon, null, /*#__PURE__*/_react.default.createElement(_MdClose.default, {
|
|
169
169
|
onClick: function onClick() {
|
|
170
170
|
return onClose();
|
|
171
171
|
}
|
|
172
|
-
})), /*#__PURE__*/_react.default.createElement("h1", null, t('CUSTOMER_DETAILS', 'Customer Details'))), !
|
|
172
|
+
})), /*#__PURE__*/_react.default.createElement("h1", null, t('CUSTOMER_DETAILS', 'Customer Details'))), !isCheckoutPlace && /*#__PURE__*/_react.default.createElement(_styles.Header, {
|
|
173
173
|
className: "user-form"
|
|
174
174
|
}, !isModal && /*#__PURE__*/_react.default.createElement("h1", null, t('CUSTOMER_DETAILS', 'Customer Details')), cartStatus !== 2 && (!isEdit ? /*#__PURE__*/_react.default.createElement("span", {
|
|
175
175
|
onClick: function onClick() {
|
|
@@ -43,7 +43,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
43
43
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
44
44
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
45
45
|
var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(props) {
|
|
46
|
-
var _formState$result, _formState$result2, _formState$changes$se, _formState$changes, _user$settings, _formState$result3, _formState$result4, _formState$changes$se2, _formState$changes2, _user$settings2, _formState$result5, _formState$result6, _formState$changes$se3, _formState$changes3, _user$settings3, _theme$profile, _theme$profile2, _theme$profile3, _theme$profile4, _theme$profile5, _validationFields$fie, _validationFields$fie2, _validationFields$fie3, _validationFields$fie4, _configs$verification3, _props$beforeElements, _props$beforeComponen, _props$beforeMidEleme, _props$beforeMidCompo, _validationFields$
|
|
46
|
+
var _formState$result, _formState$result2, _formState$changes$se, _formState$changes, _user$settings, _formState$result3, _formState$result4, _formState$changes$se2, _formState$changes2, _user$settings2, _formState$result5, _formState$result6, _formState$changes$se3, _formState$changes3, _user$settings3, _theme$profile, _theme$profile2, _theme$profile3, _theme$profile4, _theme$profile5, _checkoutFields$find, _validationFields$fie, _validationFields$fie2, _checkoutFields$find2, _validationFields$fie3, _validationFields$fie4, _configs$verification3, _props$beforeElements, _props$beforeComponen, _props$beforeMidEleme, _props$beforeMidCompo, _validationFields$fie9, _requiredFields$inclu6, _requiredFields$inclu7, _props$afterMidElemen, _props$afterMidCompon, _props$afterComponent, _props$afterElements;
|
|
47
47
|
var isEdit = props.isEdit,
|
|
48
48
|
formState = props.formState,
|
|
49
49
|
onCancel = props.onCancel,
|
|
@@ -63,7 +63,10 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
63
63
|
requiredFields = props.requiredFields,
|
|
64
64
|
handleChangeNotifications = props.handleChangeNotifications,
|
|
65
65
|
handlePlaceOrderAsGuest = props.handlePlaceOrderAsGuest,
|
|
66
|
-
isAllowGuest = props.isAllowGuest
|
|
66
|
+
isAllowGuest = props.isAllowGuest,
|
|
67
|
+
isOrderTypeValidationField = props.isOrderTypeValidationField,
|
|
68
|
+
checkoutFields = props.checkoutFields,
|
|
69
|
+
isCheckoutPlace = props.isCheckoutPlace;
|
|
67
70
|
var formMethods = (0, _reactHookForm.useForm)();
|
|
68
71
|
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
69
72
|
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
@@ -144,8 +147,14 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
144
147
|
});
|
|
145
148
|
handlePlaceOrderAsGuest && handlePlaceOrderAsGuest();
|
|
146
149
|
};
|
|
147
|
-
var showInputPhoneNumber =
|
|
148
|
-
|
|
150
|
+
var showInputPhoneNumber = isOrderTypeValidationField ? checkoutFields === null || checkoutFields === void 0 || (_checkoutFields$find = checkoutFields.find(function (field) {
|
|
151
|
+
var _field$validation_fie;
|
|
152
|
+
return (field === null || field === void 0 || (_field$validation_fie = field.validation_field) === null || _field$validation_fie === void 0 ? void 0 : _field$validation_fie.code) === 'mobile_phone';
|
|
153
|
+
})) === null || _checkoutFields$find === void 0 ? void 0 : _checkoutFields$find.enabled : (_validationFields$fie = validationFields === null || validationFields === void 0 || (_validationFields$fie2 = validationFields.fields) === null || _validationFields$fie2 === void 0 || (_validationFields$fie2 = _validationFields$fie2.checkout) === null || _validationFields$fie2 === void 0 || (_validationFields$fie2 = _validationFields$fie2.cellphone) === null || _validationFields$fie2 === void 0 ? void 0 : _validationFields$fie2.enabled) !== null && _validationFields$fie !== void 0 ? _validationFields$fie : false;
|
|
154
|
+
var showInputBirthday = isOrderTypeValidationField ? checkoutFields === null || checkoutFields === void 0 || (_checkoutFields$find2 = checkoutFields.find(function (field) {
|
|
155
|
+
var _field$validation_fie2;
|
|
156
|
+
return (field === null || field === void 0 || (_field$validation_fie2 = field.validation_field) === null || _field$validation_fie2 === void 0 ? void 0 : _field$validation_fie2.code) === 'birthdate';
|
|
157
|
+
})) === null || _checkoutFields$find2 === void 0 ? void 0 : _checkoutFields$find2.enabled : (_validationFields$fie3 = validationFields === null || validationFields === void 0 || (_validationFields$fie4 = validationFields.fields) === null || _validationFields$fie4 === void 0 || (_validationFields$fie4 = _validationFields$fie4.checkout) === null || _validationFields$fie4 === void 0 || (_validationFields$fie4 = _validationFields$fie4.birthdate) === null || _validationFields$fie4 === void 0 ? void 0 : _validationFields$fie4.enabled) !== null && _validationFields$fie3 !== void 0 ? _validationFields$fie3 : false;
|
|
149
158
|
var setUserCellPhone = function setUserCellPhone() {
|
|
150
159
|
var isEdit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
151
160
|
if (userPhoneNumber && !userPhoneNumber.includes('null') && !isEdit) {
|
|
@@ -172,26 +181,34 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
172
181
|
setUserPhoneNumber((user === null || user === void 0 ? void 0 : user.cellphone) || '');
|
|
173
182
|
};
|
|
174
183
|
var onSubmit = function onSubmit() {
|
|
175
|
-
var _validationFields$fie5, _validationFields$fie6, _configs$verification;
|
|
176
|
-
var isPhoneNumberValid = userPhoneNumber ? isValidPhoneNumber : true;
|
|
177
|
-
|
|
184
|
+
var _requiredFields$inclu, _validationFields$fie5, _validationFields$fie6, _requiredFields$inclu2, _validationFields$fie7, _validationFields$fie8, _configs$verification;
|
|
185
|
+
var isPhoneNumberValid = userPhoneNumber && showInputPhoneNumber ? isValidPhoneNumber : true;
|
|
186
|
+
var requiredPhone = (user === null || user === void 0 ? void 0 : user.guest_id) && (requiredFields === null || requiredFields === void 0 || (_requiredFields$inclu = requiredFields.includes) === null || _requiredFields$inclu === void 0 ? void 0 : _requiredFields$inclu.call(requiredFields, 'cellphone')) || (validationFields === null || validationFields === void 0 || (_validationFields$fie5 = validationFields.fields) === null || _validationFields$fie5 === void 0 || (_validationFields$fie5 = _validationFields$fie5.checkout) === null || _validationFields$fie5 === void 0 || (_validationFields$fie5 = _validationFields$fie5.cellphone) === null || _validationFields$fie5 === void 0 ? void 0 : _validationFields$fie5.enabled) && (validationFields === null || validationFields === void 0 || (_validationFields$fie6 = validationFields.fields) === null || _validationFields$fie6 === void 0 || (_validationFields$fie6 = _validationFields$fie6.checkout) === null || _validationFields$fie6 === void 0 || (_validationFields$fie6 = _validationFields$fie6.cellphone) === null || _validationFields$fie6 === void 0 ? void 0 : _validationFields$fie6.required);
|
|
187
|
+
var content = [];
|
|
188
|
+
if (requiredFields !== null && requiredFields !== void 0 && (_requiredFields$inclu2 = requiredFields.includes) !== null && _requiredFields$inclu2 !== void 0 && _requiredFields$inclu2.call(requiredFields, 'birthdate') && !birthdate) {
|
|
189
|
+
content.push(t('VALIDATION_ERROR_BIRTHDATE_REQUIRED', 'Birthdate is required'));
|
|
190
|
+
}
|
|
191
|
+
if (!userPhoneNumber && (validationFields !== null && validationFields !== void 0 && (_validationFields$fie7 = validationFields.fields) !== null && _validationFields$fie7 !== void 0 && (_validationFields$fie7 = _validationFields$fie7.checkout) !== null && _validationFields$fie7 !== void 0 && (_validationFields$fie7 = _validationFields$fie7.cellphone) !== null && _validationFields$fie7 !== void 0 && _validationFields$fie7.enabled && validationFields !== null && validationFields !== void 0 && (_validationFields$fie8 = validationFields.fields) !== null && _validationFields$fie8 !== void 0 && (_validationFields$fie8 = _validationFields$fie8.checkout) !== null && _validationFields$fie8 !== void 0 && (_validationFields$fie8 = _validationFields$fie8.cellphone) !== null && _validationFields$fie8 !== void 0 && _validationFields$fie8.required || (configs === null || configs === void 0 || (_configs$verification = configs.verification_phone_required) === null || _configs$verification === void 0 ? void 0 : _configs$verification.value) === '1')) {
|
|
192
|
+
content.push(t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone Number is required.'));
|
|
178
193
|
setAlertState({
|
|
179
194
|
open: true,
|
|
180
|
-
content:
|
|
195
|
+
content: content
|
|
181
196
|
});
|
|
182
197
|
return;
|
|
183
198
|
}
|
|
184
199
|
if (!isPhoneNumberValid && userPhoneNumber) {
|
|
185
200
|
if (user !== null && user !== void 0 && user.country_phone_code) {
|
|
201
|
+
content.push(t('INVALID_ERROR_PHONE_NUMBER', 'The Phone Number field is invalid'));
|
|
186
202
|
setAlertState({
|
|
187
203
|
open: true,
|
|
188
|
-
content:
|
|
204
|
+
content: content
|
|
189
205
|
});
|
|
190
206
|
return;
|
|
191
207
|
}
|
|
208
|
+
content.push(t('INVALID_ERROR_COUNTRY_CODE_PHONE_NUMBER', 'The country code of the phone number is invalid'));
|
|
192
209
|
setAlertState({
|
|
193
210
|
open: true,
|
|
194
|
-
content:
|
|
211
|
+
content: content
|
|
195
212
|
});
|
|
196
213
|
return;
|
|
197
214
|
}
|
|
@@ -206,6 +223,13 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
206
223
|
if (isCustomerMode) {
|
|
207
224
|
setUserCustomer(formState.result.result, true);
|
|
208
225
|
}
|
|
226
|
+
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
227
|
+
setAlertState({
|
|
228
|
+
open: true,
|
|
229
|
+
content: content
|
|
230
|
+
});
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
209
233
|
handleButtonUpdateClick(changes);
|
|
210
234
|
}
|
|
211
235
|
};
|
|
@@ -248,9 +272,6 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
248
272
|
}
|
|
249
273
|
});
|
|
250
274
|
formMethods.setValue('email', e.target.value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, ''));
|
|
251
|
-
if (emailInput.current) {
|
|
252
|
-
emailInput.current.value = e.target.value.toLowerCase().replace(/[&,()%";:ç?<>{}\\[\]\s]/g, '');
|
|
253
|
-
}
|
|
254
275
|
};
|
|
255
276
|
var showFieldWithTheme = function showFieldWithTheme(name) {
|
|
256
277
|
var _theme$profile6;
|
|
@@ -305,37 +326,21 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
305
326
|
}
|
|
306
327
|
if (!isEdit) onCancel && onCancel();
|
|
307
328
|
}, [user, isEdit]);
|
|
308
|
-
(0, _react.useEffect)(function () {
|
|
309
|
-
if (!validationFields.loading && emailInput.current) {
|
|
310
|
-
var _formState$result9, _formState$result10, _ref, _formState$changes$em, _formState$changes8;
|
|
311
|
-
formMethods.setValue('email', formState !== null && formState !== void 0 && (_formState$result9 = formState.result) !== null && _formState$result9 !== void 0 && _formState$result9.result ? formState === null || formState === void 0 || (_formState$result10 = formState.result) === null || _formState$result10 === void 0 || (_formState$result10 = _formState$result10.result) === null || _formState$result10 === void 0 ? void 0 : _formState$result10.email : (_ref = (_formState$changes$em = formState === null || formState === void 0 || (_formState$changes8 = formState.changes) === null || _formState$changes8 === void 0 ? void 0 : _formState$changes8.email) !== null && _formState$changes$em !== void 0 ? _formState$changes$em : user && (user === null || user === void 0 ? void 0 : user.email)) !== null && _ref !== void 0 ? _ref : '');
|
|
312
|
-
}
|
|
313
|
-
}, [validationFields, emailInput.current]);
|
|
314
329
|
(0, _react.useEffect)(function () {
|
|
315
330
|
if (!validationFields.loading && birthdate) {
|
|
316
|
-
var _formState$
|
|
317
|
-
formMethods.setValue('birthdate', formState !== null && formState !== void 0 && (_formState$
|
|
331
|
+
var _formState$result9, _formState$result10, _ref, _formState$changes$bi, _formState$changes8;
|
|
332
|
+
formMethods.setValue('birthdate', formState !== null && formState !== void 0 && (_formState$result9 = formState.result) !== null && _formState$result9 !== void 0 && _formState$result9.result ? formState === null || formState === void 0 || (_formState$result10 = formState.result) === null || _formState$result10 === void 0 || (_formState$result10 = _formState$result10.result) === null || _formState$result10 === void 0 ? void 0 : _formState$result10.birthdate : (_ref = (_formState$changes$bi = formState === null || formState === void 0 || (_formState$changes8 = formState.changes) === null || _formState$changes8 === void 0 ? void 0 : _formState$changes8.birthdate) !== null && _formState$changes$bi !== void 0 ? _formState$changes$bi : user && (user === null || user === void 0 ? void 0 : user.birthdate)) !== null && _ref !== void 0 ? _ref : '');
|
|
318
333
|
}
|
|
319
334
|
}, [validationFields, birthdate]);
|
|
320
335
|
(0, _react.useEffect)(function () {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
required: isRequiredField('email') ? t('VALIDATION_ERROR_EMAIL_REQUIRED', 'The field Email is required').replace('_attribute_', t('EMAIL', 'Email')) : null,
|
|
324
|
-
pattern: {
|
|
325
|
-
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
|
326
|
-
message: t('INVALID_ERROR_EMAIL', 'Invalid email address').replace('_attribute_', t('EMAIL', 'Email'))
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
}, [formMethods]);
|
|
330
|
-
(0, _react.useEffect)(function () {
|
|
331
|
-
var _formState$changes10, _formState$changes11, _configs$verification2;
|
|
332
|
-
if (isChanged && userPhoneNumber && isValidPhoneNumber && formState !== null && formState !== void 0 && (_formState$changes10 = formState.changes) !== null && _formState$changes10 !== void 0 && _formState$changes10.country_phone_code && formState !== null && formState !== void 0 && (_formState$changes11 = formState.changes) !== null && _formState$changes11 !== void 0 && _formState$changes11.cellphone && (configs === null || configs === void 0 || (_configs$verification2 = configs.verification_phone_required) === null || _configs$verification2 === void 0 ? void 0 : _configs$verification2.value) === '1') {
|
|
336
|
+
var _formState$changes9, _formState$changes10, _configs$verification2;
|
|
337
|
+
if (isChanged && userPhoneNumber && isValidPhoneNumber && formState !== null && formState !== void 0 && (_formState$changes9 = formState.changes) !== null && _formState$changes9 !== void 0 && _formState$changes9.country_phone_code && formState !== null && formState !== void 0 && (_formState$changes10 = formState.changes) !== null && _formState$changes10 !== void 0 && _formState$changes10.cellphone && (configs === null || configs === void 0 || (_configs$verification2 = configs.verification_phone_required) === null || _configs$verification2 === void 0 ? void 0 : _configs$verification2.value) === '1') {
|
|
333
338
|
setWillVerifyOtpState && setWillVerifyOtpState(true);
|
|
334
339
|
}
|
|
335
340
|
}, [isValidPhoneNumber, userPhoneNumber, configs === null || configs === void 0 || (_configs$verification3 = configs.verification_phone_required) === null || _configs$verification3 === void 0 ? void 0 : _configs$verification3.value, isChanged]);
|
|
336
341
|
(0, _react.useEffect)(function () {
|
|
337
|
-
var _requiredFields$
|
|
338
|
-
if (requiredFields && !(requiredFields !== null && requiredFields !== void 0 && (_requiredFields$
|
|
342
|
+
var _requiredFields$inclu3;
|
|
343
|
+
if (requiredFields && !(requiredFields !== null && requiredFields !== void 0 && (_requiredFields$inclu3 = requiredFields.includes) !== null && _requiredFields$inclu3 !== void 0 && _requiredFields$inclu3.call(requiredFields, 'cellphone'))) setIsValidPhoneNumber(true);
|
|
339
344
|
}, [requiredFields]);
|
|
340
345
|
var handleEditNotifications = function handleEditNotifications(key, value) {
|
|
341
346
|
setNotificationList(_objectSpread(_objectSpread({}, notificationList), {}, _defineProperty({}, key, value)));
|
|
@@ -363,12 +368,13 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
363
368
|
key: i
|
|
364
369
|
}, props));
|
|
365
370
|
}), (0, _utils.sortInputFields)({
|
|
366
|
-
values: validationFields === null || validationFields === void 0 || (_validationFields$
|
|
367
|
-
}).map(function (
|
|
368
|
-
var _requiredFields$
|
|
369
|
-
|
|
371
|
+
values: isOrderTypeValidationField ? checkoutFields : validationFields === null || validationFields === void 0 || (_validationFields$fie9 = validationFields.fields) === null || _validationFields$fie9 === void 0 ? void 0 : _validationFields$fie9.checkout
|
|
372
|
+
}).map(function (item) {
|
|
373
|
+
var _requiredFields$inclu4, _ref2, _formState$changes$fi, _requiredFields$inclu5, _ref3, _formState$changes$fi2;
|
|
374
|
+
var field = (item === null || item === void 0 ? void 0 : item.validation_field) || item;
|
|
375
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
370
376
|
key: field.id
|
|
371
|
-
}, field.code === 'email' ? (requiredFields && (requiredFields === null || requiredFields === void 0 || (_requiredFields$
|
|
377
|
+
}, field.code === 'email' ? (isOrderTypeValidationField ? item === null || item === void 0 ? void 0 : item.enabled : showField && showField(field.code)) && (requiredFields && (requiredFields === null || requiredFields === void 0 || (_requiredFields$inclu4 = requiredFields.includes) === null || _requiredFields$inclu4 === void 0 ? void 0 : _requiredFields$inclu4.call(requiredFields, field.code)) || !requiredFields || !isCheckoutPlace) && /*#__PURE__*/_react.default.createElement(_styles.InputGroup, null, /*#__PURE__*/_react.default.createElement("p", null, t(field.code.toUpperCase(), field === null || field === void 0 ? void 0 : field.name)), /*#__PURE__*/_react.default.createElement(_Inputs.Input, {
|
|
372
378
|
key: field.id,
|
|
373
379
|
type: field.type,
|
|
374
380
|
name: field.code,
|
|
@@ -376,13 +382,14 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
376
382
|
borderBottom: true,
|
|
377
383
|
disabled: !isEdit,
|
|
378
384
|
placeholder: t(field.code.toUpperCase(), field === null || field === void 0 ? void 0 : field.name),
|
|
379
|
-
defaultValue: (
|
|
385
|
+
defaultValue: (_ref2 = (_formState$changes$fi = formState === null || formState === void 0 ? void 0 : formState.changes[field.code]) !== null && _formState$changes$fi !== void 0 ? _formState$changes$fi : user && user[field.code]) !== null && _ref2 !== void 0 ? _ref2 : '',
|
|
380
386
|
onChange: handleChangeInputEmail,
|
|
381
|
-
ref:
|
|
382
|
-
|
|
383
|
-
|
|
387
|
+
ref: formMethods.register({
|
|
388
|
+
required: t('VALIDATION_ERROR_EMAIL_REQUIRED', 'The field Email is required').replace('_attribute_', t('EMAIL', 'Email')),
|
|
389
|
+
pattern: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i
|
|
390
|
+
}),
|
|
384
391
|
autoComplete: "off"
|
|
385
|
-
})) : (requiredFields && (requiredFields === null || requiredFields === void 0 || (_requiredFields$
|
|
392
|
+
})) : (isOrderTypeValidationField ? item === null || item === void 0 ? void 0 : item.enabled : showField && showField(field.code)) && (requiredFields && (requiredFields === null || requiredFields === void 0 || (_requiredFields$inclu5 = requiredFields.includes) === null || _requiredFields$inclu5 === void 0 ? void 0 : _requiredFields$inclu5.call(requiredFields, field.code)) || !requiredFields || !isCheckoutPlace) && /*#__PURE__*/_react.default.createElement(_styles.InputGroup, null, /*#__PURE__*/_react.default.createElement("p", null, t(field.code.toUpperCase(), field === null || field === void 0 ? void 0 : field.name)), /*#__PURE__*/_react.default.createElement(_Inputs.Input, {
|
|
386
393
|
key: field.id,
|
|
387
394
|
type: field.type,
|
|
388
395
|
borderBottom: true,
|
|
@@ -390,26 +397,29 @@ var UserFormDetailsUI = exports.UserFormDetailsUI = function UserFormDetailsUI(p
|
|
|
390
397
|
className: "form",
|
|
391
398
|
disabled: !isEdit,
|
|
392
399
|
placeholder: t(field.code.toUpperCase(), field === null || field === void 0 ? void 0 : field.name),
|
|
393
|
-
defaultValue: (
|
|
400
|
+
defaultValue: (_ref3 = (_formState$changes$fi2 = formState === null || formState === void 0 ? void 0 : formState.changes[field.code]) !== null && _formState$changes$fi2 !== void 0 ? _formState$changes$fi2 : user && user[field.code]) !== null && _ref3 !== void 0 ? _ref3 : '',
|
|
394
401
|
onChange: handleChangeInput,
|
|
395
402
|
ref: formMethods.register({
|
|
396
403
|
required: isRequiredField(field.code) ? t("VALIDATION_ERROR_".concat(field.code.toUpperCase(), "_REQUIRED"), "".concat(field === null || field === void 0 ? void 0 : field.name, " is required")).replace('_attribute_', t(field === null || field === void 0 ? void 0 : field.name, field.code)) : null
|
|
397
404
|
}),
|
|
398
405
|
autoComplete: "off"
|
|
399
406
|
})));
|
|
400
|
-
}), (!(user !== null && user !== void 0 && user.guest_id) && showInputBirthday || (user === null || user === void 0 ? void 0 : user.guest_id) && (requiredFields === null || requiredFields === void 0 || (_requiredFields$
|
|
407
|
+
}), (!(user !== null && user !== void 0 && user.guest_id) && showInputBirthday || isOrderTypeValidationField || (user === null || user === void 0 ? void 0 : user.guest_id)) && showInputBirthday && (requiredFields && (requiredFields === null || requiredFields === void 0 || (_requiredFields$inclu6 = requiredFields.includes) === null || _requiredFields$inclu6 === void 0 ? void 0 : _requiredFields$inclu6.call(requiredFields, 'birthdate')) || !requiredFields || !isCheckoutPlace) && /*#__PURE__*/_react.default.createElement(_styles.InputPhoneNumberWrapper, null, /*#__PURE__*/_react.default.createElement("p", null, t('BIRTHDATE', 'Birthdate')), /*#__PURE__*/_react.default.createElement(_Inputs.Input, {
|
|
401
408
|
borderBottom: true,
|
|
402
409
|
className: "form",
|
|
403
410
|
value: birthdate ? (0, _moment.default)(birthdate).format('YYYY/MM/DD') : '',
|
|
404
411
|
autoComplete: "off",
|
|
405
412
|
onFocus: function onFocus() {
|
|
406
413
|
return setOpenCalendar(true);
|
|
407
|
-
}
|
|
414
|
+
},
|
|
415
|
+
ref: formMethods.register({
|
|
416
|
+
required: isRequiredField('birthdate') ? t('VALIDATION_ERROR_BIRTHDATE_REQUIRED', 'Birthdate is required') : null
|
|
417
|
+
})
|
|
408
418
|
}), openCalendar && /*#__PURE__*/_react.default.createElement(_DatePicker.DatePickerUI, {
|
|
409
419
|
value: birthdate,
|
|
410
420
|
onChange: _handleChangeDate,
|
|
411
421
|
name: 'birthdate'
|
|
412
|
-
})), (!(user !== null && user !== void 0 && user.guest_id) && !!showInputPhoneNumber || (user === null || user === void 0 ? void 0 : user.guest_id)
|
|
422
|
+
})), (!(user !== null && user !== void 0 && user.guest_id) && !!showInputPhoneNumber || isOrderTypeValidationField || (user === null || user === void 0 ? void 0 : user.guest_id)) && showCustomerCellphone && (requiredFields && (requiredFields === null || requiredFields === void 0 || (_requiredFields$inclu7 = requiredFields.includes) === null || _requiredFields$inclu7 === void 0 ? void 0 : _requiredFields$inclu7.call(requiredFields, 'cellphone')) || !requiredFields || !isCheckoutPlace) && /*#__PURE__*/_react.default.createElement(_styles.InputPhoneNumberWrapper, null, /*#__PURE__*/_react.default.createElement("p", null, t('PHONE', 'Phone')), /*#__PURE__*/_react.default.createElement(_InputPhoneNumber.InputPhoneNumber, {
|
|
413
423
|
user: user,
|
|
414
424
|
value: userPhoneNumber,
|
|
415
425
|
setValue: handleChangePhoneNumber,
|
package/_modules/utils/index.js
CHANGED
|
@@ -221,13 +221,14 @@ var sortInputFields = exports.sortInputFields = function sortInputFields(_ref2)
|
|
|
221
221
|
values = _ref2.values;
|
|
222
222
|
var fieldsBase = fields;
|
|
223
223
|
var fieldsSorted = [];
|
|
224
|
-
var fieldsArray = Array.isArray(values) ? values : Object.values(values);
|
|
224
|
+
var fieldsArray = Array.isArray(values) ? values : values && Object.values(values);
|
|
225
225
|
if (!fieldsBase) {
|
|
226
226
|
fieldsBase = fieldsToSort;
|
|
227
227
|
}
|
|
228
228
|
fieldsBase.forEach(function (f) {
|
|
229
|
-
fieldsArray.forEach(function (field) {
|
|
230
|
-
|
|
229
|
+
fieldsArray && fieldsArray.forEach(function (field) {
|
|
230
|
+
var _field$validation_fie;
|
|
231
|
+
if (f === field.code || f === (field === null || field === void 0 || (_field$validation_fie = field.validation_field) === null || _field$validation_fie === void 0 ? void 0 : _field$validation_fie.code)) {
|
|
231
232
|
fieldsSorted.push(field);
|
|
232
233
|
}
|
|
233
234
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ordering-ui-external",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "Ordering UI Components",
|
|
5
5
|
"main": "./_modules/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"lodash": "^4.17.19",
|
|
89
89
|
"moment": "^2.29.4",
|
|
90
90
|
"nanoid": "^4.0.0",
|
|
91
|
-
"ordering-components-external": "
|
|
91
|
+
"ordering-components-external": "11.0.1",
|
|
92
92
|
"payment": "^2.4.6",
|
|
93
93
|
"polished": "^3.6.6",
|
|
94
94
|
"react-bootstrap-icons": "^1.7.2",
|
|
@@ -28,7 +28,7 @@ export const ContainerCard = styled.div`
|
|
|
28
28
|
padding: 10px 30px;
|
|
29
29
|
}
|
|
30
30
|
`}
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
${({ firstCard }) => firstCard && css`
|
|
33
33
|
margin-left: 0;
|
|
34
34
|
`}
|
|
@@ -36,7 +36,7 @@ export const ContainerCard = styled.div`
|
|
|
36
36
|
${({ disabled }) => disabled && css`
|
|
37
37
|
cursor: not-allowed;
|
|
38
38
|
`}
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
${({ businessRows }) => css`
|
|
41
41
|
width: calc(100% - 40px);
|
|
42
42
|
|
|
@@ -56,7 +56,7 @@ export const ContainerCard = styled.div`
|
|
|
56
56
|
width: ${() => businessRows === 4 ? 'calc(25% - 40px)' : businessRows === 3 ? 'calc(33% - 40px)' : 'calc(50% - 40px)'};
|
|
57
57
|
}
|
|
58
58
|
`}
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
`
|
|
61
61
|
|
|
62
62
|
export const WrapperBusinessCard = styled.div`
|
|
@@ -340,7 +340,7 @@ export const Medadata = styled.div`
|
|
|
340
340
|
font-size: 12px;
|
|
341
341
|
color: #909BA9;
|
|
342
342
|
flex-wrap: wrap;
|
|
343
|
-
|
|
343
|
+
|
|
344
344
|
|
|
345
345
|
${({ isCustomerMode }) => isCustomerMode && css`
|
|
346
346
|
> div {
|