ordering-ui-external 10.4.1 → 10.5.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.
Files changed (75) hide show
  1. package/_bundles/{0.ordering-ui.62d46eec3c210c5257aa.js → 0.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  2. package/_bundles/{1.ordering-ui.62d46eec3c210c5257aa.js → 1.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  3. package/_bundles/{2.ordering-ui.62d46eec3c210c5257aa.js → 2.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  4. package/_bundles/{4.ordering-ui.62d46eec3c210c5257aa.js → 4.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  5. package/_bundles/{5.ordering-ui.62d46eec3c210c5257aa.js → 5.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  6. package/_bundles/{6.ordering-ui.62d46eec3c210c5257aa.js → 6.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  7. package/_bundles/{7.ordering-ui.62d46eec3c210c5257aa.js → 7.ordering-ui.cc1d13aa04732fde3671.js} +2 -2
  8. package/_bundles/{8.ordering-ui.62d46eec3c210c5257aa.js → 8.ordering-ui.cc1d13aa04732fde3671.js} +1 -1
  9. package/_bundles/{9.ordering-ui.62d46eec3c210c5257aa.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/BusinessBasicInformation/index.js +8 -7
  15. package/_modules/themes/five/src/components/BusinessItemAccordion/index.js +5 -2
  16. package/_modules/themes/five/src/components/BusinessItemAccordion/styles.js +25 -19
  17. package/_modules/themes/five/src/components/BusinessProductsListing/index.js +2 -0
  18. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +133 -31
  19. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +37 -3
  20. package/_modules/themes/five/src/components/Cart/index.js +10 -6
  21. package/_modules/themes/five/src/components/Checkout/index.js +67 -22
  22. package/_modules/themes/five/src/components/GiftCard/GiftCardOrdersList/index.js +53 -0
  23. package/_modules/themes/five/src/components/GiftCard/GiftCardOrdersList/styles.js +16 -0
  24. package/_modules/themes/five/src/components/GiftCard/HorizontalGiftCardOrdersLayout/index.js +69 -0
  25. package/_modules/themes/five/src/components/GiftCard/HorizontalGiftCardOrdersLayout/styles.js +16 -0
  26. package/_modules/themes/five/src/components/GiftCard/SingleGiftCard/index.js +90 -0
  27. package/_modules/themes/five/src/components/GiftCard/SingleGiftCard/styles.js +43 -0
  28. package/_modules/themes/five/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.js +75 -0
  29. package/_modules/themes/five/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.js +19 -0
  30. package/_modules/themes/five/src/components/MyOrders/index.js +6 -1
  31. package/_modules/themes/five/src/components/OrderProgress/index.js +1 -1
  32. package/_modules/themes/five/src/components/OrdersOption/index.js +1 -0
  33. package/_modules/themes/five/src/components/PhoneAutocomplete/index.js +165 -31
  34. package/_modules/themes/five/src/components/PhoneAutocomplete/styles.js +53 -9
  35. package/_modules/themes/five/src/components/ProductForm/index.js +1 -0
  36. package/_modules/themes/five/src/components/SingleProductCard/layouts/original/styles.js +1 -1
  37. package/_modules/themes/five/src/components/UserFormDetails/index.js +5 -17
  38. package/_modules/themes/five/src/components/UserFormDetails/styles.js +3 -7
  39. package/index-template.js +9 -1
  40. package/package.json +2 -2
  41. package/src/themes/callcenterOriginal/src/components/Orders/DeliveriesManager/index.js +3 -1
  42. package/src/themes/callcenterOriginal/src/components/Orders/OrdersDashboardControls/index.js +5 -1
  43. package/src/themes/callcenterOriginal/src/components/Orders/OrdersManager/index.js +2 -0
  44. package/src/themes/five/src/components/BusinessBasicInformation/index.js +6 -3
  45. package/src/themes/five/src/components/BusinessItemAccordion/index.js +2 -2
  46. package/src/themes/five/src/components/BusinessItemAccordion/styles.js +8 -7
  47. package/src/themes/five/src/components/BusinessProductsListing/index.js +2 -0
  48. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +156 -36
  49. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +66 -0
  50. package/src/themes/five/src/components/Cart/index.js +7 -4
  51. package/src/themes/five/src/components/Checkout/index.js +61 -35
  52. package/src/themes/five/src/components/GiftCard/GiftCardOrdersList/index.js +50 -0
  53. package/src/themes/five/src/components/GiftCard/GiftCardOrdersList/styles.js +34 -0
  54. package/src/themes/five/src/components/GiftCard/HorizontalGiftCardOrdersLayout/index.js +75 -0
  55. package/src/themes/five/src/components/GiftCard/HorizontalGiftCardOrdersLayout/styles.js +29 -0
  56. package/src/themes/five/src/components/GiftCard/SingleGiftCard/index.js +79 -0
  57. package/src/themes/five/src/components/GiftCard/SingleGiftCard/styles.js +79 -0
  58. package/src/themes/five/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.js +72 -0
  59. package/src/themes/five/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.js +31 -0
  60. package/src/themes/five/src/components/MyOrders/index.js +6 -1
  61. package/src/themes/five/src/components/OrderProgress/index.js +1 -1
  62. package/src/themes/five/src/components/OrdersOption/index.js +1 -0
  63. package/src/themes/five/src/components/PhoneAutocomplete/index.js +195 -46
  64. package/src/themes/five/src/components/PhoneAutocomplete/styles.js +106 -10
  65. package/src/themes/five/src/components/ProductForm/index.js +1 -0
  66. package/src/themes/five/src/components/SingleProductCard/layouts/original/styles.js +1 -1
  67. package/src/themes/five/src/components/UserFormDetails/index.js +6 -27
  68. package/src/themes/five/src/components/UserFormDetails/styles.js +0 -16
  69. package/template/assets/images/delivery.svg +11 -0
  70. package/template/assets/images/phone-hero-callcenter.png +0 -0
  71. package/template/assets/images/phone.svg +11 -0
  72. package/template/assets/images/pickup.svg +17 -0
  73. package/_bundles/ordering-ui.62d46eec3c210c5257aa.js +0 -2
  74. /package/_bundles/{7.ordering-ui.62d46eec3c210c5257aa.js.LICENSE.txt → 7.ordering-ui.cc1d13aa04732fde3671.js.LICENSE.txt} +0 -0
  75. /package/_bundles/{ordering-ui.62d46eec3c210c5257aa.js.LICENSE.txt → ordering-ui.cc1d13aa04732fde3671.js.LICENSE.txt} +0 -0
@@ -23,7 +23,13 @@ import {
23
23
  BusinessLogosContainer,
24
24
  BusinessBanner,
25
25
  BusinessLogosWrapper,
26
- AddressFormWrapper
26
+ AddressFormWrapper,
27
+ Title,
28
+ TypesContainer,
29
+ TypeButton,
30
+ IconTypeButton,
31
+ TypesWrapper,
32
+ AdditionalTypesContainer
27
33
  } from './styles'
28
34
  import { useWindowSize } from '../../../../../../../hooks/useWindowSize'
29
35
  import { Button } from '../../../../styles/Buttons'
@@ -70,11 +76,13 @@ const BusinessesListingUI = (props) => {
70
76
  getCities,
71
77
  citiesState,
72
78
  logosLayout,
73
- actualSlug
79
+ actualSlug,
80
+ orderTypes
74
81
  } = props
75
-
82
+ const allOrderTypes = [1, 2, 3, 4, 5]
83
+ const pickupTypes = [2, 3, 4, 5]
76
84
  const [, t] = useLanguage()
77
- const [orderState, { changeCityFilter }] = useOrder()
85
+ const [orderState, { changeCityFilter, changeType }] = useOrder()
78
86
  const [{ auth }] = useSession()
79
87
  const [{ configs }] = useConfig()
80
88
  const windowSize = useWindowSize()
@@ -86,6 +94,7 @@ const BusinessesListingUI = (props) => {
86
94
  const [isPreorder, setIsPreorder] = useState(false)
87
95
  const [preorderBusiness, setPreorderBusiness] = useState(null)
88
96
  const [hasHighRatedBusiness, setHasHighRatedBusiness] = useState(true)
97
+ const [isPickupSelected, setIsPickupSelected] = useState(pickupTypes.includes(orderState?.options?.type))
89
98
  const userCustomer = JSON.parse(window.localStorage.getItem('user-customer'))
90
99
  const [favoriteIds, setFavoriteIds] = useState([])
91
100
  const allCitiesDisabled = citiesState?.cities?.every(city => !city.enabled)
@@ -105,7 +114,7 @@ const BusinessesListingUI = (props) => {
105
114
  : orderState?.options?.type === 8
106
115
  ? 'catering_pickup'
107
116
  : null
108
-
117
+ const configTypes = configs?.order_types_allowed?.value.split('|').filter(value => (allOrderTypes.includes(Number(value)))).map(value => Number(value)) || []
109
118
  const cateringValues = preorderBusiness?.configs && getCateringValues(cateringTypeString, preorderBusiness?.configs)
110
119
 
111
120
  const handleScroll = useCallback(() => {
@@ -173,6 +182,21 @@ const BusinessesListingUI = (props) => {
173
182
  changeCityFilter(cityId === orderState?.options?.city_id ? null : cityId)
174
183
  }
175
184
 
185
+ const handleChangeType = (value) => {
186
+ if (!orderState?.loading) {
187
+ changeType(value)
188
+ if (value === 1) {
189
+ setIsPickupSelected(false)
190
+ }
191
+ }
192
+ }
193
+
194
+ const handleChangeToPickup = () => {
195
+ const firstEnabledPickupType = orderTypes.find(type => configTypes?.includes(type.value) && type.value !== 1)?.value
196
+ handleChangeType(firstEnabledPickupType)
197
+ setIsPickupSelected(true)
198
+ }
199
+
176
200
  useEffect(() => {
177
201
  if (preorderBusiness) setIsPreorder(true)
178
202
  }, [preorderBusiness])
@@ -195,6 +219,30 @@ const BusinessesListingUI = (props) => {
195
219
  if (!selectedCity || !selectedCity?.enabled) changeCityFilter(null)
196
220
  }, [citiesState, orderState?.options?.city_id])
197
221
 
222
+ useEffect(() => {
223
+ if (pickupTypes.includes(orderState?.options?.type) && isCustomerMode) {
224
+ setIsPickupSelected(true)
225
+ }
226
+ }, [orderState?.options?.type])
227
+
228
+ const OrderTypesComponent = () => {
229
+ return (
230
+ <>
231
+ {orderTypes && (configTypes ? orderTypes.filter(type => configTypes?.includes(type.value) && type.value !== 1) : orderTypes).map((item, i) => (
232
+ <Button
233
+ key={item.value}
234
+ onClick={() => handleChangeType(item.value)}
235
+ color={orderState?.options?.type === item?.value ? 'primary' : 'secondary'}
236
+ disabled={orderState?.loading}
237
+ className={orderState?.options?.type !== item?.value ? 'activated' : ''}
238
+ >
239
+ {item.text}
240
+ </Button>
241
+ ))}
242
+ </>
243
+ )
244
+ }
245
+
198
246
  if (logosLayout) {
199
247
  return (
200
248
  <BusinessLogosWrapper>
@@ -234,7 +282,7 @@ const BusinessesListingUI = (props) => {
234
282
  {windowSize.width < 576 && (
235
283
  <OrderContextUI isBusinessList hideHero={(configs?.business_listing_hide_image?.value !== '1' && !isChew) && !hideHero} />
236
284
  )}
237
- {(configs?.business_listing_hide_image?.value !== '1' && !isChew) && !hideHero && (
285
+ {(configs?.business_listing_hide_image?.value !== '1' && !isChew) && !hideHero && !isCustomerMode && (
238
286
  <BusinessHeroImg
239
287
  bgimage={theme.images?.general?.businessHero}
240
288
  height={theme?.business_listing_view?.components?.business_hero?.style?.height}
@@ -242,13 +290,58 @@ const BusinessesListingUI = (props) => {
242
290
  )}
243
291
  </BusinessBanner>
244
292
  )}
245
- <OrderProgress
246
- isChew={isChew}
247
- franchiseId={props.franchiseId}
248
- userCustomerId={userCustomer?.id}
249
- asDashboard={isCustomerMode}
250
- isCustomerMode={isCustomerMode}
251
- />
293
+ {(userCustomer && orderState?.options?.address?.address && isCustomerMode) && (
294
+ <>
295
+ <Title>{t('DELIVERY_TYPE', 'Delivery Type')}</Title>
296
+ <TypesContainer>
297
+ {configTypes.includes(1) && (
298
+ <TypeButton onClick={() => handleChangeType(1)} disabled={orderState?.loading} activated={!isPickupSelected}>
299
+ <IconTypeButton activated={!isPickupSelected}>
300
+ <img
301
+ src={theme?.images?.general?.deliveryIco}
302
+ width={20}
303
+ height={20}
304
+ />
305
+ </IconTypeButton>
306
+ <p>{t('DELIVERY', 'Delivery')}</p>
307
+ </TypeButton>
308
+ )}
309
+ {configTypes.some(type => pickupTypes.includes(type)) && (
310
+ <TypeButton
311
+ disabled={orderState?.loading}
312
+ activated={isPickupSelected}
313
+ onClick={() => handleChangeToPickup()}
314
+ >
315
+ <IconTypeButton activated={isPickupSelected}>
316
+ <img
317
+ src={theme?.images?.general?.pickupIco}
318
+ width={22}
319
+ height={22}
320
+ />
321
+ </IconTypeButton>
322
+ <p>{t('PICKUP', 'Pickup')}</p>
323
+ </TypeButton>
324
+ )}
325
+ </TypesContainer>
326
+ {isPickupSelected && (
327
+ <TypesWrapper>
328
+ <p>{t('WHAT_PICKUP_YOU_NEED', 'What kind of pickup do you need?')}</p>
329
+ <AdditionalTypesContainer>
330
+ <OrderTypesComponent />
331
+ </AdditionalTypesContainer>
332
+ </TypesWrapper>
333
+ )}
334
+ </>
335
+ )}
336
+ {!isCustomerMode && (
337
+ <OrderProgress
338
+ isChew={isChew}
339
+ franchiseId={props.franchiseId}
340
+ userCustomerId={userCustomer?.id}
341
+ asDashboard={isCustomerMode}
342
+ isCustomerMode={isCustomerMode}
343
+ />
344
+ )}
252
345
  {(configs?.business_listing_hide_image?.value !== '1' && isChew) && (
253
346
  <BusinessHeroImg
254
347
  bgimage={theme.images?.general?.businessHero}
@@ -455,28 +548,27 @@ const BusinessesListingUI = (props) => {
455
548
  open={modals.formOpen || modals.listOpen}
456
549
  width='70%'
457
550
  onClose={() => setModals({ ...modals, formOpen: false, listOpen: false })}
458
- >
459
- {modals.listOpen ? (
460
- <AddressList
461
- isModal
462
- changeOrderAddressWithDefault
463
- userId={isNaN(userCustomer?.id) ? null : userCustomer?.id}
464
- onCancel={() => setModals({ ...modals, listOpen: false })}
465
- isCustomerMode={isCustomerMode}
466
- />
467
- ) : (
468
- <AddressFormWrapper>
469
- <AddressForm
470
- useValidationFileds
471
- address={orderState?.options?.address || {}}
472
- onCancel={() => setModals({ ...modals, formOpen: false })}
473
- onSaveAddress={() => setModals({ ...modals, formOpen: false })}
474
- isCustomerMode={isCustomerMode}
475
- />
476
- </AddressFormWrapper>
477
- )
478
- }
479
- </Modal>
551
+ >
552
+ {modals.listOpen ? (
553
+ <AddressList
554
+ isModal
555
+ changeOrderAddressWithDefault
556
+ userId={isNaN(userCustomer?.id) ? null : userCustomer?.id}
557
+ onCancel={() => setModals({ ...modals, listOpen: false })}
558
+ isCustomerMode={isCustomerMode}
559
+ />
560
+ ) : (
561
+ <AddressFormWrapper>
562
+ <AddressForm
563
+ useValidationFileds
564
+ address={orderState?.options?.address || {}}
565
+ onCancel={() => setModals({ ...modals, formOpen: false })}
566
+ onSaveAddress={() => setModals({ ...modals, formOpen: false })}
567
+ isCustomerMode={isCustomerMode}
568
+ />
569
+ </AddressFormWrapper>
570
+ )}
571
+ </Modal>
480
572
 
481
573
  <Alert
482
574
  title={!mapErrors ? t('SEARCH', 'Search') : t('BUSINESSES_MAP', 'Businesses Map')}
@@ -492,10 +584,38 @@ const BusinessesListingUI = (props) => {
492
584
  }
493
585
 
494
586
  export const OriginalBusinessesListing = (props) => {
587
+ const [, t] = useLanguage()
495
588
  const businessListingProps = {
496
589
  ...props,
497
590
  UIComponent: BusinessesListingUI,
498
- paginationSettings: { initialPage: 1, pageSize: 25, controlType: 'infinity' }
591
+ paginationSettings: { initialPage: 1, pageSize: 25, controlType: 'infinity' },
592
+ orderTypes: props.orderTypes || [
593
+ {
594
+ value: 1,
595
+ text: t('DELIVERY', 'Delivery'),
596
+ description: t('ORDERTYPE_DESCRIPTION_DELIVERY', 'Delivery description'),
597
+ },
598
+ {
599
+ value: 2,
600
+ text: t('PICKUP', 'Pickup'),
601
+ description: t('ORDERTYPE_DESCRIPTION_PICKUP', 'Pickup description')
602
+ },
603
+ {
604
+ value: 3,
605
+ text: t('EAT_IN', 'Eat in'),
606
+ description: t('ORDERTYPE_DESCRIPTION_EATIN', 'Eat in description')
607
+ },
608
+ {
609
+ value: 4,
610
+ text: t('CURBSIDE', 'Curbside'),
611
+ description: t('ORDERTYPE_DESCRIPTION_CURBSIDE', 'Curbside description')
612
+ },
613
+ {
614
+ value: 5,
615
+ text: t('DRIVE_THRU', 'Drive thru'),
616
+ description: t('ORDERTYPE_DESCRIPTION_DRIVETHRU', 'Drive Thru description')
617
+ }
618
+ ]
499
619
  }
500
620
  return <BusinessListController {...businessListingProps} />
501
621
  }
@@ -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
+ `