ordering-ui-external 1.9.2 → 1.9.4

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 (97) hide show
  1. package/_bundles/0.ordering-ui.9ce64e14904d222c0020.js +1 -0
  2. package/_bundles/{1.ordering-ui.8e20ae6af39ad738a29e.js → 1.ordering-ui.9ce64e14904d222c0020.js} +1 -1
  3. package/_bundles/{2.ordering-ui.8e20ae6af39ad738a29e.js → 2.ordering-ui.9ce64e14904d222c0020.js} +1 -1
  4. package/_bundles/{4.ordering-ui.8e20ae6af39ad738a29e.js → 4.ordering-ui.9ce64e14904d222c0020.js} +1 -1
  5. package/_bundles/{5.ordering-ui.8e20ae6af39ad738a29e.js → 5.ordering-ui.9ce64e14904d222c0020.js} +1 -1
  6. package/_bundles/{6.ordering-ui.8e20ae6af39ad738a29e.js → 6.ordering-ui.9ce64e14904d222c0020.js} +1 -1
  7. package/_bundles/{7.ordering-ui.8e20ae6af39ad738a29e.js → 7.ordering-ui.9ce64e14904d222c0020.js} +2 -2
  8. package/_bundles/{7.ordering-ui.8e20ae6af39ad738a29e.js.LICENSE.txt → 7.ordering-ui.9ce64e14904d222c0020.js.LICENSE.txt} +0 -0
  9. package/_bundles/{8.ordering-ui.8e20ae6af39ad738a29e.js → 8.ordering-ui.9ce64e14904d222c0020.js} +1 -1
  10. package/_bundles/{9.ordering-ui.8e20ae6af39ad738a29e.js → 9.ordering-ui.9ce64e14904d222c0020.js} +1 -1
  11. package/_bundles/ordering-ui.9ce64e14904d222c0020.js +2 -0
  12. package/_bundles/{ordering-ui.8e20ae6af39ad738a29e.js.LICENSE.txt → ordering-ui.9ce64e14904d222c0020.js.LICENSE.txt} +0 -0
  13. package/_modules/components/BusinessesListing/index.js +1 -3
  14. package/_modules/components/VerticalOrdersLayout/SingleOrderCard/index.js +26 -12
  15. package/_modules/components/VerticalOrdersLayout/styles.js +1 -1
  16. package/_modules/themes/five/index.js +7 -0
  17. package/_modules/themes/five/src/components/AddressList/index.js +3 -2
  18. package/_modules/themes/five/src/components/BusinessItemAccordion/index.js +3 -2
  19. package/_modules/themes/five/src/components/BusinessListingSearch/index.js +14 -6
  20. package/_modules/themes/five/src/components/BusinessProductsCategories/index.js +8 -3
  21. package/_modules/themes/five/src/components/BusinessProductsList/index.js +50 -14
  22. package/_modules/themes/five/src/components/BusinessProductsListing/index.js +9 -2
  23. package/_modules/themes/five/src/components/BusinessProductsListing/styles.js +10 -6
  24. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +55 -186
  25. package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +29 -40
  26. package/_modules/themes/five/src/components/Cart/index.js +56 -97
  27. package/_modules/themes/five/src/components/CartContent/index.js +50 -2
  28. package/_modules/themes/five/src/components/CartContent/styles.js +6 -4
  29. package/_modules/themes/five/src/components/Checkout/index.js +8 -2
  30. package/_modules/themes/five/src/components/Checkout/styles.js +10 -4
  31. package/_modules/themes/five/src/components/Header/index.js +26 -34
  32. package/_modules/themes/five/src/components/Header/styles.js +46 -35
  33. package/_modules/themes/five/src/components/HeaderOption/index.js +3 -2
  34. package/_modules/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/index.js +3 -2
  35. package/_modules/themes/five/src/components/MultiCheckout/index.js +22 -13
  36. package/_modules/themes/five/src/components/MultiCheckout/styles.js +11 -8
  37. package/_modules/themes/five/src/components/MultiOrdersDetails/index.js +9 -1
  38. package/_modules/themes/five/src/components/OrderContextUI/index.js +192 -0
  39. package/_modules/themes/five/src/components/OrderContextUI/styles.js +41 -0
  40. package/_modules/themes/five/src/components/OrderDetails/index.js +3 -0
  41. package/_modules/themes/five/src/components/OrdersOption/PreviousBusinessOrdered/index.js +8 -2
  42. package/_modules/themes/five/src/components/OrdersOption/PreviousBusinessOrdered/styles.js +8 -2
  43. package/_modules/themes/five/src/components/OrdersOption/index.js +2 -1
  44. package/_modules/themes/five/src/components/ProductItemAccordion/index.js +17 -8
  45. package/_modules/themes/five/src/components/ProductItemAccordion/styles.js +27 -27
  46. package/_modules/themes/five/src/components/ProductOptionSubOption/index.js +7 -2
  47. package/_modules/themes/five/src/components/ProductOptionSubOption/styles.js +17 -14
  48. package/_modules/themes/five/src/components/SingleOrderCard/index.js +16 -16
  49. package/_modules/themes/five/src/components/SingleOrderCard/styles.js +49 -41
  50. package/package.json +3 -2
  51. package/src/components/BusinessesListing/index.js +1 -3
  52. package/src/components/VerticalOrdersLayout/SingleOrderCard/index.js +25 -14
  53. package/src/components/VerticalOrdersLayout/styles.js +8 -0
  54. package/src/themes/five/index.js +2 -0
  55. package/src/themes/five/src/components/AddressList/index.js +3 -2
  56. package/src/themes/five/src/components/BusinessItemAccordion/index.js +2 -1
  57. package/src/themes/five/src/components/BusinessListingSearch/index.js +4 -0
  58. package/src/themes/five/src/components/BusinessProductsCategories/index.js +8 -3
  59. package/src/themes/five/src/components/BusinessProductsList/index.js +54 -18
  60. package/src/themes/five/src/components/BusinessProductsListing/index.js +14 -2
  61. package/src/themes/five/src/components/BusinessProductsListing/styles.js +18 -6
  62. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +219 -345
  63. package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/styles.js +2 -77
  64. package/src/themes/five/src/components/Cart/index.js +50 -57
  65. package/src/themes/five/src/components/CartContent/index.js +43 -3
  66. package/src/themes/five/src/components/CartContent/styles.js +6 -0
  67. package/src/themes/five/src/components/Checkout/index.js +16 -2
  68. package/src/themes/five/src/components/Checkout/styles.js +19 -6
  69. package/src/themes/five/src/components/Header/index.js +281 -277
  70. package/src/themes/five/src/components/Header/styles.js +20 -51
  71. package/src/themes/five/src/components/HeaderOption/index.js +3 -2
  72. package/src/themes/five/src/components/HomeHero/layouts/OriginalHomeHero/index.js +2 -1
  73. package/src/themes/five/src/components/MultiCheckout/index.js +27 -13
  74. package/src/themes/five/src/components/MultiCheckout/styles.js +8 -13
  75. package/src/themes/five/src/components/MultiOrdersDetails/index.js +21 -13
  76. package/src/themes/five/src/components/OrderContextUI/index.js +133 -0
  77. package/src/themes/five/src/components/OrderContextUI/styles.js +86 -0
  78. package/src/themes/five/src/components/OrderDetails/index.js +4 -0
  79. package/src/themes/five/src/components/OrdersOption/PreviousBusinessOrdered/index.js +5 -2
  80. package/src/themes/five/src/components/OrdersOption/PreviousBusinessOrdered/styles.js +4 -0
  81. package/src/themes/five/src/components/OrdersOption/index.js +2 -1
  82. package/src/themes/five/src/components/ProductItemAccordion/index.js +58 -40
  83. package/src/themes/five/src/components/ProductItemAccordion/styles.js +4 -3
  84. package/src/themes/five/src/components/ProductOptionSubOption/index.js +8 -1
  85. package/src/themes/five/src/components/ProductOptionSubOption/styles.js +6 -0
  86. package/src/themes/five/src/components/SingleOrderCard/index.js +12 -13
  87. package/src/themes/five/src/components/SingleOrderCard/styles.js +26 -7
  88. package/template/app.js +179 -66
  89. package/template/components/ListenPageChanges/index.js +3 -2
  90. package/template/components/OrderingThemeUpdated/index.js +41 -0
  91. package/template/helmetdata.json +7 -0
  92. package/template/pages/MessagesList/index.js +2 -0
  93. package/template/pages/MultiCart/index.js +30 -0
  94. package/template/pages/MultiCheckout/index.js +86 -10
  95. package/template/pages/MultiOrdersDetails/index.js +9 -4
  96. package/_bundles/0.ordering-ui.8e20ae6af39ad738a29e.js +0 -1
  97. package/_bundles/ordering-ui.8e20ae6af39ad738a29e.js +0 -2
@@ -13,86 +13,11 @@ export const BusinessBanner = styled.div`
13
13
  align-items: center;
14
14
  margin-bottom: 30px;
15
15
  position: relative;
16
- @media (max-width: 481px) {
16
+ @media (max-width: 576px) {
17
17
  margin-bottom: 0px;
18
18
  }
19
19
  `
20
20
 
21
- export const BusinessFeatures = styled.div`
22
- position: absolute;
23
- top: 10%;
24
- width: 100%;
25
- padding: 0 15px;
26
- box-sizing: border-box;
27
- `
28
-
29
- export const AddressMenu = styled.div`
30
- cursor: pointer;
31
- font-size: 14px;
32
- display: flex;
33
- align-items: center;
34
- background-color: #fff;
35
- color: #344050;
36
- font-weight: 600;
37
- border-radius: 50px;
38
- padding: 13px 19px;
39
- margin-bottom: 10px;
40
- span {
41
- width: 100%;
42
- overflow: hidden;
43
- text-overflow: ellipsis;
44
- white-space: nowrap;
45
- }
46
- svg {
47
- margin-right: 5px;
48
- color: #B1BCCC;
49
- ${props => props.theme?.rtl && css`
50
- margin-left: 5px;
51
- margin-right: 0;
52
- `}
53
- }
54
- `
55
-
56
- export const FeatureItems = styled.div`
57
- width: 100%;
58
- display: flex;
59
- justify-content: space-between;
60
- `
61
-
62
- export const ItemInline = styled.div`
63
- > span #select-input {
64
- background-color: #F8F9FA !important;
65
- border: none;
66
- border-radius: 7.6px;
67
- svg {
68
- font-size: 14px;
69
- }
70
- #list {
71
- background-color: #fff;
72
- border: none;
73
- border-radius: 7.6px;
74
- left: 0px;
75
- right: initial;
76
- ${props => props.theme.rtl && css`
77
- left: initial;
78
- right: 0px;
79
- `}
80
- }
81
- > div:first-child {
82
- font-size: 11px;
83
- }
84
- }
85
- .moment-popover {
86
- > div:first-child {
87
- font-size: 11px;
88
- padding: 4px 7px;
89
- svg {
90
- font-size: 14px;
91
- }
92
- }
93
- }
94
- `
95
-
96
21
  export const BusinessSearch = styled.div`
97
22
  display: flex;
98
23
  background-color: #f8f9fa;
@@ -196,7 +121,7 @@ export const BusinessHeroImgStyled = styled.div`
196
121
  height: 370px;
197
122
  }
198
123
  @media (min-width: 821px) {
199
- height: ${({ height }) => height || '650px'};
124
+ height: ${({ height, theme }) => theme?.business_listing_view?.components?.business_hero?.components?.styles?.height || height || '650px'};
200
125
  }
201
126
  `
202
127
 
@@ -7,7 +7,6 @@ import {
7
7
  useUtils,
8
8
  useValidationFields,
9
9
  useConfig,
10
- useOrderingTheme,
11
10
  useSite,
12
11
  useCustomer
13
12
  } from 'ordering-components-external'
@@ -24,7 +23,6 @@ import { useWindowSize } from '../../../../../hooks/useWindowSize'
24
23
  import { TaxInformation } from '../TaxInformation'
25
24
  import { TextArea } from '../../styles/Inputs'
26
25
  import { SpinnerLoader } from '../../../../../components/SpinnerLoader'
27
- import { CartStoresListing } from '../../../../franchise/src/components/CartStoresListing'
28
26
  import { DriverTips } from '../DriverTips'
29
27
  import { ServiceForm } from '../ServiceForm'
30
28
  import {
@@ -56,7 +54,6 @@ const CartUI = (props) => {
56
54
  onClickCheckout,
57
55
  isCheckout,
58
56
  useKioskApp,
59
- isMultiCheckout,
60
57
  isCartPending,
61
58
  isCartPopover,
62
59
  isForceOpenCart,
@@ -67,7 +64,10 @@ const CartUI = (props) => {
67
64
  handleChangeComment,
68
65
  commentState,
69
66
  handleRemoveOfferClick,
70
- setPreorderBusiness
67
+ setPreorderBusiness,
68
+ cart: cartMulticart,
69
+ hideDeliveryFee,
70
+ hideDriverTip
71
71
  } = props
72
72
 
73
73
  const theme = useTheme()
@@ -75,7 +75,6 @@ const CartUI = (props) => {
75
75
  const [orderState] = useOrder()
76
76
  const [events] = useEvent()
77
77
  const [{ parsePrice, parseNumber, parseDate }] = useUtils()
78
- const [orderingTheme] = useOrderingTheme()
79
78
  const [validationFields] = useValidationFields()
80
79
  const [{ configs }] = useConfig()
81
80
  const [{ site }] = useSite()
@@ -93,17 +92,16 @@ const CartUI = (props) => {
93
92
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
94
93
  const [openTaxModal, setOpenTaxModal] = useState({ open: false, tax: null })
95
94
  const [isUpselling, setIsUpselling] = useState(false)
96
- const [openChangeStore, setOpenChangeStore] = useState(false)
95
+ // const [openChangeStore, setOpenChangeStore] = useState(false)
97
96
 
98
97
  const businessUrlTemplate = site?.business_url_template || '/store/:business_slug'
99
98
 
100
99
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
101
- const checkoutMultiBusinessEnabled = configs?.checkout_multi_business_enabled?.value === '1'
102
- const openCarts = (Object.values(orderState?.carts)?.filter(cart => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && !cart?.wallets) || null) || []
103
-
104
- const cart = orderState?.carts?.[`businessId:${props.cart.business_id}`]
100
+ const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
101
+ const cart = cartMulticart || orderState?.carts?.[`businessId:${props.cart?.business_id}`]
105
102
  const viewString = isStore ? 'business_view' : 'header'
106
- const hideCartComments = orderingTheme?.theme?.[viewString]?.components?.cart?.components?.comments?.hidden
103
+ const hideCartComments = theme?.[viewString]?.components?.cart?.components?.comments?.hidden
104
+ const hideCartDiscount = theme?.[viewString]?.components?.cart?.components?.discount?.hidden
107
105
  const walletName = {
108
106
  cash: {
109
107
  name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet')
@@ -134,37 +132,30 @@ const CartUI = (props) => {
134
132
  }
135
133
 
136
134
  const handleClickCheckout = () => {
137
- const cartSelectedHasGroup = cart?.group?.uuid
138
- const cartFilterValidation = cart => cart?.valid && cart?.status !== 2
139
- const cartsGroupLength = cartSelectedHasGroup ? Object.values(orderState.carts).filter(_cart => _cart?.group?.uuid === cartSelectedHasGroup && cartFilterValidation(_cart))?.length : 0
140
- if (cartsGroupLength > 1 && checkoutMultiBusinessEnabled) {
141
- events.emit('go_to_page', { page: 'multi_checkout', params: { cartUuid: cart?.group?.uuid } })
142
- events.emit('cart_popover_closed')
143
- return
144
- }
145
- const cartGroupsCount = {}
146
- // eslint-disable-next-line no-unused-expressions
147
- Object.values(orderState.carts).filter(_cart => cartFilterValidation(_cart))?.forEach(_cart => {
148
- if (cartGroupsCount[_cart?.group?.uuid]) {
149
- cartGroupsCount[_cart?.group?.uuid] += 1
150
- } else {
151
- cartGroupsCount[_cart?.group?.uuid] = 1
152
- }
153
- })
154
- let groupForTheCart
155
- const groupForAddCartArray = Object.keys(cartGroupsCount).filter(cartGroupUuid => cartGroupsCount[cartGroupUuid] > 0 && cartGroupsCount[cartGroupUuid] < 5)
156
- const max = Math.max(...groupForAddCartArray.map(uuid => cartGroupsCount[uuid]))
157
- const indexes = groupForAddCartArray.filter(uuid => cartGroupsCount[uuid] === max)
158
- if (indexes?.length > 1) {
159
- groupForTheCart = indexes.find(uuid => uuid !== 'undefined')
135
+ const cartsAvailable = Object.values(orderState?.carts)?.filter(cart => cart?.valid && cart?.status !== 2)
136
+ if (cartsAvailable.length === 1) {
137
+ events.emit('go_to_page', { page: 'checkout', params: { cartUuid: cartsAvailable[0]?.uuid } })
160
138
  } else {
161
- groupForTheCart = indexes[0]
162
- }
139
+ const groupKeys = {}
140
+ cartsAvailable.forEach(_cart => {
141
+ groupKeys[_cart?.group?.uuid]
142
+ ? groupKeys[_cart?.group?.uuid] += 1
143
+ : groupKeys[_cart?.group?.uuid ?? 'null'] = 1
144
+ })
163
145
 
164
- if (checkoutMultiBusinessEnabled && openCarts?.length > 1 && groupForTheCart) {
165
- events.emit('go_to_page', { page: 'multi_cart', params: { cartUuid: cart.uuid, cartGroup: groupForTheCart === 'undefined' ? 'create' : groupForTheCart } })
166
- } else {
167
- events.emit('go_to_page', { page: 'checkout', params: { cartUuid: cart.uuid } })
146
+ if (
147
+ (Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
148
+ Object.keys(groupKeys).length > 1
149
+ ) {
150
+ events.emit('go_to_page', { page: 'multi_cart' })
151
+ } else {
152
+ events.emit('go_to_page', {
153
+ page: 'multi_checkout',
154
+ params: {
155
+ cartUuid: cartsAvailable[0]?.group?.uuid
156
+ }
157
+ })
158
+ }
168
159
  }
169
160
  events.emit('cart_popover_closed')
170
161
  onClickCheckout && onClickCheckout()
@@ -218,7 +209,7 @@ const CartUI = (props) => {
218
209
 
219
210
  const getIncludedTaxes = () => {
220
211
  if (cart?.taxes === null) {
221
- return cart.business.tax_type === 1 ? cart?.tax : 0
212
+ return cart?.business.tax_type === 1 ? cart?.tax : 0
222
213
  } else {
223
214
  return cart?.taxes.reduce((taxIncluded, tax) => {
224
215
  return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
@@ -242,9 +233,9 @@ const CartUI = (props) => {
242
233
  })
243
234
  }
244
235
 
245
- const handleChangeStore = () => {
246
- setOpenChangeStore(true)
247
- }
236
+ // const handleChangeStore = () => {
237
+ // setOpenChangeStore(true)
238
+ // }
248
239
 
249
240
  useEffect(() => {
250
241
  if (isCustomMode) setIsUpselling(true)
@@ -281,7 +272,7 @@ const CartUI = (props) => {
281
272
  handleClickCheckout={handleClickCheckout}
282
273
  checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || !cart?.valid_maximum || (!cart?.valid_minimum && !(cart?.discount_type === 1 && cart?.discount_rate === 100)) || !cart?.valid_address}
283
274
  setPreorderBusiness={setPreorderBusiness}
284
- handleChangeStore={!useKioskApp && handleChangeStore}
275
+ // handleChangeStore={!useKioskApp && handleChangeStore}
285
276
  isMultiCheckout={isMultiCheckout}
286
277
  >
287
278
  {cart?.products?.length > 0 && cart?.products.map(product => (
@@ -289,6 +280,7 @@ const CartUI = (props) => {
289
280
  key={product.code}
290
281
  isCartPending={isCartPending}
291
282
  isCartProduct
283
+ isDisabledEdit={!cart?.business_id}
292
284
  product={product}
293
285
  isCheckout={isCheckout}
294
286
  changeQuantity={changeQuantity}
@@ -297,6 +289,7 @@ const CartUI = (props) => {
297
289
  onDeleteProduct={handleDeleteClick}
298
290
  onEditProduct={handleEditProduct}
299
291
  isStore={isStore}
292
+ viewString={viewString}
300
293
  />
301
294
  ))}
302
295
  {!cart?.valid_products && (
@@ -407,14 +400,14 @@ const CartUI = (props) => {
407
400
  </tr>
408
401
  ))
409
402
  }
410
- {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
403
+ {orderState?.options?.type === 1 && cart?.delivery_price > 0 && !hideDeliveryFee && (
411
404
  <tr>
412
405
  <td>{t('DELIVERY_FEE', 'Delivery Fee')}</td>
413
- <td>{parsePrice(cart?.delivery_price)}</td>
406
+ <td>{parsePrice(cart?.delivery_price_with_discount ?? cart?.delivery_price)}</td>
414
407
  </tr>
415
408
  )}
416
409
  {
417
- cart?.offers?.length > 0 && cart?.offers?.filter(offer => offer?.target === 2)?.map(offer => (
410
+ !hideCartDiscount && cart?.offers?.length > 0 && cart?.offers?.filter(offer => offer?.target === 2)?.map(offer => (
418
411
  <tr key={offer.id}>
419
412
  <td className='icon'>
420
413
  {offer.name}
@@ -432,7 +425,7 @@ const CartUI = (props) => {
432
425
  </tr>
433
426
  ))
434
427
  }
435
- {cart?.driver_tip > 0 && (
428
+ {cart?.driver_tip > 0 && !hideDriverTip && (
436
429
  <tr>
437
430
  <td>
438
431
  {t('DRIVER_TIP', 'Driver tip')}{' '}
@@ -448,11 +441,11 @@ const CartUI = (props) => {
448
441
  )}
449
442
  </tbody>
450
443
  </table>
451
- {isCouponEnabled && !isCartPending && ((isCheckout || isCartPopover || isMultiCheckout) && !(isCheckout && isCartPopover)) && (
444
+ {isCouponEnabled && !isCartPending && ((isCheckout || isCartPopover || isMultiCheckout) && !(isCheckout && isCartPopover)) && !hideCartDiscount && (
452
445
  <CouponContainer>
453
446
  <CouponControl
454
- businessId={cart.business_id}
455
- price={cart.total}
447
+ businessId={cart?.business_id}
448
+ price={cart?.total}
456
449
  />
457
450
  </CouponContainer>
458
451
  )}
@@ -567,7 +560,7 @@ const CartUI = (props) => {
567
560
  )}
568
561
  </OrderBill>
569
562
  )}
570
- {(onClickCheckout || isForceOpenCart) && !isCheckout && cart?.valid_products && (
563
+ {(onClickCheckout || isForceOpenCart) && !isCheckout && cart?.valid_products && (!isMultiCheckout || isStore) && (
571
564
  <CheckoutAction>
572
565
  <p>{cart?.total >= 1 && parsePrice(cart?.total)}</p>
573
566
  <Button
@@ -642,17 +635,17 @@ const CartUI = (props) => {
642
635
  <TaxInformation
643
636
  type={openTaxModal.type}
644
637
  data={openTaxModal.data}
645
- products={cart.products}
638
+ products={cart?.products}
646
639
  useKioskApp={useKioskApp}
647
640
  />
648
641
  </Modal>
649
642
  {(openUpselling || isUpselling) && (
650
643
  <UpsellingPage
651
644
  useKioskApp={useKioskApp}
652
- businessId={cart.business_id}
645
+ businessId={cart?.business_id}
653
646
  isCustomMode={isCustomMode}
654
- cartProducts={cart.products}
655
- business={cart.business}
647
+ cartProducts={cart?.products}
648
+ business={cart?.business}
656
649
  handleUpsellingPage={handleUpsellingPage}
657
650
  openUpselling={openUpselling}
658
651
  canOpenUpselling={canOpenUpselling}
@@ -1,9 +1,10 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import { useTheme } from 'styled-components'
3
- import { useLanguage, useEvent } from 'ordering-components-external'
4
- import { Container, NotCarts, Title } from './styles'
3
+ import { useLanguage, useEvent, useConfig, useOrder } from 'ordering-components-external'
4
+ import { Container, NotCarts, Title, WrapperContainer } from './styles'
5
5
 
6
6
  import { Cart } from '../Cart'
7
+ import { Button } from '../../styles/Buttons'
7
8
 
8
9
  export const CartContent = (props) => {
9
10
  const {
@@ -19,8 +20,11 @@ export const CartContent = (props) => {
19
20
  const [, t] = useLanguage()
20
21
  const theme = useTheme()
21
22
  const [events] = useEvent()
23
+ const [orderState] = useOrder()
24
+ const [{ configs }] = useConfig()
22
25
 
23
26
  const [currentCartUuid, setCurrentCartUuid] = useState(null)
27
+ const checkoutMultiBusinessEnabled = configs?.checkout_multi_business_enabled?.value === '1'
24
28
 
25
29
  const handleAddProduct = (product, cart) => {
26
30
  setCurrentCartUuid(cart?.uuid)
@@ -28,6 +32,37 @@ export const CartContent = (props) => {
28
32
 
29
33
  const handleSetCurrentCartUuid = () => {
30
34
  setCurrentCartUuid(null)
35
+ props.onClose && props.onClose()
36
+ }
37
+
38
+ const handleClickCheckout = () => {
39
+ const cartsAvailable = Object.values(orderState?.carts)?.filter(cart => cart?.valid && cart?.status !== 2)
40
+ if (cartsAvailable.length === 1) {
41
+ events.emit('go_to_page', { page: 'checkout', params: { cartUuid: cartsAvailable[0]?.uuid } })
42
+ } else {
43
+ const groupKeys = {}
44
+ cartsAvailable.forEach(_cart => {
45
+ groupKeys[_cart?.group?.uuid]
46
+ ? groupKeys[_cart?.group?.uuid] += 1
47
+ : groupKeys[_cart?.group?.uuid ?? 'null'] = 1
48
+ })
49
+
50
+ if (
51
+ (Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
52
+ Object.keys(groupKeys).length > 1
53
+ ) {
54
+ events.emit('go_to_page', { page: 'multi_cart' })
55
+ } else {
56
+ events.emit('go_to_page', {
57
+ page: 'multi_checkout',
58
+ params: {
59
+ cartUuid: cartsAvailable[0]?.group?.uuid
60
+ }
61
+ })
62
+ }
63
+ }
64
+ events.emit('cart_popover_closed')
65
+ props.onClose && props.onClose()
31
66
  }
32
67
 
33
68
  useEffect(() => {
@@ -43,7 +78,12 @@ export const CartContent = (props) => {
43
78
  <>
44
79
  <Container>
45
80
  {!isSlideBar && (
46
- <Title>{t('YOUR_CART', 'Your cart')}</Title>
81
+ <WrapperContainer>
82
+ <Title>{t('YOUR_CART', 'Your cart')}</Title>
83
+ {checkoutMultiBusinessEnabled && carts?.length > 0 && (
84
+ <Button onClick={handleClickCheckout} color='primary'>{t('CHECKOUT', 'Checkout')}</Button>
85
+ )}
86
+ </WrapperContainer>
47
87
  )}
48
88
  {isOrderStateCarts && carts?.length > 0 &&
49
89
  carts.map(cart => (
@@ -13,6 +13,12 @@ export const Container = styled.div`
13
13
  }
14
14
  `
15
15
 
16
+ export const WrapperContainer = styled.div`
17
+ display: flex;
18
+ width: 100%;
19
+ justify-content: space-between;
20
+ `
21
+
16
22
  export const NotCarts = styled.div`
17
23
  height: 300px;
18
24
  display: flex;
@@ -43,7 +43,9 @@ import {
43
43
  CartHeader,
44
44
  SelectSpotContainer,
45
45
  WrapperActionsInput,
46
- MobileWrapperPlaceOrderButton
46
+ MobileWrapperPlaceOrderButton,
47
+ OrderContextUIWrapper,
48
+ HeaderContent
47
49
  } from './styles'
48
50
 
49
51
  import { Button } from '../../styles/Buttons'
@@ -61,6 +63,7 @@ import { Alert } from '../Confirm'
61
63
  import { CartContent } from '../CartContent'
62
64
  import { Select } from '../../styles/Select'
63
65
  import { PlaceSpot } from '../PlaceSpot'
66
+ import { OrderContextUI } from '../OrderContextUI'
64
67
 
65
68
  const mapConfigs = {
66
69
  mapZoom: 16,
@@ -254,11 +257,22 @@ const CheckoutUI = (props) => {
254
257
  handleStoreRedirect(cart?.business?.slug)
255
258
  }, [cart?.products])
256
259
 
260
+ useEffect(() => {
261
+ window.scrollTo(0, 0)
262
+ }, [])
263
+
257
264
  return (
258
265
  <Container>
259
266
  <WrapperLeftContainer>
260
267
  <WrapperLeftContent>
261
- <ArrowLeft className='back-arrow' onClick={() => history.goBack()} />
268
+ <HeaderContent>
269
+ <ArrowLeft className='back-arrow' onClick={() => history.goBack()} />
270
+ {windowSize?.width < 576 && (
271
+ <OrderContextUIWrapper>
272
+ <OrderContextUI isCheckOut />
273
+ </OrderContextUIWrapper>
274
+ )}
275
+ </HeaderContent>
262
276
  {!cartState.loading && cart?.status === 2 && (
263
277
  <WarningMessage>
264
278
  <VscWarning />
@@ -184,12 +184,6 @@ export const WrapperLeftContent = styled.div`
184
184
  font-size: 32px;
185
185
  color: ${props => props.theme?.colors.darkTextColor};
186
186
  }
187
-
188
- .back-arrow {
189
- font-size: 24px;
190
- cursor: pointer;
191
- margin-bottom: 5px;
192
- }
193
187
  `
194
188
  export const CheckOutDivider = styled.div`
195
189
  height: 8px;
@@ -319,3 +313,22 @@ export const MobileWrapperPlaceOrderButton = styled.div`
319
313
  border-radius: 7.6px;
320
314
  }
321
315
  `
316
+
317
+ export const OrderContextUIWrapper = styled.div`
318
+ flex: 1;
319
+ margin-left: 15px;
320
+ ${props => props.theme.rtl && css`
321
+ margin-left: 0px;
322
+ margin-right: 15px;
323
+ `}
324
+ `
325
+
326
+ export const HeaderContent = styled.div`
327
+ display: flex;
328
+ align-items: center;
329
+ margin-bottom: 10px;
330
+ .back-arrow {
331
+ font-size: 24px;
332
+ cursor: pointer;
333
+ }
334
+ `