ordering-ui-external 10.4.0 → 10.5.0

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.
Files changed (80) hide show
  1. package/_bundles/{0.ordering-ui.487a31b3537d90f69a9d.js → 0.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  2. package/_bundles/{1.ordering-ui.487a31b3537d90f69a9d.js → 1.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  3. package/_bundles/{2.ordering-ui.487a31b3537d90f69a9d.js → 2.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  4. package/_bundles/{4.ordering-ui.487a31b3537d90f69a9d.js → 4.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  5. package/_bundles/{5.ordering-ui.487a31b3537d90f69a9d.js → 5.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  6. package/_bundles/{6.ordering-ui.487a31b3537d90f69a9d.js → 6.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  7. package/_bundles/{7.ordering-ui.487a31b3537d90f69a9d.js → 7.ordering-ui.cc1d13aa04732fde3671.js} +2 -2
  8. package/_bundles/{8.ordering-ui.487a31b3537d90f69a9d.js → 8.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  9. package/_bundles/{9.ordering-ui.487a31b3537d90f69a9d.js → 9.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  10. package/_bundles/ordering-ui.cc1d13aa04732fde3671.js +2 -0
  11. package/_modules/themes/callcenterOriginal/src/components/Orders/DeliveriesManager/index.js +4 -2
  12. package/_modules/themes/callcenterOriginal/src/components/Orders/OrdersDashboardControls/index.js +3 -1
  13. package/_modules/themes/callcenterOriginal/src/components/Orders/OrdersManager/index.js +2 -0
  14. package/_modules/themes/five/src/components/BusinessItemAccordion/index.js +5 -2
  15. package/_modules/themes/five/src/components/BusinessItemAccordion/styles.js +25 -19
  16. package/_modules/themes/five/src/components/BusinessProductsList/index.js +35 -13
  17. package/_modules/themes/five/src/components/BusinessProductsList/styles.js +7 -3
  18. package/_modules/themes/five/src/components/BusinessProductsListing/index.js +2 -0
  19. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +133 -31
  20. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +37 -3
  21. package/_modules/themes/five/src/components/Cart/index.js +10 -6
  22. package/_modules/themes/five/src/components/Checkout/index.js +67 -22
  23. package/_modules/themes/five/src/components/GiftCard/GiftCardOrdersList/index.js +53 -0
  24. package/_modules/themes/five/src/components/GiftCard/GiftCardOrdersList/styles.js +16 -0
  25. package/_modules/themes/five/src/components/GiftCard/HorizontalGiftCardOrdersLayout/index.js +69 -0
  26. package/_modules/themes/five/src/components/GiftCard/HorizontalGiftCardOrdersLayout/styles.js +16 -0
  27. package/_modules/themes/five/src/components/GiftCard/SingleGiftCard/index.js +90 -0
  28. package/_modules/themes/five/src/components/GiftCard/SingleGiftCard/styles.js +43 -0
  29. package/_modules/themes/five/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.js +75 -0
  30. package/_modules/themes/five/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.js +19 -0
  31. package/_modules/themes/five/src/components/MyOrders/index.js +6 -1
  32. package/_modules/themes/five/src/components/OrderProgress/index.js +1 -1
  33. package/_modules/themes/five/src/components/OrdersOption/index.js +1 -0
  34. package/_modules/themes/five/src/components/PhoneAutocomplete/index.js +165 -31
  35. package/_modules/themes/five/src/components/PhoneAutocomplete/styles.js +53 -9
  36. package/_modules/themes/five/src/components/ProductForm/index.js +1 -0
  37. package/_modules/themes/five/src/components/RenderProductsLayout/index.js +3 -2
  38. package/_modules/themes/five/src/components/SingleProductCard/layouts/original/styles.js +1 -1
  39. package/_modules/themes/five/src/components/UserFormDetails/index.js +5 -17
  40. package/_modules/themes/five/src/components/UserFormDetails/styles.js +3 -7
  41. package/index-template.js +9 -1
  42. package/package.json +2 -2
  43. package/src/themes/callcenterOriginal/src/components/Orders/DeliveriesManager/index.js +3 -1
  44. package/src/themes/callcenterOriginal/src/components/Orders/OrdersDashboardControls/index.js +5 -1
  45. package/src/themes/callcenterOriginal/src/components/Orders/OrdersManager/index.js +2 -0
  46. package/src/themes/five/src/components/BusinessItemAccordion/index.js +2 -2
  47. package/src/themes/five/src/components/BusinessItemAccordion/styles.js +8 -7
  48. package/src/themes/five/src/components/BusinessProductsList/index.js +36 -3
  49. package/src/themes/five/src/components/BusinessProductsList/styles.js +20 -0
  50. package/src/themes/five/src/components/BusinessProductsListing/index.js +2 -0
  51. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +156 -36
  52. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +66 -0
  53. package/src/themes/five/src/components/Cart/index.js +7 -4
  54. package/src/themes/five/src/components/Checkout/index.js +61 -35
  55. package/src/themes/five/src/components/GiftCard/GiftCardOrdersList/index.js +50 -0
  56. package/src/themes/five/src/components/GiftCard/GiftCardOrdersList/styles.js +34 -0
  57. package/src/themes/five/src/components/GiftCard/HorizontalGiftCardOrdersLayout/index.js +75 -0
  58. package/src/themes/five/src/components/GiftCard/HorizontalGiftCardOrdersLayout/styles.js +29 -0
  59. package/src/themes/five/src/components/GiftCard/SingleGiftCard/index.js +79 -0
  60. package/src/themes/five/src/components/GiftCard/SingleGiftCard/styles.js +79 -0
  61. package/src/themes/five/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.js +72 -0
  62. package/src/themes/five/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.js +31 -0
  63. package/src/themes/five/src/components/MyOrders/index.js +6 -1
  64. package/src/themes/five/src/components/OrderProgress/index.js +1 -1
  65. package/src/themes/five/src/components/OrdersOption/index.js +1 -0
  66. package/src/themes/five/src/components/PhoneAutocomplete/index.js +195 -46
  67. package/src/themes/five/src/components/PhoneAutocomplete/styles.js +106 -10
  68. package/src/themes/five/src/components/ProductForm/index.js +1 -0
  69. package/src/themes/five/src/components/RenderProductsLayout/index.js +1 -0
  70. package/src/themes/five/src/components/SingleProductCard/layouts/original/styles.js +1 -1
  71. package/src/themes/five/src/components/UserFormDetails/index.js +6 -27
  72. package/src/themes/five/src/components/UserFormDetails/styles.js +0 -16
  73. package/template/assets/images/delivery.svg +11 -0
  74. package/template/assets/images/phone-hero-callcenter.png +0 -0
  75. package/template/assets/images/phone.svg +11 -0
  76. package/template/assets/images/pickup.svg +17 -0
  77. package/template/pages/BusinessProductsList/index.js +2 -1
  78. package/_bundles/ordering-ui.487a31b3537d90f69a9d.js +0 -2
  79. /package/_bundles/{7.ordering-ui.487a31b3537d90f69a9d.js.LICENSE.txt → 7.ordering-ui.cc1d13aa04732fde3671.js.LICENSE.txt} +0 -0
  80. /package/_bundles/{ordering-ui.487a31b3537d90f69a9d.js.LICENSE.txt → ordering-ui.cc1d13aa04732fde3671.js.LICENSE.txt} +0 -0
@@ -202,3 +202,69 @@ export const AddressFormWrapper = styled.div`
202
202
  margin-top: 20px;
203
203
  }
204
204
  `
205
+
206
+ export const IconTypeButton = styled.div`
207
+ display: flex;
208
+ justify-content: center;
209
+ align-items: center;
210
+ width: 44px;
211
+ height: 44px;
212
+ background: ${({ activated, theme }) => activated ? theme?.colors?.white : '#F3F9FF'};
213
+ border-radius: 44px;
214
+ `
215
+
216
+ export const TypesContainer = styled.div`
217
+ display: flex;
218
+ margin: 42px 20px 0px 20px;
219
+ `
220
+
221
+ export const AdditionalTypesContainer = styled.div`
222
+ width: 60%;
223
+ display: flex;
224
+ margin-bottom: 20px;
225
+ margin-left: 20px;
226
+ button {
227
+ padding: 4px 10px;
228
+ border-radius: 50px;
229
+ font-size: 10px;
230
+ line-height: 0;
231
+ height: 25px;
232
+ margin-right: 20px;
233
+ }
234
+ .activated {
235
+ color: ${({ theme }) => theme?.colors?.darkTextColor}
236
+ }
237
+ `
238
+
239
+ export const TypeButton = styled.div`
240
+ display: flex;
241
+ align-items: center;
242
+ width: 215px;
243
+ height: 75px;
244
+ border-radius: 7.6px;
245
+ padding: 16px;
246
+ box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.10);
247
+ margin-right: 32px;
248
+ margin-bottom: 32px;
249
+ cursor: pointer;
250
+ background: ${({ activated, theme }) => activated ? theme?.colors?.primary : theme?.colors?.white};
251
+ p{
252
+ margin: 0;
253
+ margin-left: 33px;
254
+ ${({ activated, theme }) => activated && css`
255
+ color: ${theme?.colors?.white};
256
+ `}
257
+ }
258
+ `
259
+
260
+ export const Title = styled.h2`
261
+ font-weight: 600;
262
+ font-size: 24px;
263
+ color: ${props => props.theme?.colors.headingColor};
264
+ margin: 0px 20px 5px 20px;
265
+ `
266
+
267
+ export const TypesWrapper = styled.div`
268
+ margin-left: 20px;
269
+ width: 600px;
270
+ `
@@ -8,6 +8,7 @@ import {
8
8
  useValidationFields,
9
9
  useConfig,
10
10
  useSite,
11
+ useSession,
11
12
  useCustomer
12
13
  } from 'ordering-components-external'
13
14
  import { Button } from '../../styles/Buttons'
@@ -73,13 +74,16 @@ const CartUI = (props) => {
73
74
  hideCouponInput,
74
75
  businessConfigs,
75
76
  loyaltyRewardRate,
76
- isCustomerMode
77
+ isCustomerMode,
78
+ guestCheckoutComment,
79
+ guestCheckoutCupon
77
80
  } = props
78
81
 
79
82
  const theme = useTheme()
80
83
  const [, t] = useLanguage()
81
84
  const [orderState] = useOrder()
82
85
  const [events] = useEvent()
86
+ const [{ user: loginUser }] = useSession()
83
87
  const [{ parsePrice, parseNumber, parseDate }] = useUtils()
84
88
  const [validationFields] = useValidationFields()
85
89
  const [{ configs }] = useConfig()
@@ -107,8 +111,8 @@ const CartUI = (props) => {
107
111
  const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
108
112
  const cart = cartMulticart || orderState?.carts?.[`businessId:${props.cart?.business_id}`]
109
113
  const viewString = isStore ? 'business_view' : 'header'
110
- const hideCartComments = theme?.[viewString]?.components?.cart?.components?.comments?.hidden || !validationFields?.fields?.checkout?.comments?.enabled
111
- const hideCartDiscount = theme?.[viewString]?.components?.cart?.components?.discount_coupon?.hidden
114
+ const hideCartComments = theme?.[viewString]?.components?.cart?.components?.comments?.hidden || ((loginUser?.guest_id && guestCheckoutComment) ? !guestCheckoutComment?.enabled : !validationFields?.fields?.checkout?.comments?.enabled)
115
+ const hideCartDiscount = theme?.[viewString]?.components?.cart?.components?.discount_coupon?.hidden || ((loginUser?.guest_id && guestCheckoutCupon) ? !guestCheckoutCupon?.enabled : !validationFields?.fields?.checkout?.comments?.enabled)
112
116
  const cateringTypeString = orderState?.options?.type === 7
113
117
  ? 'catering_delivery'
114
118
  : orderState?.options?.type === 8
@@ -142,7 +146,6 @@ const CartUI = (props) => {
142
146
  }
143
147
  return acc = acc
144
148
  }, cart?.subtotal)
145
- console.log('cart', cart)
146
149
  const clearAmount = (value) => parseFloat((Math.trunc(value * 100) / 100).toFixed(configs.format_number_decimal_length?.value ?? 2))
147
150
  const loyaltyRewardValue = clearAmount((cart?.subtotal + getIncludedTaxes()) * loyaltyRewardRate)
148
151
 
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react'
1
+ import React, { useEffect, useMemo, useState } from 'react'
2
2
  import VscWarning from '@meronex/icons/vsc/VscWarning'
3
3
  import Skeleton from 'react-loading-skeleton'
4
4
  import { useTheme } from 'styled-components'
@@ -99,7 +99,8 @@ const CheckoutUI = (props) => {
99
99
  handleStoreRedirect,
100
100
  onPlaceOrderClick,
101
101
  setPlaceSpotNumber,
102
- placeSpotNumber
102
+ placeSpotNumber,
103
+ checkoutFieldsState
103
104
  } = props
104
105
 
105
106
  const theme = useTheme()
@@ -136,13 +137,18 @@ const CheckoutUI = (props) => {
136
137
  const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' &&
137
138
  (isWalletCashEnabled || isWalletCreditPointsEnabled) && !useKioskApp && !isCustomerMode
138
139
  const isMultiDriverTips = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
140
+ const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
139
141
 
140
142
  const placeSpotTypes = [3, 4, 5]
141
143
  const placeSpotsEnabled = placeSpotTypes.includes(options?.type) && !useKioskApp
142
144
  const isGiftCardCart = !cart?.business_id
145
+ const guestCheckoutDriveTip = checkoutFieldsState?.fields?.find(field => field.order_type_id === 1 && field?.validation_field?.code === 'driver_tip')
146
+ const guestCheckoutComment = useMemo(() => checkoutFieldsState?.fields?.find(field => field.order_type_id === options?.type && field?.validation_field?.code === 'comments'), [checkoutFieldsState, options])
147
+ const guestCheckoutCupon = useMemo(() => checkoutFieldsState?.fields?.find(field => field.order_type_id === options?.type && field?.validation_field?.code === 'coupon'), [checkoutFieldsState, options])
143
148
  // const [hasBusinessPlaces, setHasBusinessPlaces] = useState(null)
144
149
 
145
- const validateCommentsCartField = validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required && (cart?.comment === null || cart?.comment?.trim().length === 0)
150
+ const validateCommentsCartField = (!user?.guest_id ? (validationFields?.fields?.checkout?.comments?.enabled && validationFields?.fields?.checkout?.comments?.required) : (guestCheckoutComment?.enabled && guestCheckoutComment?.required)) && (cart?.comment === null || cart?.comment?.trim().length === 0)
151
+ const validateDriverTipField = options.type === 1 && (!user?.guest_id ? (validationFields?.fields?.checkout?.driver_tip?.enabled && validationFields?.fields?.checkout?.driver_tip?.required) : (guestCheckoutDriveTip?.enabled && guestCheckoutDriveTip?.required)) && (Number(cart?.driver_tip) <= 0)
146
152
 
147
153
  const validateZipcodeCard =
148
154
  validationFields?.fields?.card?.zipcode?.enabled && validationFields?.fields?.card?.zipcode?.required && paymethodSelected?.gateway === 'stripe' && paymethodSelected?.data?.card && !paymethodSelected?.data?.card?.zipcode
@@ -157,10 +163,7 @@ const CheckoutUI = (props) => {
157
163
  !cart?.valid_maximum ||
158
164
  (!cart?.valid_minimum && !(cart?.discount_type === 1 && cart?.discount_rate === 100)) ||
159
165
  // (((placeSpotTypes.includes(options?.type) && !cart?.place) && hasBusinessPlaces)) ||
160
- (options.type === 1 &&
161
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
162
- validationFields?.fields?.checkout?.driver_tip?.required &&
163
- (Number(cart?.driver_tip) <= 0)) ||
166
+ (validateDriverTipField && !isGiftCardCart) ||
164
167
  (validateCommentsCartField) ||
165
168
  validateZipcodeCard
166
169
 
@@ -178,7 +181,7 @@ const CheckoutUI = (props) => {
178
181
  const hideBusinessDetails = theme?.checkout?.components?.business?.hidden
179
182
  const hideBusinessMap = theme?.checkout?.components?.map?.hidden
180
183
  const hideCustomerDetails = theme?.checkout?.components?.customer?.hidden
181
- const driverTipsField = !cartState.loading && cart && cart?.business_id && options.type === 1 && cart?.status !== 2 && validationFields?.fields?.checkout?.driver_tip?.enabled && driverTipsOptions.length > 0 && !useKioskApp
184
+ const driverTipsField = !cartState.loading && cart && cart?.business_id && options.type === 1 && cart?.status !== 2 && ((!user?.guest_id && validationFields?.fields?.checkout?.driver_tip?.enabled) || (user?.guest_id && guestCheckoutDriveTip?.enabled)) && driverTipsOptions.length > 0 && !useKioskApp
182
185
 
183
186
  const creditPointPlan = loyaltyPlansState?.result?.find(loyal => loyal.type === 'credit_point')
184
187
  const creditPointPlanOnBusiness = creditPointPlan?.businesses?.find(b => b.business_id === cart?.business_id && b.accumulates)
@@ -190,8 +193,7 @@ const CheckoutUI = (props) => {
190
193
  return
191
194
  }
192
195
 
193
- if (!userErrors.length && (!requiredFields?.length ||
194
- (allowedGuest && (paymethodSelected?.gateway === 'cash' || paymethodSelected?.gateway === 'card_delivery')))) {
196
+ if (!userErrors.length && !requiredFields?.length) {
195
197
  const body = {}
196
198
  if (behalfName) {
197
199
  body.on_behalf_of = behalfName
@@ -227,10 +229,30 @@ const CheckoutUI = (props) => {
227
229
  setIsUserDetailsEdit(false)
228
230
  }
229
231
 
232
+ const checkGuestValidationFields = () => {
233
+ const userSelected = isCustomerMode ? customerState.user : user
234
+ const _requiredFields = checkoutFieldsState?.fields
235
+ .filter(field => (field?.order_type_id === options?.type) && field?.enabled && field?.required &&
236
+ !notFields.includes(field?.validation_field?.code) &&
237
+ userSelected && !userSelected[field?.validation_field?.code])
238
+ .map(item => item?.validation_field?.code)
239
+ const guestCheckoutCellPhone = checkoutFieldsState?.fields?.find(field => field.order_type_id === options?.type && field?.validation_field?.code === 'mobile_phone')
240
+
241
+ if (
242
+ userSelected &&
243
+ !userSelected?.cellphone &&
244
+ ((guestCheckoutCellPhone?.enabled &&
245
+ guestCheckoutCellPhone?.required) ||
246
+ configs?.verification_phone_required?.value === '1')
247
+ ) {
248
+ _requiredFields.push('cellphone')
249
+ }
250
+ setRequiredFields(_requiredFields)
251
+ }
252
+
230
253
  const checkValidationFields = () => {
231
254
  setUserErrors([])
232
255
  const errors = []
233
- const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes', 'comments']
234
256
  const userSelected = isCustomerMode ? customerState.user : user
235
257
  const _requiredFields = []
236
258
 
@@ -294,6 +316,11 @@ const CheckoutUI = (props) => {
294
316
  }
295
317
  }, [validationFields, user, customerState])
296
318
 
319
+ useEffect(() => {
320
+ if (checkoutFieldsState?.loading || !user?.guest_id || customerState.loading || userLoading) return
321
+ checkGuestValidationFields()
322
+ }, [user, checkoutFieldsState, customerState])
323
+
297
324
  useEffect(() => {
298
325
  if (errors) {
299
326
  setAlertState({
@@ -313,12 +340,12 @@ const CheckoutUI = (props) => {
313
340
 
314
341
  useEffect(() => {
315
342
  if (cart?.products?.length) return
316
- if (cart?.business?.slug) {
343
+ if (cart?.business_id !== null) {
317
344
  handleStoreRedirect(cart?.business?.slug)
318
345
  } else {
319
346
  events.emit('go_to_page', { page: 'wallets' })
320
347
  }
321
- }, [cart?.products])
348
+ }, [JSON.stringify(cart?.products)])
322
349
 
323
350
  useEffect(() => {
324
351
  window.scrollTo(0, 0)
@@ -542,24 +569,24 @@ const CheckoutUI = (props) => {
542
569
 
543
570
  {
544
571
  !!(!isMultiDriverTips && driverTipsField) &&
545
- <>
546
- <DriverTipContainer>
547
- <h1>{t('DRIVER_TIPS', 'Driver Tips')}</h1>
548
- <p>{t('100%_OF_THE_TIP_YOUR_DRIVER', '100% of the tip goes to your driver')}</p>
549
- <DriverTips
550
- businessId={cart?.business_id}
551
- driverTipsOptions={driverTipsOptions}
552
- isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
553
- isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
554
- driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
555
- ? cart?.driver_tip
556
- : cart?.driver_tip_rate}
557
- cart={cart}
558
- useOrderContext
559
- />
560
- </DriverTipContainer>
561
- <DriverTipDivider />
562
- </>
572
+ <>
573
+ <DriverTipContainer>
574
+ <h1>{t('DRIVER_TIPS', 'Driver Tips')}</h1>
575
+ <p>{t('100%_OF_THE_TIP_YOUR_DRIVER', '100% of the tip goes to your driver')}</p>
576
+ <DriverTips
577
+ businessId={cart?.business_id}
578
+ driverTipsOptions={driverTipsOptions}
579
+ isFixedPrice={parseInt(configs?.driver_tip_type?.value, 10) === 1}
580
+ isDriverTipUseCustom={!!parseInt(configs?.driver_tip_use_custom?.value, 10)}
581
+ driverTip={parseInt(configs?.driver_tip_type?.value, 10) === 1
582
+ ? cart?.driver_tip
583
+ : cart?.driver_tip_rate}
584
+ cart={cart}
585
+ useOrderContext
586
+ />
587
+ </DriverTipContainer>
588
+ <DriverTipDivider />
589
+ </>
563
590
  }
564
591
  {!cartState.loading && placeSpotsEnabled && cart?.business_id && (
565
592
  <SelectSpotContainer>
@@ -594,6 +621,8 @@ const CheckoutUI = (props) => {
594
621
  creditPointPlanOnBusiness?.accumulation_rate ??
595
622
  (!!creditPointPlanOnBusiness && creditPointPlan?.accumulation_rate) ?? 0
596
623
  }
624
+ guestCheckoutComment={guestCheckoutComment}
625
+ guestCheckoutCupon={guestCheckoutCupon}
597
626
  />
598
627
  </CartContainer>
599
628
  )}
@@ -658,10 +687,7 @@ const CheckoutUI = (props) => {
658
687
  </WarningText>
659
688
  )}
660
689
 
661
- {options.type === 1 &&
662
- validationFields?.fields?.checkout?.driver_tip?.enabled &&
663
- validationFields?.fields?.checkout?.driver_tip?.required &&
664
- (Number(cart?.driver_tip) <= 0) &&
690
+ {validateDriverTipField && !isGiftCardCart &&
665
691
  (
666
692
  <WarningText>
667
693
  {t('WARNING_INVALID_DRIVER_TIP', 'Driver Tip is required.')}
@@ -0,0 +1,50 @@
1
+ import React, { useState } from 'react'
2
+ import { useLanguage } from 'ordering-components-external'
3
+ import { HorizontalGiftCardOrdersLayout } from '../HorizontalGiftCardOrdersLayout'
4
+ import {
5
+ Container,
6
+ Divider,
7
+ NoOrdersWrapper
8
+ } from './styles'
9
+
10
+ export const GiftCardOrdersList = (props) => {
11
+ const [, t] = useLanguage()
12
+ const [isEmptyPending, setIsEmptyPending] = useState(false)
13
+ const [isEmptySent, setIsEmptySent] = useState(false)
14
+ const [isEmptyRedeemed, setIsEmptyRedeemed] = useState(false)
15
+
16
+ return (
17
+ <Container>
18
+ <HorizontalGiftCardOrdersLayout
19
+ title={t('PENDING', 'Pending')}
20
+ defaultStatus='pending'
21
+ setIsEmpty={setIsEmptyPending}
22
+ scrollId='pendingGifts'
23
+ />
24
+
25
+ {isEmptyPending && isEmptySent && isEmptyRedeemed && (
26
+ <Divider />
27
+ )}
28
+
29
+ <HorizontalGiftCardOrdersLayout
30
+ title={t('SENT', 'Sent')}
31
+ defaultStatus='sent'
32
+ setIsEmpty={setIsEmptySent}
33
+ scrollId='sentGifts'
34
+ />
35
+
36
+ <HorizontalGiftCardOrdersLayout
37
+ title={t('REDEEMED', 'Redeemed')}
38
+ defaultStatus='activated'
39
+ setIsEmpty={setIsEmptyRedeemed}
40
+ scrollId='redeemedgGifts'
41
+ />
42
+
43
+ {isEmptyPending && isEmptySent && isEmptyRedeemed && (
44
+ <NoOrdersWrapper>
45
+ <p>{t('YOU_DONT_HAVE_CARDS', 'You don\'t have cards')}</p>
46
+ </NoOrdersWrapper>
47
+ )}
48
+ </Container>
49
+ )
50
+ }
@@ -0,0 +1,34 @@
1
+ import styled from 'styled-components'
2
+
3
+ export const Container = styled.div`
4
+ h2 {
5
+ font-size: 24px;
6
+ font-weight: 600;
7
+ margin: 40px 0 20px 0;
8
+ }
9
+ `
10
+
11
+ export const Divider = styled.div`
12
+ margin-top: 25px;
13
+ background: #F8F9FA;
14
+ height: 8px;
15
+ width: 100%;
16
+ `
17
+ export const NoOrdersWrapper = styled.div`
18
+ display: flex;
19
+ flex-direction: column;
20
+ align-items: center;
21
+ justify-content: center;
22
+ padding: 50px 0px;
23
+ box-sizing: border-box;
24
+ min-height: calc(100% - 120px);
25
+ width: 100%;
26
+
27
+ > p {
28
+ font-weight: 500;
29
+ font-size: 16px;
30
+ line-height: 24px;
31
+ margin-top: 0px;
32
+ margin-bottom: 25px;
33
+ }
34
+ `
@@ -0,0 +1,75 @@
1
+ import React, { useEffect } from 'react'
2
+ import { GiftCardOrdersList as GiftCardOrdersListController } from 'ordering-components-external'
3
+ import Skeleton from 'react-loading-skeleton'
4
+ import { AutoScroll } from '../../AutoScroll'
5
+ import { SingleGiftCard } from '../SingleGiftCard'
6
+ import { Pagination } from '../../Pagination'
7
+ import {
8
+ ProductsListContainer,
9
+ ProductsList,
10
+ PaginationWrapper
11
+ } from './styles'
12
+
13
+ const HorizontalGiftCardOrdersLayoutUI = (props) => {
14
+ const {
15
+ giftCards,
16
+ paginationProps,
17
+ goToPage,
18
+ title,
19
+ setIsEmpty,
20
+ scrollId
21
+ } = props
22
+
23
+ useEffect(() => {
24
+ if (giftCards.loading) return
25
+ if (giftCards.list?.length === 0) setIsEmpty(true)
26
+ }, [giftCards])
27
+
28
+ return (
29
+ <>
30
+ {giftCards.loading
31
+ ? <Skeleton width={100} height={24} />
32
+ : giftCards.list?.length > 0 && <h2>{title}</h2>}
33
+ <ProductsListContainer>
34
+ <ProductsList>
35
+ <AutoScroll scrollId={scrollId}>
36
+ {giftCards.loading ? (
37
+ [...Array(10).keys()].map(i => (
38
+ <SingleGiftCard
39
+ isSkeleton
40
+ key={i}
41
+ />
42
+ ))
43
+ ) : (
44
+ <>
45
+ {giftCards.list.map(card => (
46
+ <SingleGiftCard
47
+ key={card.id}
48
+ card={card}
49
+ />
50
+ ))}
51
+ </>
52
+ )}
53
+ </AutoScroll>
54
+ </ProductsList>
55
+ </ProductsListContainer>
56
+ {giftCards.list?.length > 0 && Math.ceil(paginationProps?.totalPages) > 1 && (
57
+ <PaginationWrapper>
58
+ <Pagination
59
+ currentPage={paginationProps.currentPage}
60
+ totalPages={Math.ceil(paginationProps?.totalPages)}
61
+ handleChangePage={goToPage}
62
+ />
63
+ </PaginationWrapper>
64
+ )}
65
+ </>
66
+ )
67
+ }
68
+
69
+ export const HorizontalGiftCardOrdersLayout = (props) => {
70
+ const giftCardsProps = {
71
+ ...props,
72
+ UIComponent: HorizontalGiftCardOrdersLayoutUI
73
+ }
74
+ return <GiftCardOrdersListController {...giftCardsProps} />
75
+ }
@@ -0,0 +1,29 @@
1
+ import styled from 'styled-components'
2
+
3
+ export const ProductsListContainer = styled.div`
4
+ margin-top: 10px;
5
+ display: flex;
6
+ overflow: scroll hidden;
7
+ `
8
+
9
+ export const ProductsList = styled.div`
10
+ display: flex;
11
+ box-sizing: border-box;
12
+
13
+ .product-card {
14
+ width: 270px;
15
+ max-width: 270px;
16
+ margin: 10px;
17
+ border: 1px solid #E9ECEF;
18
+ }
19
+
20
+ @media(min-width: 480px){
21
+ .product-card {
22
+ width: 400px;
23
+ max-width: 400px;
24
+ }
25
+ }
26
+ `
27
+ export const PaginationWrapper = styled.div`
28
+ margin: 20px 0;
29
+ `
@@ -0,0 +1,79 @@
1
+ import React from 'react'
2
+ import { useLanguage, useUtils, useEvent } from 'ordering-components-external'
3
+ import Skeleton from 'react-loading-skeleton'
4
+ import { useTheme } from 'styled-components'
5
+ import BsDot from '@meronex/icons/bs/BsDot'
6
+
7
+ import {
8
+ CardContainer,
9
+ CardLogo,
10
+ CardInfo
11
+ } from './styles'
12
+
13
+ export const SingleGiftCard = (props) => {
14
+ const {
15
+ card,
16
+ isSkeleton
17
+ } = props
18
+
19
+ const theme = useTheme()
20
+ const [, t] = useLanguage()
21
+ const [events] = useEvent()
22
+ const [{ parsePrice, optimizeImage, parseDate }] = useUtils()
23
+
24
+ const getGiftCardStatus = (status) => {
25
+ switch (status) {
26
+ case 'pending':
27
+ return t('PENDING', 'Pending')
28
+ case 'activated':
29
+ return t('REDEEMED')
30
+ default:
31
+ return status
32
+ }
33
+ }
34
+
35
+ const handleClickGiftCardOrder = (card) => {
36
+ events.emit('go_to_page', { page: 'order_detail', params: { orderId: card.order_product?.order_id } })
37
+ }
38
+
39
+ return (
40
+ <CardContainer
41
+ className='product-card'
42
+ onClick={() => handleClickGiftCardOrder(card)}
43
+ >
44
+ {isSkeleton ? (
45
+ <Skeleton height={86} width={86} />
46
+ ) : (
47
+ <CardLogo
48
+ bgimage={optimizeImage(card?.order_product?.images || theme?.images?.dummies?.product, 'h_86,c_limit')}
49
+ />
50
+ )}
51
+ <CardInfo>
52
+ <div>
53
+ {isSkeleton ? (
54
+ <Skeleton height={16} width={100} />
55
+ ) : (
56
+ <span className='name'>{card?.order_product?.name}</span>
57
+ )}
58
+ {isSkeleton ? (
59
+ <Skeleton height={16} width={80} />
60
+ ) : (
61
+ <span>{parsePrice(card?.order_product?.price)}</span>
62
+ )}
63
+ </div>
64
+ {isSkeleton ? (
65
+ <p className='date'><Skeleton width={150} height={14} /></p>
66
+ ) : (
67
+ <p className='date'>
68
+ {t('ORDER_NUM', 'Order No.')} {card?.order_product?.order_id}<BsDot />{parseDate(card?.created_at)}
69
+ </p>
70
+ )}
71
+ {isSkeleton ? (
72
+ <p className='status'><Skeleton width={80} height={14} /></p>
73
+ ) : (
74
+ <p className='status'>{getGiftCardStatus(card?.status)}</p>
75
+ )}
76
+ </CardInfo>
77
+ </CardContainer>
78
+ )
79
+ }
@@ -0,0 +1,79 @@
1
+ import React from 'react'
2
+ import styled, { css } from 'styled-components'
3
+
4
+ export const CardContainer = styled.div`
5
+ background: ${props => props.theme.colors?.backgroundPage};
6
+ display: flex;
7
+ cursor: pointer;
8
+ padding: 10px;
9
+ border-radius: 7.6px;
10
+
11
+ &:hover {
12
+ box-shadow: rgb(0 0 0 / 20%) 0px 8px 24px;
13
+ }
14
+ `
15
+ const CardLogoStyled = styled.div`
16
+ box-sizing: border-box;
17
+ position: relative;
18
+ background-repeat: no-repeat, repeat;
19
+ background-size: cover;
20
+ background-position: center;
21
+ object-fit: cover;
22
+ height: 86px;
23
+ width: 86px;
24
+ min-width: 86px;
25
+ min-height: 86px;
26
+ border-radius: 8px;
27
+ box-shadow: 0px 1px 4px rgba(0,0,0,0.1);
28
+ `
29
+ export const CardLogo = (props) => {
30
+ const style = {}
31
+ if (props.bgimage) {
32
+ style.backgroundImage = `url(${props.bgimage})`
33
+ }
34
+ if (props.soldOut) {
35
+ style.filter = 'brightness(70%)'
36
+ }
37
+ return (
38
+ <CardLogoStyled {...props} style={style}>
39
+ {props.children}
40
+ </CardLogoStyled>
41
+ )
42
+ }
43
+
44
+ export const CardInfo = styled.div`
45
+ ${props => props.theme?.rtl ? css`
46
+ margin-right: 15px;
47
+ ` : css`
48
+ margin-left: 15px;
49
+ `}
50
+
51
+ flex: 1;
52
+ > div {
53
+ display: flex;
54
+ align-items: center;
55
+ justify-content: space-between;
56
+ font-size: 16px;
57
+ font-weight: 600;
58
+ span.name {
59
+ overflow: hidden;
60
+ text-overflow: ellipsis;
61
+ white-space: nowrap;
62
+ }
63
+ }
64
+
65
+ p.date {
66
+ font-size: 14px;
67
+ color: ${props => props.theme.colors.darkGray};
68
+ margin: 7px 0;
69
+ line-height: 24px;
70
+ display: flex;
71
+ align-items: center;
72
+ }
73
+ p.status {
74
+ font-size: 14px;
75
+ line-height: 24px;
76
+ color: ${props => props.theme.colors.primary};
77
+ margin: 0;
78
+ }
79
+ `