ordering-components-external 13.2.23 → 13.2.25
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/{7.ordering-component.7eadc8f0cb2d9320da3a.js → 7.ordering-component.4a1e766eb57cfebad17d.js} +1 -1
- package/_bundles/{ordering-component.7eadc8f0cb2d9320da3a.js → ordering-component.4a1e766eb57cfebad17d.js} +2 -2
- package/_modules/components/PaymentOptionStripeLink/index.js +10 -1
- package/_modules/components/ProductOptionSuboption/index.js +37 -4
- package/package.json +1 -1
- package/src/components/PaymentOptionStripeLink/index.js +10 -1
- package/src/components/ProductOptionSuboption/index.js +48 -4
- /package/_bundles/{0.ordering-component.7eadc8f0cb2d9320da3a.js → 0.ordering-component.4a1e766eb57cfebad17d.js} +0 -0
- /package/_bundles/{1.ordering-component.7eadc8f0cb2d9320da3a.js → 1.ordering-component.4a1e766eb57cfebad17d.js} +0 -0
- /package/_bundles/{2.ordering-component.7eadc8f0cb2d9320da3a.js → 2.ordering-component.4a1e766eb57cfebad17d.js} +0 -0
- /package/_bundles/{4.ordering-component.7eadc8f0cb2d9320da3a.js → 4.ordering-component.4a1e766eb57cfebad17d.js} +0 -0
- /package/_bundles/{5.ordering-component.7eadc8f0cb2d9320da3a.js → 5.ordering-component.4a1e766eb57cfebad17d.js} +0 -0
- /package/_bundles/{6.ordering-component.7eadc8f0cb2d9320da3a.js → 6.ordering-component.4a1e766eb57cfebad17d.js} +0 -0
- /package/_bundles/{7.ordering-component.7eadc8f0cb2d9320da3a.js.LICENSE.txt → 7.ordering-component.4a1e766eb57cfebad17d.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-component.7eadc8f0cb2d9320da3a.js → 8.ordering-component.4a1e766eb57cfebad17d.js} +0 -0
- /package/_bundles/{ordering-component.7eadc8f0cb2d9320da3a.js.LICENSE.txt → ordering-component.4a1e766eb57cfebad17d.js.LICENSE.txt} +0 -0
|
@@ -34,7 +34,8 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
34
34
|
*/
|
|
35
35
|
var PaymentOptionStripeLink = exports.PaymentOptionStripeLink = function PaymentOptionStripeLink(props) {
|
|
36
36
|
var UIComponent = props.UIComponent,
|
|
37
|
-
paymentURL = props.paymentURL
|
|
37
|
+
paymentURL = props.paymentURL,
|
|
38
|
+
cartTotal = props.cartTotal;
|
|
38
39
|
var _useApi = (0, _ApiContext.useApi)(),
|
|
39
40
|
_useApi2 = _slicedToArray(_useApi, 1),
|
|
40
41
|
ordering = _useApi2[0];
|
|
@@ -78,6 +79,14 @@ var PaymentOptionStripeLink = exports.PaymentOptionStripeLink = function Payment
|
|
|
78
79
|
provider: customProviders.includes(ordering === null || ordering === void 0 ? void 0 : ordering.project) ? 'custom' : 'twilio',
|
|
79
80
|
country_phone_code: userInfo.country_phone_code,
|
|
80
81
|
cellphone: userInfo.cellphone,
|
|
82
|
+
payment_url: paymentURL,
|
|
83
|
+
user: {
|
|
84
|
+
name: userInfo === null || userInfo === void 0 ? void 0 : userInfo.name,
|
|
85
|
+
lastname: userInfo === null || userInfo === void 0 ? void 0 : userInfo.lastname
|
|
86
|
+
},
|
|
87
|
+
cart: {
|
|
88
|
+
total: cartTotal !== null && cartTotal !== void 0 ? cartTotal : 0
|
|
89
|
+
},
|
|
81
90
|
message: t('LINK_TO_PAY_MESSAGE', 'Hello there _name_ _lastname_, click on the following link to complete the payment: _link_').replace('_name_', userInfo === null || userInfo === void 0 ? void 0 : userInfo.name).replace('_lastname_', userInfo === null || userInfo === void 0 ? void 0 : userInfo.lastname).replace('_link_', paymentURL)
|
|
82
91
|
};
|
|
83
92
|
_context.next = 6;
|
|
@@ -73,13 +73,16 @@ var ProductOptionSuboption = exports.ProductOptionSuboption = function ProductOp
|
|
|
73
73
|
var selectStatus = isOrigin ? !state.selected : state.selected;
|
|
74
74
|
var minMaxValidation = option.with_half_option ? usePizzaValidation : balance === option.max && !((option === null || option === void 0 ? void 0 : option.max) === 1 && (option === null || option === void 0 ? void 0 : option.min) === 1);
|
|
75
75
|
var canBeSelectedByHalf = (pizzaState === null || pizzaState === void 0 || (_pizzaState2 = pizzaState["option:".concat(option === null || option === void 0 ? void 0 : option.id)]) === null || _pizzaState2 === void 0 ? void 0 : _pizzaState2.value) === option.max - 0.5 && option.with_half_option;
|
|
76
|
+
var shouldApplyHalfLogic = (option === null || option === void 0 ? void 0 : option.with_half_option) && (option === null || option === void 0 ? void 0 : option.allow_suboption_quantity) && (option === null || option === void 0 ? void 0 : option.limit_suboptions_by_max);
|
|
77
|
+
var remainingBalance = option.max - balance;
|
|
78
|
+
var canOnlySelectHalf = shouldApplyHalfLogic && remainingBalance < 1 && remainingBalance > 0;
|
|
76
79
|
if (selectStatus && (option.limit_suboptions_by_max || isAlsea) && minMaxValidation && !canBeSelectedByHalf) {
|
|
77
80
|
return;
|
|
78
81
|
}
|
|
79
82
|
changeState(_objectSpread(_objectSpread({}, state), {}, {
|
|
80
83
|
quantity: state.selected ? 0 : 1,
|
|
81
84
|
selected: !state.selected,
|
|
82
|
-
position: canBeSelectedByHalf ? 'left' : 'whole'
|
|
85
|
+
position: canBeSelectedByHalf || canOnlySelectHalf ? 'left' : 'whole'
|
|
83
86
|
}));
|
|
84
87
|
};
|
|
85
88
|
|
|
@@ -87,12 +90,27 @@ var ProductOptionSuboption = exports.ProductOptionSuboption = function ProductOp
|
|
|
87
90
|
* Increment suboption quantity
|
|
88
91
|
*/
|
|
89
92
|
var increment = function increment() {
|
|
93
|
+
var shouldApplyHalfLogic = (option === null || option === void 0 ? void 0 : option.with_half_option) && (option === null || option === void 0 ? void 0 : option.allow_suboption_quantity) && (option === null || option === void 0 ? void 0 : option.limit_suboptions_by_max);
|
|
94
|
+
var maxByPosition = shouldApplyHalfLogic && state.position !== 'whole' ? suboption.max * 2 : suboption.max;
|
|
95
|
+
|
|
96
|
+
// Validar si incrementar excedería el máximo de la opción cuando está en 'whole'
|
|
97
|
+
if (shouldApplyHalfLogic && state.position === 'whole') {
|
|
98
|
+
var _pizzaState3;
|
|
99
|
+
var otherOptionsValue = 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;
|
|
100
|
+
var wouldExceedMax = otherOptionsValue + 1 > option.max;
|
|
101
|
+
if (wouldExceedMax) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
90
105
|
if (!(option !== null && option !== void 0 && option.with_half_option) && option.limit_suboptions_by_max && (balance === option.max || state.quantity === suboption.max)) {
|
|
91
106
|
return;
|
|
92
107
|
}
|
|
93
108
|
if (!(option !== null && option !== void 0 && option.with_half_option) && !option.limit_suboptions_by_max && state.quantity === suboption.max) {
|
|
94
109
|
return;
|
|
95
110
|
}
|
|
111
|
+
if (shouldApplyHalfLogic && state.quantity === maxByPosition) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
96
114
|
if (option !== null && option !== void 0 && option.with_half_option && usePizzaValidation) {
|
|
97
115
|
return;
|
|
98
116
|
}
|
|
@@ -123,16 +141,31 @@ var ProductOptionSuboption = exports.ProductOptionSuboption = function ProductOp
|
|
|
123
141
|
*/
|
|
124
142
|
var changePosition = function changePosition(position) {
|
|
125
143
|
var price = option.with_half_option && suboption.half_price && position !== 'whole' ? suboption.half_price : suboption.price;
|
|
144
|
+
var shouldApplyHalfLogic = (option === null || option === void 0 ? void 0 : option.with_half_option) && (option === null || option === void 0 ? void 0 : option.allow_suboption_quantity) && (option === null || option === void 0 ? void 0 : option.limit_suboptions_by_max);
|
|
145
|
+
if (shouldApplyHalfLogic && position === 'whole') {
|
|
146
|
+
var _pizzaState4;
|
|
147
|
+
var otherOptionsValue = pizzaState === null || pizzaState === void 0 || (_pizzaState4 = pizzaState["option:".concat(option === null || option === void 0 ? void 0 : option.id)]) === null || _pizzaState4 === void 0 ? void 0 : _pizzaState4.value;
|
|
148
|
+
var additionalValue = position === 'whole' ? state.quantity / 2 : 0;
|
|
149
|
+
var wouldExceedMax = otherOptionsValue + additionalValue > option.max;
|
|
150
|
+
if (wouldExceedMax) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
var newQuantity = state.quantity;
|
|
155
|
+
if (shouldApplyHalfLogic && position === 'whole' && state.quantity > suboption.max) {
|
|
156
|
+
newQuantity = suboption.max;
|
|
157
|
+
}
|
|
126
158
|
changeState(_objectSpread(_objectSpread({}, state), {}, {
|
|
127
159
|
position: position,
|
|
128
160
|
price: price,
|
|
129
|
-
|
|
161
|
+
quantity: newQuantity,
|
|
162
|
+
total: price * newQuantity
|
|
130
163
|
}));
|
|
131
164
|
};
|
|
132
165
|
|
|
133
166
|
/**
|
|
134
|
-
* Change
|
|
135
|
-
* @param {
|
|
167
|
+
* Change quantity of the suboption
|
|
168
|
+
* @param {number} quantity Quantity of the suboption
|
|
136
169
|
*/
|
|
137
170
|
var changeQuantity = function changeQuantity(quantity) {
|
|
138
171
|
changeState(_objectSpread(_objectSpread({}, state), {}, {
|
package/package.json
CHANGED
|
@@ -11,7 +11,8 @@ import { useSession } from '../../contexts/SessionContext'
|
|
|
11
11
|
export const PaymentOptionStripeLink = (props) => {
|
|
12
12
|
const {
|
|
13
13
|
UIComponent,
|
|
14
|
-
paymentURL
|
|
14
|
+
paymentURL,
|
|
15
|
+
cartTotal
|
|
15
16
|
} = props
|
|
16
17
|
|
|
17
18
|
const [ordering] = useApi()
|
|
@@ -35,6 +36,14 @@ export const PaymentOptionStripeLink = (props) => {
|
|
|
35
36
|
provider: customProviders.includes(ordering?.project) ? 'custom' : 'twilio',
|
|
36
37
|
country_phone_code: userInfo.country_phone_code,
|
|
37
38
|
cellphone: userInfo.cellphone,
|
|
39
|
+
payment_url: paymentURL,
|
|
40
|
+
user: {
|
|
41
|
+
name: userInfo?.name,
|
|
42
|
+
lastname: userInfo?.lastname
|
|
43
|
+
},
|
|
44
|
+
cart: {
|
|
45
|
+
total: cartTotal ?? 0
|
|
46
|
+
},
|
|
38
47
|
message: t('LINK_TO_PAY_MESSAGE',
|
|
39
48
|
'Hello there _name_ _lastname_, click on the following link to complete the payment: _link_')
|
|
40
49
|
.replace('_name_', userInfo?.name)
|
|
@@ -51,14 +51,20 @@ export const ProductOptionSuboption = (props) => {
|
|
|
51
51
|
const selectStatus = isOrigin ? !state.selected : state.selected
|
|
52
52
|
const minMaxValidation = option.with_half_option ? usePizzaValidation : (balance === option.max && !(option?.max === 1 && option?.min === 1))
|
|
53
53
|
const canBeSelectedByHalf = (pizzaState?.[`option:${option?.id}`]?.value === (option.max - 0.5)) && option.with_half_option
|
|
54
|
+
|
|
55
|
+
const shouldApplyHalfLogic = option?.with_half_option && option?.allow_suboption_quantity && option?.limit_suboptions_by_max
|
|
56
|
+
const remainingBalance = option.max - balance
|
|
57
|
+
const canOnlySelectHalf = shouldApplyHalfLogic && remainingBalance < 1 && remainingBalance > 0
|
|
58
|
+
|
|
54
59
|
if (selectStatus && (option.limit_suboptions_by_max || isAlsea) && minMaxValidation && !canBeSelectedByHalf) {
|
|
55
60
|
return
|
|
56
61
|
}
|
|
62
|
+
|
|
57
63
|
changeState({
|
|
58
64
|
...state,
|
|
59
65
|
quantity: state.selected ? 0 : 1,
|
|
60
66
|
selected: !state.selected,
|
|
61
|
-
position: canBeSelectedByHalf ? 'left' : 'whole'
|
|
67
|
+
position: (canBeSelectedByHalf || canOnlySelectHalf) ? 'left' : 'whole'
|
|
62
68
|
})
|
|
63
69
|
}
|
|
64
70
|
|
|
@@ -66,15 +72,34 @@ export const ProductOptionSuboption = (props) => {
|
|
|
66
72
|
* Increment suboption quantity
|
|
67
73
|
*/
|
|
68
74
|
const increment = () => {
|
|
75
|
+
const shouldApplyHalfLogic = option?.with_half_option && option?.allow_suboption_quantity && option?.limit_suboptions_by_max
|
|
76
|
+
const maxByPosition = shouldApplyHalfLogic && state.position !== 'whole'
|
|
77
|
+
? suboption.max * 2
|
|
78
|
+
: suboption.max
|
|
79
|
+
|
|
80
|
+
// Validar si incrementar excedería el máximo de la opción cuando está en 'whole'
|
|
81
|
+
if (shouldApplyHalfLogic && state.position === 'whole') {
|
|
82
|
+
const otherOptionsValue = pizzaState?.[`option:${option?.id}`]?.value
|
|
83
|
+
const wouldExceedMax = (otherOptionsValue + 1) > option.max
|
|
84
|
+
|
|
85
|
+
if (wouldExceedMax) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
69
90
|
if (!option?.with_half_option && option.limit_suboptions_by_max && (balance === option.max || state.quantity === suboption.max)) {
|
|
70
91
|
return
|
|
71
92
|
}
|
|
72
93
|
if (!option?.with_half_option && !option.limit_suboptions_by_max && state.quantity === suboption.max) {
|
|
73
94
|
return
|
|
74
95
|
}
|
|
96
|
+
if (shouldApplyHalfLogic && state.quantity === maxByPosition) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
75
99
|
if (option?.with_half_option && usePizzaValidation) {
|
|
76
100
|
return
|
|
77
101
|
}
|
|
102
|
+
|
|
78
103
|
changeState({
|
|
79
104
|
...state,
|
|
80
105
|
selected: state.quantity === 0 ? true : state.selected,
|
|
@@ -104,17 +129,36 @@ export const ProductOptionSuboption = (props) => {
|
|
|
104
129
|
*/
|
|
105
130
|
const changePosition = (position) => {
|
|
106
131
|
const price = option.with_half_option && suboption.half_price && position !== 'whole' ? suboption.half_price : suboption.price
|
|
132
|
+
|
|
133
|
+
const shouldApplyHalfLogic = option?.with_half_option && option?.allow_suboption_quantity && option?.limit_suboptions_by_max
|
|
134
|
+
|
|
135
|
+
if (shouldApplyHalfLogic && position === 'whole') {
|
|
136
|
+
const otherOptionsValue = pizzaState?.[`option:${option?.id}`]?.value
|
|
137
|
+
const additionalValue = position === 'whole' ? state.quantity / 2 : 0
|
|
138
|
+
const wouldExceedMax = (otherOptionsValue + additionalValue) > option.max
|
|
139
|
+
|
|
140
|
+
if (wouldExceedMax) {
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let newQuantity = state.quantity
|
|
146
|
+
if (shouldApplyHalfLogic && position === 'whole' && state.quantity > suboption.max) {
|
|
147
|
+
newQuantity = suboption.max
|
|
148
|
+
}
|
|
149
|
+
|
|
107
150
|
changeState({
|
|
108
151
|
...state,
|
|
109
152
|
position,
|
|
110
153
|
price,
|
|
111
|
-
|
|
154
|
+
quantity: newQuantity,
|
|
155
|
+
total: price * newQuantity
|
|
112
156
|
})
|
|
113
157
|
}
|
|
114
158
|
|
|
115
159
|
/**
|
|
116
|
-
* Change
|
|
117
|
-
* @param {
|
|
160
|
+
* Change quantity of the suboption
|
|
161
|
+
* @param {number} quantity Quantity of the suboption
|
|
118
162
|
*/
|
|
119
163
|
const changeQuantity = (quantity) => {
|
|
120
164
|
changeState({
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|