ordering-ui-react-native 0.17.85 → 0.17.87

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 (33) hide show
  1. package/package.json +1 -1
  2. package/themes/business/src/components/MapView/index.tsx +2 -2
  3. package/themes/business/src/components/ProductItemAccordion/index.tsx +21 -3
  4. package/themes/original/src/components/AddressForm/index.tsx +26 -22
  5. package/themes/original/src/components/BusinessBasicInformation/index.tsx +91 -70
  6. package/themes/original/src/components/BusinessController/index.tsx +71 -49
  7. package/themes/original/src/components/BusinessProductsListing/index.tsx +32 -44
  8. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +48 -30
  9. package/themes/original/src/components/Cart/index.tsx +36 -71
  10. package/themes/original/src/components/CartContent/index.tsx +47 -2
  11. package/themes/original/src/components/CartContent/styles.tsx +10 -0
  12. package/themes/original/src/components/Checkout/index.tsx +40 -32
  13. package/themes/original/src/components/Messages/index.tsx +8 -7
  14. package/themes/original/src/components/MultiCart/index.tsx +41 -54
  15. package/themes/original/src/components/MultiCheckout/index.tsx +2 -7
  16. package/themes/original/src/components/MyOrders/index.tsx +9 -7
  17. package/themes/original/src/components/OrderDetails/index.tsx +99 -73
  18. package/themes/original/src/components/OrderTypeSelector/index.tsx +6 -4
  19. package/themes/original/src/components/PageBanner/index.tsx +60 -33
  20. package/themes/original/src/components/PageBanner/styles.tsx +0 -7
  21. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +1 -1
  22. package/themes/original/src/components/ProductForm/index.tsx +2 -2
  23. package/themes/original/src/components/SingleOrderCard/index.tsx +58 -44
  24. package/themes/original/src/components/SingleProductCard/index.tsx +51 -21
  25. package/themes/original/src/components/SingleProductCard/styles.tsx +11 -1
  26. package/themes/original/src/components/StripeCardsList/index.tsx +1 -1
  27. package/themes/original/src/components/UpsellingProducts/index.tsx +243 -216
  28. package/themes/original/src/components/UpsellingProducts/styles.tsx +12 -1
  29. package/themes/original/src/components/UserProfile/index.tsx +82 -53
  30. package/themes/original/src/components/shared/OButton.tsx +5 -1
  31. package/themes/original/src/components/shared/OInput.tsx +8 -2
  32. package/themes/original/src/types/index.tsx +3 -0
  33. package/themes/original/src/utils/index.tsx +11 -0
@@ -1,244 +1,271 @@
1
1
  import React, { useState, useEffect } from 'react'
2
2
  import { Platform, StyleSheet, TouchableOpacity, View } from 'react-native'
3
3
  import {
4
- UpsellingPage as UpsellingPageController,
5
- useUtils,
6
- useLanguage,
7
- useOrder
4
+ UpsellingPage as UpsellingPageController,
5
+ useUtils,
6
+ useLanguage,
7
+ useOrder,
8
+ useConfig
8
9
  } from 'ordering-components/native'
9
10
  import { useTheme } from 'styled-components/native';
10
11
  import { OText, OIcon, OBottomPopup, OButton } from '../shared'
11
12
  import { UpsellingProductsParams } from '../../types'
12
13
  import {
13
- Container,
14
- UpsellingContainer,
15
- Item,
16
- Details,
17
- AddButton,
18
- TopBar,
19
- TopActions
14
+ Container,
15
+ UpsellingContainer,
16
+ Item,
17
+ Details,
18
+ AddButton,
19
+ CartList,
20
+ CartDivider
20
21
  } from './styles'
21
22
  import { OrderSummary } from '../OrderSummary';
23
+ import { Cart } from '../Cart';
22
24
  import { ScrollView } from 'react-native-gesture-handler';
23
25
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
24
26
 
25
27
  const UpsellingProductsUI = (props: UpsellingProductsParams) => {
26
- const {
27
- isCustomMode,
28
- upsellingProducts,
29
- business,
30
- handleUpsellingPage,
31
- handleCloseUpsellingPage,
32
- openUpselling,
33
- canOpenUpselling,
34
- setCanOpenUpselling,
35
- isFromCart,
36
- onNavigationRedirect,
37
- onGoBack
38
- } = props
28
+ const {
29
+ isCustomMode,
30
+ upsellingProducts,
31
+ business,
32
+ handleUpsellingPage,
33
+ handleCloseUpsellingPage,
34
+ openUpselling,
35
+ canOpenUpselling,
36
+ setCanOpenUpselling,
37
+ isFromCart,
38
+ onNavigationRedirect,
39
+ onGoBack
40
+ } = props
39
41
 
40
- const theme = useTheme();
42
+ const theme = useTheme();
41
43
 
42
- const styles = StyleSheet.create({
43
- imageStyle: {
44
- width: 73,
45
- height: 73,
46
- resizeMode: 'cover',
47
- borderRadius: 7.6,
48
- },
49
- closeUpsellingButton: {
50
- borderRadius: 7.6,
51
- borderColor: theme.colors.primary,
52
- backgroundColor: theme.colors.primary,
53
- borderWidth: 1,
54
- alignSelf: 'center',
55
- height: 44,
56
- shadowOpacity: 0,
57
- width: '80%',
58
- },
59
- cancelBtn: {
60
- paddingHorizontal: 18,
61
- borderWidth: 1,
62
- borderRadius: 7.6,
63
- borderColor: theme.colors.textSecondary,
64
- height: 38
65
- },
66
- headerItem: {
67
- flexDirection: 'row',
68
- alignItems: 'center',
69
- marginVertical: 2,
70
- marginHorizontal: 20,
71
- },
72
- btnBackArrow: {
73
- borderWidth: 0,
74
- width: 26,
75
- height: 26,
76
- backgroundColor: theme.colors.clear,
77
- borderColor: theme.colors.clear,
78
- shadowColor: theme.colors.clear,
79
- paddingLeft: 0,
80
- paddingRight: 0,
81
- marginLeft: 20,
82
- marginBottom: 10
83
- },
84
- })
44
+ const styles = StyleSheet.create({
45
+ imageStyle: {
46
+ width: 73,
47
+ height: 73,
48
+ resizeMode: 'cover',
49
+ borderRadius: 7.6,
50
+ },
51
+ closeUpsellingButton: {
52
+ borderRadius: 7.6,
53
+ borderColor: theme.colors.primary,
54
+ backgroundColor: theme.colors.primary,
55
+ borderWidth: 1,
56
+ alignSelf: 'center',
57
+ height: 44,
58
+ shadowOpacity: 0,
59
+ width: '80%',
60
+ },
61
+ cancelBtn: {
62
+ paddingHorizontal: 18,
63
+ borderWidth: 1,
64
+ borderRadius: 7.6,
65
+ borderColor: theme.colors.textSecondary,
66
+ height: 38
67
+ },
68
+ headerItem: {
69
+ flexDirection: 'row',
70
+ alignItems: 'center',
71
+ marginVertical: 2,
72
+ marginHorizontal: 20,
73
+ },
74
+ btnBackArrow: {
75
+ borderWidth: 0,
76
+ width: 26,
77
+ height: 26,
78
+ backgroundColor: theme.colors.clear,
79
+ borderColor: theme.colors.clear,
80
+ shadowColor: theme.colors.clear,
81
+ paddingLeft: 0,
82
+ paddingRight: 0,
83
+ marginLeft: 20,
84
+ marginBottom: 10
85
+ },
86
+ })
85
87
 
86
- const [modalIsOpen, setModalIsOpen] = useState(false)
87
- const [{ carts }] = useOrder()
88
- const [{ parsePrice }] = useUtils()
89
- const [, t] = useLanguage()
90
- const { bottom } = useSafeAreaInsets()
91
- const [isCheckout, setIsCheckout] = useState(false)
88
+ const [modalIsOpen, setModalIsOpen] = useState(false)
89
+ const [{ carts }] = useOrder()
90
+ const [{ parsePrice }] = useUtils()
91
+ const [{ configs }] = useConfig()
92
+ const [, t] = useLanguage()
93
+ const { bottom } = useSafeAreaInsets()
94
+ const [isCheckout, setIsCheckout] = useState(false)
95
+ const [isCartsLoading, setIsCartsLoading] = useState(false)
92
96
 
93
- const cart = carts?.[`businessId:${props.businessId}`] ?? {}
94
- const cartProducts = cart?.products?.length
95
- ? cart?.products.map((product: any) => product.id)
96
- : []
97
+ const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
98
+ const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
99
+ const showCartList = isChewLayout
100
+ const commentDelayTime = isChewLayout ? 500 : null
97
101
 
98
- const productsList = !upsellingProducts.loading && !upsellingProducts.error
99
- ? upsellingProducts?.products?.length
100
- ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
101
- : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
102
- : []
102
+ const cart = carts?.[`businessId:${props.businessId}`] ?? {}
103
+ const cartList = (carts && Object.values(carts).filter((_cart: any) => _cart?.products?.length > 0 && _cart.uuid !== cart?.uuid)) || []
104
+ const cartProducts = cart?.products?.length
105
+ ? cart?.products.map((product: any) => product.id)
106
+ : []
103
107
 
104
- useEffect(() => {
105
- if (!isCustomMode && !props.products) {
106
- if (!upsellingProducts.loading) {
107
- if (upsellingProducts?.products?.length && !isFromCart) {
108
- setCanOpenUpselling && setCanOpenUpselling(true)
109
- } else {
110
- handleUpsellingPage && handleUpsellingPage()
111
- }
112
- }
113
- }
114
- }, [upsellingProducts.loading, upsellingProducts?.products.length])
108
+ const productsList = !upsellingProducts.loading && !upsellingProducts.error
109
+ ? upsellingProducts?.products?.length
110
+ ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
111
+ : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
112
+ : []
115
113
 
116
- const handleFormProduct = (product: any) => {
117
- onNavigationRedirect && onNavigationRedirect('ProductDetails', {
118
- product: product,
119
- businessId: product?.api?.businessId,
120
- businessSlug: business.slug,
121
- })
122
- }
114
+ useEffect(() => {
115
+ if (!isCustomMode && !props.products) {
116
+ if (!upsellingProducts.loading) {
117
+ if (upsellingProducts?.products?.length && !isFromCart) {
118
+ setCanOpenUpselling && setCanOpenUpselling(true)
119
+ } else {
120
+ handleUpsellingPage && handleUpsellingPage()
121
+ }
122
+ }
123
+ }
124
+ }, [upsellingProducts.loading, upsellingProducts?.products.length])
123
125
 
124
- const UpsellingLayout = () => {
125
- return (
126
- <Container>
127
- <UpsellingContainer
128
- horizontal
129
- showsHorizontalScrollIndicator={false}
130
- contentContainerStyle={{ paddingHorizontal: Platform.OS === 'ios' ? 40 : 0 }}
131
- >
132
- {
133
- !upsellingProducts.loading && (
134
- <>
135
- {
136
- !upsellingProducts.error ? productsList.map((product: any, i: number) => (
137
- <Item key={`${product.id}_${i}`}>
138
- <View style={{ flexBasis: '57%' }}>
139
- <Details>
140
- <OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
141
- <OText size={12} lineHeight={18} color={theme.colors.textNormal}>{parsePrice(product.price)}</OText>
142
- </Details>
143
- <AddButton onPress={() => handleFormProduct(product)}>
144
- <OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
145
- </AddButton>
146
- </View>
147
- <View>
148
- <OIcon url={product?.images || theme?.images?.dummies?.product} style={styles.imageStyle} />
149
- </View>
150
- </Item>
151
- )) : (
152
- <OText>
153
- {upsellingProducts.message}
154
- </OText>
155
- )
156
- }
157
- </>
158
- )
159
- }
160
- </UpsellingContainer>
161
- </Container>
162
- )
163
- }
126
+ const handleFormProduct = (product: any) => {
127
+ onNavigationRedirect && onNavigationRedirect('ProductDetails', {
128
+ product: product,
129
+ businessId: product?.api?.businessId,
130
+ businessSlug: business.slug,
131
+ })
132
+ }
164
133
 
165
- const UpsellingContent = () => {
166
- return (
167
- <>
168
- <View style={{ ...styles.headerItem, flex: 1, marginTop: Platform.OS == 'ios' ? 35 : 14 }}>
169
- <TouchableOpacity onPress={() => onGoBack()} style={styles.btnBackArrow}>
170
- <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
171
- </TouchableOpacity>
172
- </View>
173
- <ScrollView style={{ marginTop: 10, marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
174
- {productsList.length > 0 &&
175
- <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
176
- <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
177
- <UpsellingLayout />
178
- </View>
179
- }
180
- <View style={{ paddingHorizontal: 40 }}>
181
- <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
182
- <OrderSummary
183
- cart={cart}
184
- isCartPending={cart?.status === 2}
185
- onNavigationRedirect={onNavigationRedirect}
186
- />
187
- </View>
188
- </ScrollView>
189
- <View
190
- style={{
191
- alignItems: 'center',
192
- bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
193
- }}
194
- >
195
- <OButton
196
- imgRightSrc=''
197
- text={t('CHECKOUT', 'Checkout')}
198
- style={{ ...styles.closeUpsellingButton }}
199
- textStyle={{ color: theme.colors.white, fontSize: 14 }}
200
- onClick={() => {
201
- handleUpsellingPage()
202
- setIsCheckout(true)
203
- }}
204
- />
205
- </View>
206
- </>
207
- )
208
- }
134
+ const UpsellingLayout = () => {
135
+ return (
136
+ <Container>
137
+ <UpsellingContainer
138
+ horizontal
139
+ showsHorizontalScrollIndicator={false}
140
+ contentContainerStyle={{ paddingHorizontal: Platform.OS === 'ios' ? 40 : 0 }}
141
+ >
142
+ {
143
+ !upsellingProducts.loading && (
144
+ <>
145
+ {
146
+ !upsellingProducts.error ? productsList.map((product: any, i: number) => (
147
+ <Item key={`${product.id}_${i}`}>
148
+ <View style={{ flexBasis: '57%' }}>
149
+ <Details>
150
+ <OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
151
+ <OText size={12} lineHeight={18} color={theme.colors.textNormal}>{parsePrice(product.price)}</OText>
152
+ </Details>
153
+ <AddButton onPress={() => handleFormProduct(product)}>
154
+ <OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
155
+ </AddButton>
156
+ </View>
157
+ <View>
158
+ <OIcon url={product?.images || theme?.images?.dummies?.product} style={styles.imageStyle} />
159
+ </View>
160
+ </Item>
161
+ )) : (
162
+ <OText>
163
+ {upsellingProducts.message}
164
+ </OText>
165
+ )
166
+ }
167
+ </>
168
+ )
169
+ }
170
+ </UpsellingContainer>
171
+ </Container>
172
+ )
173
+ }
209
174
 
210
- return (
211
- <>
212
- {isCustomMode ? (
213
- <UpsellingLayout />
214
- ) : (
215
- <>
216
- {props.isPage ? (
217
- <UpsellingContent />
218
- ) : (
219
- canOpenUpselling && !modalIsOpen && (
220
- <OBottomPopup
221
- title={''}
222
- open={openUpselling}
223
- onClose={() => handleUpsellingPage()}
224
- isStatusBar
225
- >
226
- <UpsellingContent />
227
- </OBottomPopup>
228
- )
229
- )}
230
- </>
231
- )}
232
- </>
233
- )
175
+ const UpsellingContent = () => {
176
+ return (
177
+ <>
178
+ <View style={{ ...styles.headerItem, flex: 1, marginTop: Platform.OS == 'ios' ? 35 : 14 }}>
179
+ <TouchableOpacity onPress={() => onGoBack()} style={styles.btnBackArrow}>
180
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
181
+ </TouchableOpacity>
182
+ </View>
183
+ <ScrollView style={{ marginTop: 10, marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
184
+ {productsList.length > 0 &&
185
+ <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
186
+ <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
187
+ <UpsellingLayout />
188
+ </View>
189
+ }
190
+ <View style={{ paddingHorizontal: 40 }}>
191
+ <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
192
+ <OrderSummary
193
+ cart={cart}
194
+ commentDelayTime={commentDelayTime}
195
+ isCartPending={cart?.status === 2}
196
+ onNavigationRedirect={onNavigationRedirect}
197
+ />
198
+ </View>
199
+ {showCartList && cartList.map((cart: any, i: number) => (
200
+ <CartList key={i}>
201
+ <Cart
202
+ cart={cart}
203
+ cartuuid={cart.uuid}
204
+ hideUpselling
205
+ singleBusiness={props.singleBusiness}
206
+ isFranchiseApp={props.isFranchiseApp}
207
+ isCartsLoading={isCartsLoading}
208
+ setIsCartsLoading={setIsCartsLoading}
209
+ isMultiCheckout={isMultiCheckout}
210
+ onNavigationRedirect={props.onNavigationRedirect}
211
+ />
212
+ <CartDivider />
213
+ </CartList>
214
+ ))}
215
+ </ScrollView>
216
+ <View
217
+ style={{
218
+ alignItems: 'center',
219
+ bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
220
+ }}
221
+ >
222
+ <OButton
223
+ imgRightSrc=''
224
+ text={t('CHECKOUT', 'Checkout')}
225
+ style={{ ...styles.closeUpsellingButton }}
226
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
227
+ onClick={() => {
228
+ handleUpsellingPage()
229
+ setIsCheckout(true)
230
+ }}
231
+ />
232
+ </View>
233
+ </>
234
+ )
235
+ }
236
+
237
+ return (
238
+ <>
239
+ {isCustomMode ? (
240
+ <UpsellingLayout />
241
+ ) : (
242
+ <>
243
+ {props.isPage ? (
244
+ <UpsellingContent />
245
+ ) : (
246
+ canOpenUpselling && !modalIsOpen && (
247
+ <OBottomPopup
248
+ title={''}
249
+ open={openUpselling}
250
+ onClose={() => handleUpsellingPage()}
251
+ isStatusBar
252
+ >
253
+ <UpsellingContent />
254
+ </OBottomPopup>
255
+ )
256
+ )}
257
+ </>
258
+ )}
259
+ </>
260
+ )
234
261
  }
235
262
 
236
263
  export const UpsellingProducts = (props: UpsellingProductsParams) => {
237
- const upsellingProductsProps = {
238
- ...props,
239
- UIComponent: UpsellingProductsUI
240
- }
241
- return (
242
- <UpsellingPageController {...upsellingProductsProps} />
243
- )
264
+ const upsellingProductsProps = {
265
+ ...props,
266
+ UIComponent: UpsellingProductsUI
267
+ }
268
+ return (
269
+ <UpsellingPageController {...upsellingProductsProps} />
270
+ )
244
271
  }
@@ -47,4 +47,15 @@ export const TopBar = styled.View`
47
47
  export const TopActions = styled.TouchableOpacity`
48
48
  height: 44px;
49
49
  justify-content: center;
50
- `;
50
+ `;
51
+
52
+ export const CartList = styled.ScrollView`
53
+ padding: 10px 40px;
54
+ overflow: visible;
55
+ `
56
+
57
+ export const CartDivider = styled.View`
58
+ height: 8px;
59
+ background-color: ${(props: any) => props.theme.colors.backgroundGray100};
60
+ margin: 20px -40px 0;
61
+ `