ordering-ui-external 2.5.0 → 2.5.2
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.5657c6a53b3791887fd7.js → 0.ordering-ui.cf22ed960e0a8685bf74.js} +1 -1
- package/_bundles/{5.ordering-ui.5657c6a53b3791887fd7.js → 5.ordering-ui.cf22ed960e0a8685bf74.js} +1 -1
- package/_bundles/{7.ordering-ui.5657c6a53b3791887fd7.js → 7.ordering-ui.cf22ed960e0a8685bf74.js} +1 -1
- package/_bundles/{ordering-ui.5657c6a53b3791887fd7.js → ordering-ui.cf22ed960e0a8685bf74.js} +2 -2
- package/_modules/components/StripeMethodForm/index.js +26 -11
- package/_modules/themes/five/src/components/CitiesControl/index.js +1 -1
- package/_modules/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/index.js +1 -1
- package/_modules/themes/five/src/components/MultiCartsPaymethodsAndWallets/index.js +36 -5
- package/_modules/themes/five/src/components/MultiCheckout/index.js +30 -3
- package/_modules/themes/five/src/components/OrderDetails/OrderEta.js +2 -4
- package/_modules/themes/five/src/components/OrderProgress/index.js +11 -5
- package/_modules/themes/five/src/components/PaymentOptions/index.js +8 -5
- package/_modules/themes/five/src/components/StripeElementsForm/index.js +3 -1
- package/package.json +1 -1
- package/src/components/StripeMethodForm/index.js +22 -10
- package/src/themes/five/src/components/CitiesControl/index.js +1 -1
- package/src/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/index.js +1 -1
- package/src/themes/five/src/components/MultiCartsPaymethodsAndWallets/index.js +83 -51
- package/src/themes/five/src/components/MultiCheckout/index.js +16 -0
- package/src/themes/five/src/components/OrderDetails/OrderEta.js +4 -2
- package/src/themes/five/src/components/OrderProgress/index.js +9 -3
- package/src/themes/five/src/components/PaymentOptions/index.js +7 -4
- package/src/themes/five/src/components/StripeElementsForm/index.js +3 -1
- /package/_bundles/{1.ordering-ui.5657c6a53b3791887fd7.js → 1.ordering-ui.cf22ed960e0a8685bf74.js} +0 -0
- /package/_bundles/{2.ordering-ui.5657c6a53b3791887fd7.js → 2.ordering-ui.cf22ed960e0a8685bf74.js} +0 -0
- /package/_bundles/{4.ordering-ui.5657c6a53b3791887fd7.js → 4.ordering-ui.cf22ed960e0a8685bf74.js} +0 -0
- /package/_bundles/{6.ordering-ui.5657c6a53b3791887fd7.js → 6.ordering-ui.cf22ed960e0a8685bf74.js} +0 -0
- /package/_bundles/{7.ordering-ui.5657c6a53b3791887fd7.js.LICENSE.txt → 7.ordering-ui.cf22ed960e0a8685bf74.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-ui.5657c6a53b3791887fd7.js → 8.ordering-ui.cf22ed960e0a8685bf74.js} +0 -0
- /package/_bundles/{9.ordering-ui.5657c6a53b3791887fd7.js → 9.ordering-ui.cf22ed960e0a8685bf74.js} +0 -0
- /package/_bundles/{ordering-ui.5657c6a53b3791887fd7.js.LICENSE.txt → ordering-ui.cf22ed960e0a8685bf74.js.LICENSE.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
useLanguage,
|
|
4
4
|
useConfig,
|
|
@@ -28,6 +28,8 @@ import {
|
|
|
28
28
|
SectionLeft,
|
|
29
29
|
SectionLeftText
|
|
30
30
|
} from './styles'
|
|
31
|
+
import { StripeElementsForm } from '../StripeElementsForm'
|
|
32
|
+
import Modal from '../Modal'
|
|
31
33
|
|
|
32
34
|
const stripeOptions = ['stripe_direct', 'stripe', 'stripe_connect']
|
|
33
35
|
|
|
@@ -72,17 +74,21 @@ const MultiCartsPaymethodsAndWalletsUI = (props) => {
|
|
|
72
74
|
handlePaymethodDataChange,
|
|
73
75
|
setCardList,
|
|
74
76
|
walletsPaymethod,
|
|
75
|
-
isCustomerMode
|
|
77
|
+
isCustomerMode,
|
|
78
|
+
handlePlaceOrder,
|
|
79
|
+
cartGroup
|
|
76
80
|
} = props
|
|
77
81
|
|
|
78
82
|
const theme = useTheme()
|
|
79
83
|
const [, t] = useLanguage()
|
|
80
84
|
const [{ configs }] = useConfig()
|
|
81
85
|
const [{ parsePrice }] = useUtils()
|
|
86
|
+
const [openPaymethod, setOpenPaymethod] = useState(null)
|
|
82
87
|
|
|
83
88
|
const isWalletCashEnabled = configs?.wallet_cash_enabled?.value === '1'
|
|
84
89
|
const isWalletPointsEnabled = configs?.wallet_credit_point_enabled?.value === '1'
|
|
85
|
-
|
|
90
|
+
const methodsPay = ['global_google_pay', 'global_apple_pay']
|
|
91
|
+
const stripeDirectMethods = ['stripe_direct', ...methodsPay]
|
|
86
92
|
const walletName = {
|
|
87
93
|
cash: {
|
|
88
94
|
name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
|
|
@@ -109,7 +115,10 @@ const MultiCartsPaymethodsAndWalletsUI = (props) => {
|
|
|
109
115
|
{(!isCustomerMode || (isCustomerMode && (paymethod.gateway === 'card_delivery' || paymethod.gateway === 'cash'))) && (
|
|
110
116
|
<PayCard
|
|
111
117
|
isActive={paymethodSelected?.id === paymethod.id}
|
|
112
|
-
onClick={() =>
|
|
118
|
+
onClick={() => {
|
|
119
|
+
handleSelectPaymethod({ ...paymethod, paymethod: { gateway: paymethod.gateway }, paymethod_id: paymethod?.id })
|
|
120
|
+
setOpenPaymethod(paymethod)
|
|
121
|
+
}}
|
|
113
122
|
>
|
|
114
123
|
<div>{getPayIcon(paymethod.id)}</div>
|
|
115
124
|
<p>{t(paymethod?.gateway.toUpperCase(), paymethod?.name)}</p>
|
|
@@ -161,57 +170,80 @@ const MultiCartsPaymethodsAndWalletsUI = (props) => {
|
|
|
161
170
|
{walletsState?.result?.filter(wallet =>
|
|
162
171
|
paymethodsAndWallets.wallets.find(item => item.type === wallet.type))
|
|
163
172
|
.map((wallet, idx) => walletName[wallet.type]?.isActive &&
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
173
|
+
(
|
|
174
|
+
<WalletOptionContainer
|
|
175
|
+
key={wallet.type}
|
|
176
|
+
isBottomBorder={idx === paymethodsAndWallets.wallets?.length - 1}
|
|
177
|
+
>
|
|
178
|
+
<SectionLeft>
|
|
179
|
+
<Checkbox
|
|
180
|
+
name={`payment_option_${wallet.type}`}
|
|
181
|
+
id={`custom-checkbox-${idx}`}
|
|
182
|
+
disabled={
|
|
183
|
+
(balance === 0 && !walletsPaymethod?.find(walletPay => walletPay.wallet_id === wallet.id)?.id) ||
|
|
184
|
+
wallet.balance === 0
|
|
185
|
+
}
|
|
186
|
+
value={`payment_option_${wallet.type}`}
|
|
187
|
+
checked={!!walletsPaymethod?.find(walletPay => walletPay.wallet_id === wallet.id)?.id}
|
|
188
|
+
onChange={() => handleSelectWallet(
|
|
189
|
+
!walletsPaymethod?.find(walletPay => walletPay.wallet_id === wallet.id)?.id,
|
|
190
|
+
wallet
|
|
191
|
+
)}
|
|
192
|
+
/>
|
|
193
|
+
<SectionLeftText>
|
|
194
|
+
<label
|
|
195
|
+
style={{
|
|
196
|
+
color: (balance === 0 && !walletsPaymethod?.find(walletPay => walletPay.wallet_id === wallet.id)?.id) ||
|
|
197
|
+
wallet.balance === 0 ? theme.colors.darkGray : 'black'
|
|
198
|
+
}}
|
|
199
|
+
htmlFor={`custom-checkbox-${idx}`}
|
|
200
|
+
>
|
|
201
|
+
{walletName[wallet.type]?.name}
|
|
202
|
+
</label>
|
|
203
|
+
</SectionLeftText>
|
|
204
|
+
</SectionLeft>
|
|
205
|
+
<div>
|
|
206
|
+
{wallet.type === 'cash' && (
|
|
207
|
+
<span>{parsePrice(wallet?.balance, { isTruncable: true })}</span>
|
|
208
|
+
)}
|
|
209
|
+
{wallet.type === 'credit_point' && (
|
|
210
|
+
<span>
|
|
211
|
+
<span style={{ color: theme.colors.primary }}>
|
|
212
|
+
{`${wallet?.balance} ${t('POINTS', 'Points')}`}
|
|
213
|
+
</span> {wallet?.balance > 0 && `= ${parsePrice(wallet?.balance / wallet?.redemption_rate, { isTruncable: true })}`}
|
|
214
|
+
</span>
|
|
215
|
+
)}
|
|
216
|
+
</div>
|
|
217
|
+
</WalletOptionContainer>
|
|
218
|
+
))}
|
|
210
219
|
</>
|
|
211
220
|
)}
|
|
212
221
|
</WalletPaymentOptionContainer>
|
|
213
222
|
)}
|
|
214
|
-
|
|
223
|
+
{/* Stripe direct, Google pay, Apple pay */}
|
|
224
|
+
<Modal
|
|
225
|
+
title={t('ADD_CARD', 'Add card')}
|
|
226
|
+
open={stripeDirectMethods?.includes(openPaymethod?.gateway) && !paymethodSelected?.paymethod_data?.id}
|
|
227
|
+
className='modal-info'
|
|
228
|
+
onClose={() => setOpenPaymethod(null)}
|
|
229
|
+
>
|
|
230
|
+
{!paymethodSelected?.data?.publishable &&
|
|
231
|
+
<Container>
|
|
232
|
+
<p>{t('ADD_PUBLISHABLE_KEY', 'Please add a publishable key')}</p>
|
|
233
|
+
</Container>}
|
|
234
|
+
{paymethodSelected?.data?.publishable && stripeDirectMethods?.includes(paymethodSelected?.paymethod?.gateway) && (
|
|
235
|
+
<StripeElementsForm
|
|
236
|
+
methodsPay={methodsPay}
|
|
237
|
+
paymethod={paymethodSelected?.paymethod?.gateway}
|
|
238
|
+
businessId={props.businessId}
|
|
239
|
+
cartGroup={cartGroup?.result}
|
|
240
|
+
publicKey={paymethodSelected?.data?.publishable || paymethodSelected?.data?.publishable_key}
|
|
241
|
+
handleSource={handlePaymethodDataChange}
|
|
242
|
+
onCancel={() => setOpenPaymethod(null)}
|
|
243
|
+
handlePlaceOrder={handlePlaceOrder}
|
|
244
|
+
/>
|
|
245
|
+
)}
|
|
246
|
+
</Modal>
|
|
215
247
|
</Container>
|
|
216
248
|
)
|
|
217
249
|
}
|
|
@@ -101,6 +101,11 @@ const MultiCheckoutUI = (props) => {
|
|
|
101
101
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
102
102
|
: configs?.driver_tip_options?.value || []
|
|
103
103
|
|
|
104
|
+
const methodsPay = ['global_google_pay', 'global_apple_pay']
|
|
105
|
+
const creditPointPlan = loyaltyPlansState?.result?.find((loyal) => loyal.type === 'credit_point')
|
|
106
|
+
const businessIds = openCarts.map((cart) => cart.business_id)
|
|
107
|
+
const loyalBusinessIds = creditPointPlan?.businesses?.filter((b) => b.accumulates).map((item) => item.business_id) ?? []
|
|
108
|
+
const creditPointPlanOnBusiness = businessIds.every((bid) => loyalBusinessIds.includes(bid)) && creditPointPlan
|
|
104
109
|
const creditPointGeneralPlan = loyaltyPlansState?.result?.find((loyal) => loyal.type === 'credit_point')
|
|
105
110
|
const loyalBusinessAvailable = creditPointGeneralPlan?.businesses?.filter((b) => b.accumulates) ?? []
|
|
106
111
|
|
|
@@ -209,6 +214,15 @@ const MultiCheckoutUI = (props) => {
|
|
|
209
214
|
}
|
|
210
215
|
}, [walletState.error])
|
|
211
216
|
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
if (methodsPay.includes(paymethodSelected?.paymethod?.gateway) && typeof paymethodSelected?.paymethod_data === 'string') {
|
|
219
|
+
const hasSource = JSON.parse(paymethodSelected?.paymethod_data)?.source_id
|
|
220
|
+
if (hasSource) {
|
|
221
|
+
handlePlaceOrder()
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}, [paymethodSelected])
|
|
225
|
+
|
|
212
226
|
return (
|
|
213
227
|
<>
|
|
214
228
|
{((!cartGroup?.loading && openCarts.length === 0) || !cartUuid) ? (
|
|
@@ -260,7 +274,9 @@ const MultiCheckoutUI = (props) => {
|
|
|
260
274
|
handlePaymethodDataChange={handlePaymethodDataChange}
|
|
261
275
|
cartUuid={cartUuid}
|
|
262
276
|
isCustomerMode={isCustomerMode}
|
|
277
|
+
cartGroup={cartGroup}
|
|
263
278
|
setCardList={setCardList}
|
|
279
|
+
handlePlaceOrder={handlePlaceOrder}
|
|
264
280
|
/>
|
|
265
281
|
</PaymentMethodContainer>
|
|
266
282
|
|
|
@@ -38,9 +38,11 @@ export const OrderEta = (props) => {
|
|
|
38
38
|
}
|
|
39
39
|
_estimatedTime = moment.utc(_delivery).add(totalEta, 'minutes')
|
|
40
40
|
} else {
|
|
41
|
-
|
|
41
|
+
const _etaTime = order?.delivered_in
|
|
42
|
+
? order?.delivered_in + order?.eta_time
|
|
43
|
+
: order?.eta_time
|
|
44
|
+
_estimatedTime = moment.utc(_delivery).add(_etaTime, 'minutes')
|
|
42
45
|
}
|
|
43
|
-
if (order?.delivered_in) { _estimatedTime = moment.utc(_delivery).add(order?.delivered_in, 'minutes')}
|
|
44
46
|
_estimatedTime = outputFormat ? moment(_estimatedTime).local().format(outputFormat) : parseDate(_estimatedTime, { utc: false })
|
|
45
47
|
setEstimatedDeliveryTime(_estimatedTime)
|
|
46
48
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
useLanguage,
|
|
4
4
|
useUtils,
|
|
5
5
|
useEvent,
|
|
6
|
+
useConfig,
|
|
6
7
|
OrderList as OrderListController
|
|
7
8
|
} from 'ordering-components-external'
|
|
8
9
|
import { Button } from '../../styles/Buttons'
|
|
@@ -31,11 +32,12 @@ const OrderProgressUI = (props) => {
|
|
|
31
32
|
isCustomerMode
|
|
32
33
|
} = props
|
|
33
34
|
const [, t] = useLanguage()
|
|
34
|
-
const [{ optimizeImage, parseTime }] = useUtils()
|
|
35
|
+
const [{ optimizeImage, parseTime, parseDate }] = useUtils()
|
|
36
|
+
const [{ configs }] = useConfig()
|
|
35
37
|
const theme = useTheme()
|
|
36
38
|
const [events] = useEvent()
|
|
37
39
|
const [lastOrder, setLastOrder] = useState(null)
|
|
38
|
-
const statusToShow = [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21]
|
|
40
|
+
const statusToShow = [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21, 22, 23]
|
|
39
41
|
|
|
40
42
|
const isChew = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
|
|
41
43
|
|
|
@@ -110,7 +112,11 @@ const OrderProgressUI = (props) => {
|
|
|
110
112
|
? parseTime(lastOrder?.delivery_datetime_utc, { outputFormat: 'hh:mm A', utc: false })
|
|
111
113
|
: parseTime(lastOrder?.delivery_datetime, { utc: false })}
|
|
112
114
|
-
|
|
113
|
-
|
|
115
|
+
{statusToShow.includes(lastOrder?.status) ? (
|
|
116
|
+
<OrderEta order={lastOrder} outputFormat={configs?.general_hour_format?.value || 'HH:mm'} />
|
|
117
|
+
) : (
|
|
118
|
+
parseDate(lastOrder?.reporting_data?.at[`status:${lastOrder.status}`], { outputFormat: configs?.general_hour_format?.value })
|
|
119
|
+
)}
|
|
114
120
|
</span>
|
|
115
121
|
</TimeWrapper>
|
|
116
122
|
</ProgressTextWrapper>
|
|
@@ -112,10 +112,13 @@ const PaymentOptionsUI = (props) => {
|
|
|
112
112
|
|
|
113
113
|
const includeKioskPaymethods = ['cash', 'card_delivery']
|
|
114
114
|
|
|
115
|
+
const multiCheckoutMethods = ['global_google_pay', 'global_apple_pay']
|
|
116
|
+
|
|
115
117
|
const list = paymethodsList ? paymethodsList?.paymethods : paymethods?.map(pay => pay.paymethod)
|
|
116
118
|
|
|
117
119
|
const popupMethods = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal', 'square', 'google_pay', 'apple_pay']
|
|
118
|
-
|
|
120
|
+
|
|
121
|
+
const supportedMethods = list?.filter(p => !multiCheckoutMethods.includes(p.gateway))?.filter(p => useKioskApp ? includeKioskPaymethods.includes(p.gateway) : p)
|
|
119
122
|
|
|
120
123
|
const handlePaymentMethodClick = (paymethod) => {
|
|
121
124
|
if (paymethod?.gateway === 'paypal' &&
|
|
@@ -176,7 +179,7 @@ const PaymentOptionsUI = (props) => {
|
|
|
176
179
|
if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
|
|
177
180
|
handlePlaceOrder()
|
|
178
181
|
}
|
|
179
|
-
}, [paymethodData, paymethodSelected])
|
|
182
|
+
}, [JSON.stringify(paymethodData), paymethodSelected])
|
|
180
183
|
|
|
181
184
|
return (
|
|
182
185
|
<>
|
|
@@ -193,10 +196,10 @@ const PaymentOptionsUI = (props) => {
|
|
|
193
196
|
supportedMethods.sort((a, b) => a.id - b.id).map(paymethod => (
|
|
194
197
|
<React.Fragment key={paymethod.id}>
|
|
195
198
|
{
|
|
196
|
-
(!isCustomerMode || (isCustomerMode && (paymethod.gateway === 'card_delivery' || paymethod.gateway === 'cash'))) && (
|
|
199
|
+
((!isCustomerMode && paymethod.gateway) || (isCustomerMode && (paymethod.gateway === 'card_delivery' || paymethod.gateway === 'cash'))) && (
|
|
197
200
|
<PayCard
|
|
198
201
|
isDisabled={isDisabled}
|
|
199
|
-
className={
|
|
202
|
+
className={`${(paymethodSelected?.id || isOpenMethod?.paymethod?.id) === paymethod.id ? 'active' : ''}`}
|
|
200
203
|
onClick={() => handlePaymentMethodClick(paymethod)}
|
|
201
204
|
>
|
|
202
205
|
<div>
|
|
@@ -22,7 +22,8 @@ const StripeElementsFormUI = (props) => {
|
|
|
22
22
|
paymethod,
|
|
23
23
|
cart,
|
|
24
24
|
handlePlaceOrder,
|
|
25
|
-
methodsPay
|
|
25
|
+
methodsPay,
|
|
26
|
+
cartGroup
|
|
26
27
|
} = props
|
|
27
28
|
const [, t] = useLanguage()
|
|
28
29
|
return (
|
|
@@ -38,6 +39,7 @@ const StripeElementsFormUI = (props) => {
|
|
|
38
39
|
{methodsPay?.includes(paymethod) ? (
|
|
39
40
|
<StripeMethodForm
|
|
40
41
|
cart={cart}
|
|
42
|
+
cartGroup={cartGroup}
|
|
41
43
|
handleSource={handleSource}
|
|
42
44
|
onNewCard={onNewCard}
|
|
43
45
|
toSave={toSave}
|
/package/_bundles/{1.ordering-ui.5657c6a53b3791887fd7.js → 1.ordering-ui.cf22ed960e0a8685bf74.js}
RENAMED
|
File without changes
|
/package/_bundles/{2.ordering-ui.5657c6a53b3791887fd7.js → 2.ordering-ui.cf22ed960e0a8685bf74.js}
RENAMED
|
File without changes
|
/package/_bundles/{4.ordering-ui.5657c6a53b3791887fd7.js → 4.ordering-ui.cf22ed960e0a8685bf74.js}
RENAMED
|
File without changes
|
/package/_bundles/{6.ordering-ui.5657c6a53b3791887fd7.js → 6.ordering-ui.cf22ed960e0a8685bf74.js}
RENAMED
|
File without changes
|
|
File without changes
|
/package/_bundles/{8.ordering-ui.5657c6a53b3791887fd7.js → 8.ordering-ui.cf22ed960e0a8685bf74.js}
RENAMED
|
File without changes
|
/package/_bundles/{9.ordering-ui.5657c6a53b3791887fd7.js → 9.ordering-ui.cf22ed960e0a8685bf74.js}
RENAMED
|
File without changes
|