ordering-ui-external 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_bundles/{0.ordering-ui.32113e17b220a7b5ae09.js → 0.ordering-ui.a228aa8797d9d0fc5a6c.js} +0 -0
- package/_bundles/{1.ordering-ui.32113e17b220a7b5ae09.js → 1.ordering-ui.a228aa8797d9d0fc5a6c.js} +0 -0
- package/_bundles/{2.ordering-ui.32113e17b220a7b5ae09.js → 2.ordering-ui.a228aa8797d9d0fc5a6c.js} +0 -0
- package/_bundles/{4.ordering-ui.32113e17b220a7b5ae09.js → 4.ordering-ui.a228aa8797d9d0fc5a6c.js} +0 -0
- package/_bundles/{5.ordering-ui.32113e17b220a7b5ae09.js → 5.ordering-ui.a228aa8797d9d0fc5a6c.js} +0 -0
- package/_bundles/{6.ordering-ui.32113e17b220a7b5ae09.js → 6.ordering-ui.a228aa8797d9d0fc5a6c.js} +0 -0
- package/_bundles/{7.ordering-ui.32113e17b220a7b5ae09.js → 7.ordering-ui.a228aa8797d9d0fc5a6c.js} +1 -1
- package/_bundles/{7.ordering-ui.32113e17b220a7b5ae09.js.LICENSE.txt → 7.ordering-ui.a228aa8797d9d0fc5a6c.js.LICENSE.txt} +0 -0
- package/_bundles/{8.ordering-ui.32113e17b220a7b5ae09.js → 8.ordering-ui.a228aa8797d9d0fc5a6c.js} +0 -0
- package/_bundles/{9.ordering-ui.32113e17b220a7b5ae09.js → 9.ordering-ui.a228aa8797d9d0fc5a6c.js} +0 -0
- package/_bundles/ordering-ui.a228aa8797d9d0fc5a6c.js +2 -0
- package/_bundles/{ordering-ui.32113e17b220a7b5ae09.js.LICENSE.txt → ordering-ui.a228aa8797d9d0fc5a6c.js.LICENSE.txt} +0 -0
- package/_modules/themes/callcenterOriginal/index.js +7 -0
- package/_modules/themes/callcenterOriginal/src/components/Cart/index.js +46 -32
- package/_modules/themes/callcenterOriginal/src/components/Cart/styles.js +1 -1
- package/_modules/themes/callcenterOriginal/src/components/CartContent/index.js +53 -21
- package/_modules/themes/callcenterOriginal/src/components/CartContent/styles.js +6 -4
- package/_modules/themes/callcenterOriginal/src/components/CartPopover/index.js +5 -19
- package/_modules/themes/callcenterOriginal/src/components/Header/index.js +3 -21
- package/_modules/themes/callcenterOriginal/src/components/Header/styles.js +2 -2
- package/_modules/themes/five/src/components/BusinessProductsListing/index.js +1 -0
- package/_modules/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +13 -8
- package/_modules/themes/five/src/components/Cart/index.js +1 -1
- package/_modules/themes/five/src/components/RenderProductsLayout/index.js +1 -1
- package/package.json +2 -2
- package/src/themes/callcenterOriginal/index.js +2 -0
- package/src/themes/callcenterOriginal/src/components/Cart/index.js +321 -307
- package/src/themes/callcenterOriginal/src/components/Cart/styles.js +1 -1
- package/src/themes/callcenterOriginal/src/components/CartContent/index.js +69 -50
- package/src/themes/callcenterOriginal/src/components/CartContent/styles.js +6 -0
- package/src/themes/callcenterOriginal/src/components/CartPopover/index.js +20 -32
- package/src/themes/callcenterOriginal/src/components/Header/index.js +276 -292
- package/src/themes/callcenterOriginal/src/components/Header/styles.js +19 -1
- package/src/themes/five/src/components/BusinessProductsListing/index.js +1 -0
- package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/index.js +5 -1
- package/src/themes/five/src/components/Cart/index.js +1 -1
- package/src/themes/five/src/components/RenderProductsLayout/index.js +1 -1
- package/_bundles/ordering-ui.32113e17b220a7b5ae09.js +0 -2
|
@@ -1,13 +1,15 @@
|
|
|
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
|
-
import { Cart } from '
|
|
6
|
+
import { Cart } from '../../../../five/src/components/Cart'
|
|
7
|
+
import { Button } from '../../styles/Buttons'
|
|
7
8
|
|
|
8
9
|
export const CartContent = (props) => {
|
|
9
10
|
const {
|
|
10
11
|
carts,
|
|
12
|
+
isOpenCart,
|
|
11
13
|
isOrderStateCarts,
|
|
12
14
|
isCartPopover,
|
|
13
15
|
isForceOpenCart,
|
|
@@ -17,8 +19,11 @@ export const CartContent = (props) => {
|
|
|
17
19
|
const [, t] = useLanguage()
|
|
18
20
|
const theme = useTheme()
|
|
19
21
|
const [events] = useEvent()
|
|
22
|
+
const [orderState] = useOrder()
|
|
23
|
+
const [{ configs }] = useConfig()
|
|
20
24
|
|
|
21
25
|
const [currentCartUuid, setCurrentCartUuid] = useState(null)
|
|
26
|
+
const checkoutMultiBusinessEnabled = configs?.checkout_multi_business_enabled?.value === '1'
|
|
22
27
|
|
|
23
28
|
const handleAddProduct = (product, cart) => {
|
|
24
29
|
setCurrentCartUuid(cart?.uuid)
|
|
@@ -28,6 +33,36 @@ export const CartContent = (props) => {
|
|
|
28
33
|
setCurrentCartUuid(null)
|
|
29
34
|
}
|
|
30
35
|
|
|
36
|
+
const handleClickCheckout = () => {
|
|
37
|
+
const cartsAvailable = Object.values(orderState?.carts)?.filter(cart => cart?.valid && cart?.status !== 2)
|
|
38
|
+
if (cartsAvailable.length === 1) {
|
|
39
|
+
events.emit('go_to_page', { page: 'checkout', params: { cartUuid: cartsAvailable[0]?.uuid } })
|
|
40
|
+
} else {
|
|
41
|
+
const groupKeys = {}
|
|
42
|
+
cartsAvailable.forEach(_cart => {
|
|
43
|
+
groupKeys[_cart?.group?.uuid]
|
|
44
|
+
? groupKeys[_cart?.group?.uuid] += 1
|
|
45
|
+
: groupKeys[_cart?.group?.uuid ?? 'null'] = 1
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
if (
|
|
49
|
+
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
50
|
+
Object.keys(groupKeys).length > 1
|
|
51
|
+
) {
|
|
52
|
+
events.emit('go_to_page', { page: 'multi_cart' })
|
|
53
|
+
} else {
|
|
54
|
+
events.emit('go_to_page', {
|
|
55
|
+
page: 'multi_checkout',
|
|
56
|
+
params: {
|
|
57
|
+
cartUuid: cartsAvailable[0]?.group?.uuid
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
events.emit('cart_popover_closed')
|
|
63
|
+
props.onClose && props.onClose()
|
|
64
|
+
}
|
|
65
|
+
|
|
31
66
|
useEffect(() => {
|
|
32
67
|
events.on('cart_popover_closed', handleSetCurrentCartUuid)
|
|
33
68
|
events.on('cart_product_added', handleAddProduct)
|
|
@@ -38,54 +73,38 @@ export const CartContent = (props) => {
|
|
|
38
73
|
}, [])
|
|
39
74
|
|
|
40
75
|
return (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
props.beforeElements?.map((BeforeElement, i) => (
|
|
44
|
-
<React.Fragment key={i}>
|
|
45
|
-
{BeforeElement}
|
|
46
|
-
</React.Fragment>))
|
|
47
|
-
}
|
|
48
|
-
{
|
|
49
|
-
props.beforeComponents?.map((BeforeComponent, i) => (
|
|
50
|
-
<BeforeComponent key={i} {...props} />))
|
|
51
|
-
}
|
|
52
|
-
<Container>
|
|
76
|
+
<Container>
|
|
77
|
+
<WrapperContainer>
|
|
53
78
|
<Title>{t('YOUR_CART', 'Your cart')}</Title>
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
<React.Fragment key={cart.uuid}>
|
|
57
|
-
{cart.products.length > 0 && (
|
|
58
|
-
<Cart
|
|
59
|
-
isCartPending={cart?.status === 2}
|
|
60
|
-
cart={cart}
|
|
61
|
-
isCartPopover={isCartPopover}
|
|
62
|
-
isCheckout={window.location.pathname === `/checkout/${cart?.uuid}`}
|
|
63
|
-
isForceOpenCart={isForceOpenCart}
|
|
64
|
-
currentCartUuid={currentCartUuid}
|
|
65
|
-
isProducts={cart.products.length}
|
|
66
|
-
onClickCheckout={props.onClose}
|
|
67
|
-
setPreorderBusiness={setPreorderBusiness}
|
|
68
|
-
/>
|
|
69
|
-
)}
|
|
70
|
-
</React.Fragment>
|
|
71
|
-
))}
|
|
72
|
-
{(!carts || carts?.length === 0) && (
|
|
73
|
-
<NotCarts>
|
|
74
|
-
<img src={theme.images?.general?.notFound} alt='Not Found' width='200px' height='122px' loading='lazy' />
|
|
75
|
-
<h1>{t('NO_PRODUCTS_TO_CART', 'You have no products added to the cart')}</h1>
|
|
76
|
-
</NotCarts>
|
|
79
|
+
{checkoutMultiBusinessEnabled && carts?.length > 0 && (
|
|
80
|
+
<Button onClick={handleClickCheckout} color='primary'>{t('CHECKOUT', 'Checkout')}</Button>
|
|
77
81
|
)}
|
|
78
|
-
</
|
|
79
|
-
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
</WrapperContainer>
|
|
83
|
+
{isOrderStateCarts && carts?.length > 0 &&
|
|
84
|
+
carts.map(cart => (
|
|
85
|
+
<React.Fragment key={cart.uuid}>
|
|
86
|
+
{cart.products.length > 0 && (
|
|
87
|
+
<Cart
|
|
88
|
+
isCartPending={cart?.status === 2}
|
|
89
|
+
cart={cart}
|
|
90
|
+
isOpenCart={isOpenCart}
|
|
91
|
+
isCartPopover={isCartPopover}
|
|
92
|
+
isCheckout={window.location.pathname === `/checkout/${cart?.uuid}`}
|
|
93
|
+
isForceOpenCart={isForceOpenCart}
|
|
94
|
+
currentCartUuid={currentCartUuid}
|
|
95
|
+
isProducts={cart.products.length}
|
|
96
|
+
onClickCheckout={props.onClose}
|
|
97
|
+
setPreorderBusiness={setPreorderBusiness}
|
|
98
|
+
/>
|
|
99
|
+
)}
|
|
100
|
+
</React.Fragment>
|
|
101
|
+
))}
|
|
102
|
+
{(!carts || carts?.length === 0) && (
|
|
103
|
+
<NotCarts>
|
|
104
|
+
<img src={theme.images?.general?.notFound} alt='Not Found' width='200px' height='122px' loading='lazy' />
|
|
105
|
+
<h1>{t('NO_PRODUCTS_TO_CART', 'You have no products added to the cart')}</h1>
|
|
106
|
+
</NotCarts>
|
|
107
|
+
)}
|
|
108
|
+
</Container>
|
|
90
109
|
)
|
|
91
110
|
}
|
|
@@ -86,37 +86,25 @@ export const CartPopover = (props) => {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
|
-
|
|
90
|
-
{props.
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
setPreorderBusiness={setPreorderBusiness}
|
|
110
|
-
/>
|
|
111
|
-
<PopoverArrow key='arrow' ref={arrowElement} style={styles.arrow} />
|
|
112
|
-
</PopoverBody>
|
|
113
|
-
</div>
|
|
114
|
-
{props.afterComponents?.map((AfterComponent, i) => (
|
|
115
|
-
<AfterComponent key={i} {...props} />))}
|
|
116
|
-
{props.afterElements?.map((AfterElement, i) => (
|
|
117
|
-
<React.Fragment key={i}>
|
|
118
|
-
{AfterElement}
|
|
119
|
-
</React.Fragment>))}
|
|
120
|
-
</>
|
|
89
|
+
<div style={{ overflow: 'hidden' }}>
|
|
90
|
+
<HeaderItem ref={referenceElement} onClick={props.onClick} name='cart-popover'>
|
|
91
|
+
<span>
|
|
92
|
+
<Cart3 />
|
|
93
|
+
{props.carts?.length > 0 && <span>{props.carts?.length}</span>}
|
|
94
|
+
</span>
|
|
95
|
+
</HeaderItem>
|
|
96
|
+
<PopoverBody className='cart-popover' ref={popperElement} style={popStyle} {...attributes.popper}>
|
|
97
|
+
<CartContent
|
|
98
|
+
isCartPopover
|
|
99
|
+
isOpenCart={open}
|
|
100
|
+
onClick={props.onClick}
|
|
101
|
+
carts={props.carts}
|
|
102
|
+
isOrderStateCarts={!!orderState.carts}
|
|
103
|
+
onClose={props.onClose}
|
|
104
|
+
setPreorderBusiness={setPreorderBusiness}
|
|
105
|
+
/>
|
|
106
|
+
<PopoverArrow key='arrow' ref={arrowElement} style={styles.arrow} />
|
|
107
|
+
</PopoverBody>
|
|
108
|
+
</div>
|
|
121
109
|
)
|
|
122
110
|
}
|