ordering-ui-external 2.4.3 → 2.4.5

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 (28) hide show
  1. package/_bundles/{7.ordering-ui.d43a68e386178f10fff2.js → 7.ordering-ui.83ddb51fdc85c2b920b0.js} +1 -1
  2. package/_bundles/ordering-ui.83ddb51fdc85c2b920b0.js +2 -0
  3. package/_modules/themes/five/src/components/Cart/index.js +12 -29
  4. package/_modules/themes/five/src/components/CartContent/index.js +25 -7
  5. package/_modules/themes/five/src/components/CartContent/styles.js +7 -3
  6. package/_modules/themes/five/src/components/Checkout/index.js +7 -7
  7. package/_modules/themes/five/src/components/MultiCheckout/index.js +9 -7
  8. package/_modules/themes/five/src/components/OrderDetails/OrderEta.js +8 -7
  9. package/_modules/utils/index.js +25 -2
  10. package/package.json +2 -2
  11. package/src/themes/five/src/components/Cart/index.js +11 -17
  12. package/src/themes/five/src/components/CartContent/index.js +58 -22
  13. package/src/themes/five/src/components/CartContent/styles.js +26 -0
  14. package/src/themes/five/src/components/Checkout/index.js +1 -1
  15. package/src/themes/five/src/components/MultiCheckout/index.js +7 -6
  16. package/src/themes/five/src/components/OrderDetails/OrderEta.js +6 -5
  17. package/src/utils/index.js +20 -0
  18. package/_bundles/ordering-ui.d43a68e386178f10fff2.js +0 -2
  19. /package/_bundles/{0.ordering-ui.d43a68e386178f10fff2.js → 0.ordering-ui.83ddb51fdc85c2b920b0.js} +0 -0
  20. /package/_bundles/{1.ordering-ui.d43a68e386178f10fff2.js → 1.ordering-ui.83ddb51fdc85c2b920b0.js} +0 -0
  21. /package/_bundles/{2.ordering-ui.d43a68e386178f10fff2.js → 2.ordering-ui.83ddb51fdc85c2b920b0.js} +0 -0
  22. /package/_bundles/{4.ordering-ui.d43a68e386178f10fff2.js → 4.ordering-ui.83ddb51fdc85c2b920b0.js} +0 -0
  23. /package/_bundles/{5.ordering-ui.d43a68e386178f10fff2.js → 5.ordering-ui.83ddb51fdc85c2b920b0.js} +0 -0
  24. /package/_bundles/{6.ordering-ui.d43a68e386178f10fff2.js → 6.ordering-ui.83ddb51fdc85c2b920b0.js} +0 -0
  25. /package/_bundles/{7.ordering-ui.d43a68e386178f10fff2.js.LICENSE.txt → 7.ordering-ui.83ddb51fdc85c2b920b0.js.LICENSE.txt} +0 -0
  26. /package/_bundles/{8.ordering-ui.d43a68e386178f10fff2.js → 8.ordering-ui.83ddb51fdc85c2b920b0.js} +0 -0
  27. /package/_bundles/{9.ordering-ui.d43a68e386178f10fff2.js → 9.ordering-ui.83ddb51fdc85c2b920b0.js} +0 -0
  28. /package/_bundles/{ordering-ui.d43a68e386178f10fff2.js.LICENSE.txt → ordering-ui.83ddb51fdc85c2b920b0.js.LICENSE.txt} +0 -0
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import { useTheme } from 'styled-components'
3
- import { useLanguage, useEvent, useConfig, useOrder } from 'ordering-components-external'
4
- import { Container, NotCarts, Title, WrapperContainer } from './styles'
3
+ import { useLanguage, useEvent, useConfig, useOrder, useUtils } from 'ordering-components-external'
4
+ import { Container, MultiCartPriceContainer, NotCarts, Title, WrapperContainer } from './styles'
5
5
 
6
6
  import { Cart } from '../Cart'
7
7
  import { Button } from '../../styles/Buttons'
@@ -21,11 +21,17 @@ export const CartContent = (props) => {
21
21
  const theme = useTheme()
22
22
  const [events] = useEvent()
23
23
  const [orderState] = useOrder()
24
+ const [{ parsePrice }] = useUtils()
24
25
  const [{ configs }] = useConfig()
25
26
 
26
27
  const [currentCartUuid, setCurrentCartUuid] = useState(null)
27
28
  const checkoutMultiBusinessEnabled = configs?.checkout_multi_business_enabled?.value === '1'
28
29
 
30
+ const totalCartsPrice = carts?.length && carts.reduce((total, cart) => { return total + cart?.total }, 0)
31
+ const totalCartsFee = carts?.length && carts
32
+ ?.filter((cart) => cart?.status !== 1 && cart?.valid)
33
+ ?.reduce((total, cart) => { return total + (cart?.delivery_price_with_discount) }, 0)
34
+
29
35
  const handleAddProduct = (product, cart) => {
30
36
  setCurrentCartUuid(cart?.uuid)
31
37
  }
@@ -85,26 +91,56 @@ export const CartContent = (props) => {
85
91
  )}
86
92
  </WrapperContainer>
87
93
  )}
88
- {isOrderStateCarts && carts?.length > 0 &&
89
- carts.map(cart => (
90
- <React.Fragment key={cart.uuid}>
91
- {cart.products.length > 0 && (
92
- <Cart
93
- isCartPending={cart?.status === 2}
94
- cart={cart}
95
- isCartPopover={isCartPopover}
96
- isCheckout={window.location.pathname === `/checkout/${cart?.uuid}` && !isCartPopover}
97
- isForceOpenCart={isForceOpenCart}
98
- currentCartUuid={currentCartUuid}
99
- isProducts={cart.products.length}
100
- onClickCheckout={props.onClose}
101
- setPreorderBusiness={setPreorderBusiness}
102
- isOpenCart={isOpenCart}
103
- businessConfigs={cart?.business?.configs}
104
- />
105
- )}
106
- </React.Fragment>
107
- ))}
94
+ {isOrderStateCarts && carts?.length > 0 && (
95
+ <>
96
+ {carts.map(cart => (
97
+ <React.Fragment key={cart.uuid}>
98
+ {cart.products.length > 0 && (
99
+ <Cart
100
+ cart={cart}
101
+ isCartPending={cart?.status === 2}
102
+ isOpenCart={isOpenCart}
103
+ isCartPopover={isCartPopover}
104
+ isCheckout={window.location.pathname === `/checkout/${cart?.uuid}` && !isCartPopover}
105
+ isForceOpenCart={isForceOpenCart}
106
+ currentCartUuid={currentCartUuid}
107
+ isProducts={cart.products.length}
108
+ onClickCheckout={props.onClose}
109
+ setPreorderBusiness={setPreorderBusiness}
110
+ businessConfigs={cart?.business?.configs}
111
+ hideCouponInput={configs?.multi_business_checkout_coupon_input_style?.value === 'group'}
112
+ hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
113
+ hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
114
+ />
115
+ )}
116
+ </React.Fragment>
117
+ ))}
118
+ {checkoutMultiBusinessEnabled && !!carts.length && (
119
+ <MultiCartPriceContainer>
120
+ {!!totalCartsFee &&
121
+ configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' &&
122
+ (
123
+ <span>
124
+ <p>{t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}</p>
125
+ <p>{parsePrice(totalCartsFee)}</p>
126
+ </span>
127
+ )}
128
+ {carts.reduce((sum, cart) => sum + cart?.driver_tip, 0) > 0 &&
129
+ configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' &&
130
+ (
131
+ <span>
132
+ <p>{t('DRIVER_TIP', 'Driver tip')}</p>
133
+ <p>{parsePrice(carts.reduce((sum, cart) => sum + cart?.driver_tip, 0))}</p>
134
+ </span>
135
+ )}
136
+ <div>
137
+ <h4>{t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}</h4>
138
+ <h4>{parsePrice(totalCartsPrice)}</h4>
139
+ </div>
140
+ </MultiCartPriceContainer>
141
+ )}
142
+ </>
143
+ )}
108
144
  {(!carts || carts?.length === 0) && (
109
145
  <NotCarts>
110
146
  <img src={theme.images?.general?.notFound} alt='Not Found' width='200px' height='122px' loading='lazy' />
@@ -54,3 +54,29 @@ export const Title = styled.h1`
54
54
  text-align: left;
55
55
  }
56
56
  `
57
+
58
+ export const MultiCartPriceContainer = styled.div`
59
+ margin-top: 38px;
60
+ > div {
61
+ display: flex;
62
+ align-items: center;
63
+ justify-content: space-between;
64
+ margin-top: 5px;
65
+ margin-bottom: 5px;
66
+ > h4 {
67
+ font-size: 18px;
68
+ margin: 0;
69
+ }
70
+ }
71
+ > span {
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: space-between;
75
+ margin-bottom: 5px;
76
+ }
77
+ p {
78
+ font-size: 14px;
79
+ color: ${props => props.theme.colors.darkGray};
80
+ margin: 0;
81
+ }
82
+ `
@@ -341,7 +341,7 @@ const CheckoutUI = (props) => {
341
341
  </div>
342
342
  ) : (
343
343
  <AddressDetails
344
- location={businessDetails?.business?.location}
344
+ location={options?.address?.location}
345
345
  businessLogo={businessDetails?.business?.logo || theme.images?.dummies?.businessLogo}
346
346
  isCartPending={cart?.status === 2}
347
347
  businessId={cart?.business_id}
@@ -108,7 +108,7 @@ const MultiCheckoutUI = (props) => {
108
108
 
109
109
  const getIncludedTaxes = (cart) => {
110
110
  if (cart?.taxes === null || !cart?.taxes) {
111
- return cart.business.tax_type === 1 ? cart?.tax : 0
111
+ return cart?.business?.tax_type === 1 ? cart?.tax : 0
112
112
  } else {
113
113
  return cart?.taxes.reduce((taxIncluded, tax) => {
114
114
  return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
@@ -116,11 +116,12 @@ const MultiCheckoutUI = (props) => {
116
116
  }
117
117
  }
118
118
 
119
- const loyaltyRewardValue = creditPointPlanOnBusiness?.accumulation_rate
120
- ? Math.round(
121
- openCarts.reduce((sum, cart) => sum + cart?.subtotal + getIncludedTaxes(cart), 0) /
122
- creditPointPlanOnBusiness?.accumulation_rate
123
- ) : 0
119
+ const subtotalAmount = openCarts.reduce((sum, cart) => sum + (cart?.subtotal + getIncludedTaxes(cart)), 0) *
120
+ creditPointPlanOnBusiness?.accumulation_rate
121
+
122
+ const loyaltyRewardValue = (creditPointPlanOnBusiness?.accumulation_rate
123
+ ? (Math.trunc(subtotalAmount * 100) / 100).toFixed(configs.format_number_decimal_length?.value ?? 2)
124
+ : 0)
124
125
 
125
126
  const handlePlaceOrder = () => {
126
127
  if (!userErrors.length) {
@@ -8,7 +8,7 @@ export const OrderEta = (props) => {
8
8
  outputFormat
9
9
  } = props
10
10
 
11
- const [{ parseTime }] = useUtils()
11
+ const [{ parseDate }] = useUtils()
12
12
  const [estimatedDeliveryTime, setEstimatedDeliveryTime] = useState(null)
13
13
 
14
14
  const getEstimatedDeliveryTime = () => {
@@ -36,10 +36,11 @@ export const OrderEta = (props) => {
36
36
  if (diffTimeAsMinutes <= 0) {
37
37
  totalEta += (Math.floor(Math.abs(diffTimeAsMinutes / order?.eta_current_status_time) + 1) * order?.eta_current_status_penalty_time)
38
38
  }
39
- _estimatedTime = moment(_delivery).add(totalEta, 'minutes')
39
+ _estimatedTime = moment.utc(_delivery).add(totalEta, 'minutes')
40
40
  } else {
41
- _estimatedTime = moment(_delivery).add(order?.eta_time, 'minutes')
41
+ _estimatedTime = moment.utc(_delivery).add(order?.eta_time, 'minutes')
42
42
  }
43
+ _estimatedTime = outputFormat ? moment(_estimatedTime).format(outputFormat) : parseDate(_estimatedTime, { utc: false })
43
44
  setEstimatedDeliveryTime(_estimatedTime)
44
45
  }
45
46
 
@@ -49,11 +50,11 @@ export const OrderEta = (props) => {
49
50
  getEstimatedDeliveryTime()
50
51
  }, 1000)
51
52
  return () => clearInterval(interval)
52
- }, [order])
53
+ }, [order, outputFormat])
53
54
 
54
55
  return (
55
56
  <>
56
- {!outputFormat ? parseTime(estimatedDeliveryTime) : parseTime(estimatedDeliveryTime, { outputFormat: 'hh:mm A' })}
57
+ {estimatedDeliveryTime}
57
58
  </>
58
59
  )
59
60
  }
@@ -676,3 +676,23 @@ export const calendarLanguages = {
676
676
  Su: 'DAYMIN7'
677
677
  }
678
678
  }
679
+
680
+ export const getCateringValues = (cateringTypeString, configs) => {
681
+ const splitCateringValue = (configName) => Object.values(configs || {})
682
+ ?.find(config => config?.key === configName)
683
+ ?.value?.split('|')
684
+ ?.find(val => val.includes(cateringTypeString))?.split(',')[1]
685
+ const preorderSlotInterval = parseInt(splitCateringValue('preorder_slot_interval'))
686
+ const preorderLeadTime = parseInt(splitCateringValue('preorder_lead_time'))
687
+ const preorderTimeRange = parseInt(splitCateringValue('preorder_time_range'))
688
+ const preorderMaximumDays = parseInt(splitCateringValue('preorder_maximum_days'))
689
+ const preorderMinimumDays = parseInt(splitCateringValue('preorder_minimum_days'))
690
+
691
+ return {
692
+ preorderSlotInterval,
693
+ preorderLeadTime,
694
+ preorderTimeRange,
695
+ preorderMaximumDays,
696
+ preorderMinimumDays
697
+ }
698
+ }