ordering-ui-react-native 0.14.35 → 0.14.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.14.35",
3
+ "version": "0.14.38",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -0,0 +1 @@
1
+ declare module 'react-native-color-matrix-image-filters'
@@ -30,6 +30,8 @@ import { NotFoundSource } from './src/components/NotFoundSource';
30
30
  import { OrderTypeSelector } from './src/components/OrderTypeSelector';
31
31
  import { Wallets } from './src/components/Wallets';
32
32
  import { PaymentOptionWallet } from './src/components/PaymentOptionWallet';
33
+ import { ProductForm } from './src/components/ProductForm';
34
+ import { UpsellingProducts } from './src/components/UpsellingProducts';
33
35
 
34
36
  import { Toast } from './src/components/shared/OToast';
35
37
  import {
@@ -90,6 +92,8 @@ export {
90
92
  OrderTypeSelector,
91
93
  Wallets,
92
94
  PaymentOptionWallet,
95
+ ProductForm,
96
+ UpsellingProducts,
93
97
 
94
98
  // OComponents
95
99
  Toast,
@@ -46,7 +46,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
46
46
  const [menu, setMenu] = useState({})
47
47
  const [timeList, setTimeList] = useState<any>([])
48
48
  const [selectDate, setSelectedDate] = useState<any>(null)
49
- const [datesWhitelist, setDateWhitelist] = useState<any>([{start: null, end: null}])
49
+ const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
50
50
 
51
51
  const styles = StyleSheet.create({
52
52
  container: {
@@ -54,19 +54,19 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
54
54
  paddingVertical: 30,
55
55
  paddingHorizontal: 40
56
56
  },
57
- businessLogo: {
58
- backgroundColor: 'white',
59
- width: 60,
60
- height: 60,
61
- borderRadius: 7.6,
62
- justifyContent: 'center',
63
- alignItems: 'center',
64
- shadowColor: '#000000',
65
- shadowOffset: { width: 0, height: 1 },
66
- shadowOpacity: 0.1,
67
- shadowRadius: 1,
68
- elevation: 2
69
- },
57
+ businessLogo: {
58
+ backgroundColor: 'white',
59
+ width: 60,
60
+ height: 60,
61
+ borderRadius: 7.6,
62
+ justifyContent: 'center',
63
+ alignItems: 'center',
64
+ shadowColor: '#000000',
65
+ shadowOffset: { width: 0, height: 1 },
66
+ shadowOpacity: 0.1,
67
+ shadowRadius: 1,
68
+ elevation: 2
69
+ },
70
70
  selectOption: {
71
71
  backgroundColor: theme.colors.backgroundGray100,
72
72
  borderRadius: 7.6,
@@ -82,7 +82,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
82
82
  paddingBottom: 15,
83
83
  borderBottomWidth: 1,
84
84
  borderColor: theme.colors.backgroundGray200,
85
- height: 100
85
+ height: 100,
86
86
  },
87
87
  calendarHeaderContainer: {
88
88
  flex: 1,
@@ -101,35 +101,36 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
101
101
  dateNumber: {
102
102
  color: '#B1BCCC',
103
103
  fontSize: 16,
104
- fontWeight: '500'
104
+ fontWeight: '500',
105
105
  },
106
106
  dateName: {
107
107
  color: '#B1BCCC',
108
108
  fontSize: 12,
109
- textTransform: 'capitalize'
109
+ textTransform: 'capitalize',
110
110
  },
111
111
  highlightDateName: {
112
112
  color: '#344050',
113
113
  fontSize: 12,
114
- textTransform: 'capitalize'
114
+ textTransform: 'capitalize',
115
115
  },
116
116
  highlightDateNumber: {
117
117
  color: '#344050',
118
118
  fontSize: 16,
119
- textTransform: 'capitalize'
119
+ textTransform: 'capitalize',
120
120
  },
121
121
  disabledDateName: {
122
122
  color: '#B1BCCC',
123
123
  fontSize: 10,
124
124
  textTransform: 'capitalize',
125
- opacity: 1
125
+ opacity: 1,
126
126
  },
127
127
  disabledDateNumber: {
128
128
  color: '#B1BCCC',
129
129
  fontSize: 14,
130
- fontWeight: '500'
130
+ fontWeight: '500',
131
+
131
132
  }
132
- })
133
+ })
133
134
 
134
135
  const preorderTypeList = [
135
136
  { key: 'business_hours', name: t('BUSINESS_HOURS', 'Business hours') },
@@ -191,7 +192,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
191
192
 
192
193
  const LeftSelector = () => {
193
194
  return (
194
- <View style={{height: '100%', justifyContent: 'flex-end'}}>
195
+ <View style={{ height: '100%', justifyContent: 'flex-end' }}>
195
196
  <IconAntDesign
196
197
  name='caretleft'
197
198
  color={theme.colors.textNormal}
@@ -203,7 +204,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
203
204
 
204
205
  const RightSelector = () => {
205
206
  return (
206
- <View style={{height: '100%', justifyContent: 'flex-end'}}>
207
+ <View style={{ height: '100%', justifyContent: 'flex-end' }}>
207
208
  <IconAntDesign
208
209
  name='caretright'
209
210
  color={theme.colors.textNormal}
@@ -280,7 +281,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
280
281
  name='close'
281
282
  color={theme.colors.textThird}
282
283
  size={24}
283
- style={{ marginLeft: -4}}
284
+ style={{ marginLeft: -4 }}
284
285
  />
285
286
  </TouchableOpacity>
286
287
  <BusinessInfoWrapper>
@@ -294,8 +295,8 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
294
295
  <FastImage
295
296
  style={{ width: 59, height: 59 }}
296
297
  source={{
297
- uri: optimizeImage(business?.logo, 'h_60,c_limit'),
298
- priority: FastImage.priority.normal,
298
+ uri: optimizeImage(business?.logo, 'h_60,c_limit'),
299
+ priority: FastImage.priority.normal,
299
300
  }}
300
301
  resizeMode={FastImage.resizeMode.cover}
301
302
  />
@@ -372,7 +373,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
372
373
  setMenu={setMenu}
373
374
  menu={menu}
374
375
  />
375
- </MenuWrapper>
376
+ </MenuWrapper>
376
377
  )}
377
378
  <OrderTimeWrapper>
378
379
  <OText
@@ -393,14 +394,15 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
393
394
  calendarHeaderStyle={styles.calendarHeader}
394
395
  dateNumberStyle={styles.dateNumber}
395
396
  dateNameStyle={styles.dateName}
396
- iconContainer={{flex: 0.1}}
397
+ iconContainer={{ flex: 0.1 }}
397
398
  highlightDateNameStyle={styles.highlightDateName}
398
399
  highlightDateNumberStyle={styles.highlightDateNumber}
400
+ dayContainerStyle={{ height: '100%' }}
401
+ highlightDateContainerStyle={{ height: '100%' }}
399
402
  calendarHeaderFormat='MMMM, YYYY'
400
- iconStyle={{borderWidth: 1}}
403
+ iconStyle={{ borderWidth: 1 }}
401
404
  selectedDate={selectDate}
402
405
  datesWhitelist={datesWhitelist}
403
- dayContainerStyle={{height: 40}}
404
406
  disabledDateNameStyle={styles.disabledDateName}
405
407
  disabledDateNumberStyle={styles.disabledDateNumber}
406
408
  disabledDateOpacity={0.6}
@@ -417,7 +419,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
417
419
  <TimeItem active={timeSelected === time.value}>
418
420
  <OText
419
421
  size={14}
420
- color={timeSelected === time.value ? theme.colors.primary: theme.colors.textNormal}
422
+ color={timeSelected === time.value ? theme.colors.primary : theme.colors.textNormal}
421
423
  style={{
422
424
  lineHeight: 24
423
425
  }}
@@ -426,15 +428,15 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
426
428
  </TouchableOpacity>
427
429
  ))}
428
430
  {timeList.length % 3 === 2 && (
429
- <TimeItem style={{backgroundColor: 'transparent'}}/>
431
+ <TimeItem style={{ backgroundColor: 'transparent' }} />
430
432
  )}
431
433
  </TimeContentWrapper>
432
434
  </TimeListWrapper>
433
435
  </OrderTimeWrapper>
434
436
  <OButton
435
437
  text={t('GO_TO_MENU', 'Go to menu')}
436
- textStyle={{color: 'white'}}
437
- style={{borderRadius: 7.6, marginBottom: 20, marginTop: 30}}
438
+ textStyle={{ color: 'white' }}
439
+ style={{ borderRadius: 7.6, marginBottom: 20, marginTop: 30 }}
438
440
  onClick={() => handleClickBusiness()}
439
441
  />
440
442
  </PreOrderContainer>
@@ -0,0 +1,35 @@
1
+ import React, { useEffect } from 'react'
2
+ import { UpsellingPage as UpsellingPageController } from 'ordering-components/native'
3
+
4
+ const UpsellingRedirectUI = (props: any) => {
5
+ const {
6
+ setOpenUpselling,
7
+ upsellingProducts,
8
+ handleUpsellingPage,
9
+ onRedirect,
10
+ } = props
11
+
12
+ useEffect(() => {
13
+ if (!upsellingProducts.loading) {
14
+ if (upsellingProducts?.products?.length) {
15
+ onRedirect &&
16
+ onRedirect('UpsellingPage', props)
17
+ } else {
18
+ handleUpsellingPage && handleUpsellingPage()
19
+ }
20
+ setOpenUpselling(false)
21
+ }
22
+ }, [upsellingProducts.loading, upsellingProducts?.products.length])
23
+
24
+ return (<>{null}</>)
25
+ }
26
+
27
+ export const UpsellingRedirect = (props: any) => {
28
+ const upsellingProps = {
29
+ ...props,
30
+ UIComponent: UpsellingRedirectUI
31
+ }
32
+ return (
33
+ <UpsellingPageController {...upsellingProps} />
34
+ )
35
+ }
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react'
2
- import { View, TouchableOpacity, StyleSheet, SafeAreaView, Platform } from 'react-native'
2
+ import { View, TouchableOpacity, StyleSheet, SafeAreaView } from 'react-native'
3
3
  import { useTheme } from 'styled-components/native';
4
4
  import {
5
5
  BusinessAndProductList,
@@ -17,17 +17,13 @@ import { BusinessProductsCategories } from '../BusinessProductsCategories'
17
17
  import { BusinessProductsList } from '../BusinessProductsList'
18
18
  import { BusinessProductsListingParams } from '../../types'
19
19
  import {
20
- WrapHeader,
21
20
  TopHeader,
22
- AddressInput,
23
21
  WrapSearchBar,
24
22
  WrapContent,
25
23
  BusinessProductsListingContainer
26
24
  } from './styles'
27
25
  import { FloatingButton } from '../FloatingButton'
28
- import { ProductForm } from '../ProductForm'
29
- import { UpsellingProducts } from '../UpsellingProducts'
30
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
26
+ import { UpsellingRedirect } from './UpsellingRedirect'
31
27
  import Animated from 'react-native-reanimated'
32
28
 
33
29
  const PIXELS_TO_SCROLL = 1000
@@ -47,7 +43,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
47
43
  errorQuantityProducts,
48
44
  header,
49
45
  logo,
50
- getNextProducts
46
+ getNextProducts,
51
47
  } = props
52
48
 
53
49
  const theme = useTheme();
@@ -56,7 +52,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
56
52
  const [orderState] = useOrder()
57
53
  const [{ parsePrice }] = useUtils()
58
54
  const [, { showToast }] = useToast()
59
- const { top } = useSafeAreaInsets();
60
55
 
61
56
  const styles = StyleSheet.create({
62
57
  mainContainer: {
@@ -87,7 +82,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
87
82
  const { business, loading, error } = businessState
88
83
  const [openBusinessInformation, setOpenBusinessInformation] = useState(false)
89
84
  const [isOpenSearchBar, setIsOpenSearchBar] = useState(false)
90
- const [curProduct, setCurProduct] = useState(null)
91
85
  const [openUpselling, setOpenUpselling] = useState(false)
92
86
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
93
87
  const scrollViewRef = useRef<any>(null)
@@ -102,7 +96,11 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
102
96
  }
103
97
 
104
98
  const onProductClick = (product: any) => {
105
- setCurProduct(product)
99
+ onRedirect('ProductDetails', {
100
+ product: product,
101
+ businessSlug: business.slug,
102
+ businessId: business.id,
103
+ })
106
104
  }
107
105
 
108
106
  const handleCancel = () => {
@@ -110,14 +108,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
110
108
  handleChangeSearch('')
111
109
  }
112
110
 
113
- const handleCloseProductModal = () => {
114
- setCurProduct(null)
115
- }
116
-
117
- const handlerProductAction = () => {
118
- handleCloseProductModal()
119
- }
120
-
121
111
  const handleUpsellingPage = () => {
122
112
  onRedirect('CheckoutNavigator', {
123
113
  screen: 'CheckoutPage',
@@ -166,13 +156,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
166
156
  setCategoryClicked(false);
167
157
  }, []);
168
158
 
169
-
170
- useEffect(() => {
171
- if (!orderState.loading) {
172
- handleCloseProductModal()
173
- }
174
- }, [orderState.loading])
175
-
176
159
  return (
177
160
  <SafeAreaView
178
161
  style={{ flex: 1 }}
@@ -304,49 +287,35 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
304
287
  </>
305
288
  )}
306
289
  </BusinessProductsListingContainer>
307
- {!loading && auth && !openUpselling && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
290
+ {!loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
308
291
  <FloatingButton
309
292
  btnText={
310
293
  currentCart?.subtotal >= currentCart?.minimum
311
- ? !openUpselling ? t('VIEW_ORDER', 'View Order') : t('LOADING', 'Loading')
294
+ ? t('VIEW_ORDER', 'View Order')
312
295
  : `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
313
296
  }
314
297
  isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum}
315
- btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && !openUpselling && currentCart?.products?.length > 0}
316
- btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && !openUpselling && currentCart?.products?.length > 0}
298
+ btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
299
+ btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
317
300
  btnLeftValue={currentCart?.products?.length}
318
301
  btnRightValue={parsePrice(currentCart?.total)}
319
- disabled={openUpselling || currentCart?.subtotal < currentCart?.minimum}
302
+ disabled={currentCart?.subtotal < currentCart?.minimum}
320
303
  handleClick={() => setOpenUpselling(true)}
321
304
  />
322
305
  )}
323
- <OModal
324
- open={!!curProduct}
325
- onClose={handleCloseProductModal}
326
- entireModal
327
- customClose
328
- isAvoidKeyBoardView
329
- >
330
- <ProductForm
331
- product={curProduct}
332
- businessSlug={business.slug}
333
- businessId={business.id}
334
- onClose={handleCloseProductModal}
335
- navigation={navigation}
336
- onSave={handlerProductAction}
337
- />
338
- </OModal>
339
306
  {openUpselling && (
340
- <UpsellingProducts
307
+ <UpsellingRedirect
341
308
  businessId={currentCart?.business_id}
342
309
  business={currentCart?.business}
343
310
  cartProducts={currentCart?.products}
344
311
  cart={currentCart}
312
+ setOpenUpselling={setOpenUpselling}
345
313
  handleUpsellingPage={handleUpsellingPage}
346
314
  handleCloseUpsellingPage={handleCloseUpsellingPage}
347
315
  openUpselling={openUpselling}
348
316
  canOpenUpselling={canOpenUpselling}
349
317
  setCanOpenUpselling={setCanOpenUpselling}
318
+ onRedirect={onRedirect}
350
319
  />
351
320
  )}
352
321
  </SafeAreaView>
@@ -17,7 +17,6 @@ import { BusinessItemAccordion } from '../BusinessItemAccordion';
17
17
  import { CouponControl } from '../CouponControl';
18
18
 
19
19
  import { OButton, OInput, OModal, OText } from '../shared';
20
- import { ProductForm } from '../ProductForm';
21
20
  import { UpsellingProducts } from '../UpsellingProducts';
22
21
  import { verifyDecimals } from '../../utils';
23
22
  import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
@@ -35,10 +34,9 @@ const CartUI = (props: any) => {
35
34
  removeProduct,
36
35
  handleCartOpen,
37
36
  setIsCartsLoading,
38
- hideUpselling,
39
37
  handleChangeComment,
40
- commentState
41
- // isFromCart
38
+ commentState,
39
+ onNavigationRedirect
42
40
  } = props
43
41
 
44
42
  const theme = useTheme();
@@ -49,8 +47,6 @@ const CartUI = (props: any) => {
49
47
  const [{ parsePrice, parseNumber, parseDate }] = useUtils()
50
48
  const [validationFields] = useValidationFields()
51
49
 
52
- const [openProduct, setModalIsOpen] = useState(false)
53
- const [curProduct, setCurProduct] = useState<any>(null)
54
50
  const [openUpselling, setOpenUpselling] = useState(false)
55
51
  const [openChangeStore, setOpenChangeStore] = useState(false)
56
52
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
@@ -71,14 +67,14 @@ const CartUI = (props: any) => {
71
67
  }
72
68
 
73
69
  const handleEditProduct = (product: any) => {
74
- setCurProduct(product)
75
- setModalIsOpen(true)
76
- }
77
-
78
- const handlerProductAction = (product: any) => {
79
- if (Object.keys(product).length) {
80
- setModalIsOpen(false)
81
- }
70
+ onNavigationRedirect('ProductDetails', {
71
+ businessId,
72
+ isCartProduct: true,
73
+ productCart: product,
74
+ businessSlug: cart?.business?.slug,
75
+ categoryId: product?.category_id,
76
+ productId: product?.id,
77
+ })
82
78
  }
83
79
 
84
80
  const handleClearProducts = async () => {
@@ -329,23 +325,6 @@ const CartUI = (props: any) => {
329
325
  </CheckoutAction>
330
326
  )}
331
327
  </BusinessItemAccordion>
332
- <OModal
333
- open={openProduct}
334
- entireModal
335
- customClose
336
- onClose={() => setModalIsOpen(false)}
337
- >
338
- <ProductForm
339
- isCartProduct
340
- productCart={curProduct}
341
- businessSlug={cart?.business?.slug}
342
- businessId={businessId}
343
- categoryId={curProduct?.category_id}
344
- productId={curProduct?.id}
345
- onSave={handlerProductAction}
346
- onClose={() => setModalIsOpen(false)}
347
- />
348
- </OModal>
349
328
 
350
329
  <OModal
351
330
  open={openChangeStore && props.isFranchiseApp}
@@ -546,6 +546,7 @@ const CheckoutUI = (props: any) => {
546
546
  <OrderSummary
547
547
  cart={cart}
548
548
  isCartPending={cart?.status === 2}
549
+ onNavigationRedirect={onNavigationRedirect}
549
550
  />
550
551
  </>
551
552
  )}
@@ -611,7 +611,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
611
611
  <OText size={16} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
612
612
  {t('DELIVERY_PREFERENCE', 'Delivery Preference')}
613
613
  </OText>
614
- <OText size={12} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>{order?.delivery_option?.name ?? t('EITHER_WAY', 'Either way')}</OText>
614
+ <OText size={12} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
615
+ {order?.delivery_option?.name ? t(order?.delivery_option?.name.toUpperCase().replace(/\s/g, '_')) : t('EITHER_WAY', 'Either way')}
616
+ </OText>
615
617
  </View>
616
618
  )}
617
619
  {order?.comment && (
@@ -20,7 +20,6 @@ import {
20
20
  import { ProductItemAccordion } from '../ProductItemAccordion';
21
21
  import { CouponControl } from '../CouponControl';
22
22
  import { OInput, OModal, OText } from '../shared';
23
- import { ProductForm } from '../ProductForm';
24
23
  import { verifyDecimals } from '../../utils';
25
24
  import AntIcon from 'react-native-vector-icons/AntDesign'
26
25
  import { TaxInformation } from '../TaxInformation';
@@ -35,7 +34,8 @@ const OrderSummaryUI = (props: any) => {
35
34
  isCartPending,
36
35
  isFromCheckout,
37
36
  commentState,
38
- handleChangeComment
37
+ handleChangeComment,
38
+ onNavigationRedirect
39
39
  } = props;
40
40
 
41
41
  const theme = useTheme()
@@ -44,8 +44,6 @@ const OrderSummaryUI = (props: any) => {
44
44
  const [orderState] = useOrder();
45
45
  const [{ parsePrice, parseNumber }] = useUtils();
46
46
  const [validationFields] = useValidationFields();
47
- const [openProduct, setModalIsOpen] = useState(false)
48
- const [curProduct, setCurProduct] = useState<any>(null)
49
47
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
50
48
 
51
49
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
@@ -55,14 +53,15 @@ const OrderSummaryUI = (props: any) => {
55
53
  }
56
54
 
57
55
  const handleEditProduct = (product: any) => {
58
- setCurProduct(product)
59
- setModalIsOpen(true)
60
- }
61
-
62
- const handlerProductAction = (product: any) => {
63
- if (Object.keys(product).length) {
64
- setModalIsOpen(false)
65
- }
56
+ onNavigationRedirect('ProductDetails', {
57
+ isCartProduct: true,
58
+ productCart: product,
59
+ businessSlug: cart?.business?.slug,
60
+ businessId: cart?.business_id,
61
+ categoryId: product?.category_id,
62
+ productId: product?.id,
63
+ isFromCheckout: isFromCheckout,
64
+ })
66
65
  }
67
66
 
68
67
  const getIncludedTaxes = () => {
@@ -242,24 +241,6 @@ const OrderSummaryUI = (props: any) => {
242
241
  )}
243
242
  </OSBill>
244
243
  )}
245
- <OModal
246
- open={openProduct}
247
- entireModal
248
- customClose
249
- onClose={() => setModalIsOpen(false)}
250
- >
251
- <ProductForm
252
- isCartProduct
253
- productCart={curProduct}
254
- businessSlug={cart?.business?.slug}
255
- businessId={cart?.business_id}
256
- categoryId={curProduct?.category_id}
257
- productId={curProduct?.id}
258
- onSave={handlerProductAction}
259
- onClose={() => setModalIsOpen(false)}
260
- isFromCheckout={isFromCheckout}
261
- />
262
- </OModal>
263
244
  <OModal
264
245
  open={openTaxModal.open}
265
246
  onClose={() => setOpenTaxModal({ open: false, data: null })}
@@ -16,10 +16,9 @@ import {
16
16
  Grayscale
17
17
  } from 'react-native-color-matrix-image-filters'
18
18
 
19
- import { View, TouchableOpacity, StyleSheet, Dimensions, Platform, AppRegistry, I18nManager } from 'react-native';
19
+ import { View, TouchableOpacity, StyleSheet, Dimensions, I18nManager, SafeAreaView } from 'react-native';
20
20
 
21
21
  import {
22
- ProductHeader,
23
22
  WrapHeader,
24
23
  TopHeader,
25
24
  WrapContent,
@@ -40,9 +39,7 @@ import { ScrollView } from 'react-native-gesture-handler';
40
39
  import { ProductOptionSubOption } from '../ProductOptionSubOption';
41
40
  import { NotFoundSource } from '../NotFoundSource';
42
41
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
43
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
44
42
  import { useState } from 'react';
45
- import { useWindowDimensions } from 'react-native';
46
43
 
47
44
  const windowHeight = Dimensions.get('window').height;
48
45
  const windowWidth = Dimensions.get('window').width;
@@ -63,8 +60,6 @@ export const ProductOptionsUI = (props: any) => {
63
60
  handleChangeSuboptionState,
64
61
  handleChangeCommentState,
65
62
  productObject,
66
- onClose,
67
- isFromCheckout,
68
63
  } = props;
69
64
 
70
65
  const theme = useTheme();
@@ -97,7 +92,7 @@ export const ProductOptionsUI = (props: any) => {
97
92
  },
98
93
  btnBackArrow: {
99
94
  borderWidth: 0,
100
- backgroundColor: 'rgba(0,0,0,0.3)',
95
+ backgroundColor: '#FFF',
101
96
  borderRadius: 24,
102
97
  marginRight: 15,
103
98
  },
@@ -160,15 +155,13 @@ export const ProductOptionsUI = (props: any) => {
160
155
  const [gallery, setGallery] = useState([])
161
156
  const [thumbsSwiper, setThumbsSwiper] = useState(0)
162
157
 
163
- const { top, bottom } = useSafeAreaInsets();
164
- const { height } = useWindowDimensions();
165
158
  const [selOpt, setSelectedOpt] = useState(0);
166
159
  const [isHaveWeight, setIsHaveWeight] = useState(false)
167
160
  const [qtyBy, setQtyBy] = useState({
168
161
  weight_unit: false,
169
162
  pieces: true
170
163
  })
171
- const [pricePerWeightUnit, setPricePerWeightUnit] = useState(null)
164
+ const [pricePerWeightUnit, setPricePerWeightUnit] = useState<any>(null)
172
165
 
173
166
  const swiperRef: any = useRef(null)
174
167
 
@@ -187,10 +180,8 @@ export const ProductOptionsUI = (props: any) => {
187
180
  };
188
181
 
189
182
  const handleSaveProduct = () => {
190
- console.log('----- click handle ------')
191
183
  const isErrors = Object.values(errors).length > 0;
192
184
  if (!isErrors) {
193
- console.log('----- save handle ------')
194
185
  handleSave && handleSave();
195
186
  return;
196
187
  }
@@ -220,7 +211,6 @@ export const ProductOptionsUI = (props: any) => {
220
211
  }
221
212
 
222
213
  const handleRedirectLogin = () => {
223
- onClose();
224
214
  navigation.navigate('Login');
225
215
  };
226
216
 
@@ -298,14 +288,20 @@ export const ProductOptionsUI = (props: any) => {
298
288
  </>
299
289
  );
300
290
 
291
+ const handleGoBack = navigation?.canGoBack()
292
+ ? () => navigation.goBack()
293
+ : () => navigation.navigate('Business', { store: props.businessSlug })
294
+
301
295
  return (
302
- <>
303
- <TopHeader>
304
- <TouchableOpacity
305
- style={styles.headerItem}
306
- onPress={onClose}>
307
- <OIcon src={theme.images.general.close} width={16} />
308
- </TouchableOpacity>
296
+ <SafeAreaView style={{ flex: 1 }}>
297
+ <TopHeader>
298
+ <OButton
299
+ imgLeftSrc={theme.images.general.arrow_left}
300
+ imgRightSrc={null}
301
+ style={styles.btnBackArrow}
302
+ onClick={() => handleGoBack()}
303
+ imgLeftStyle={{ tintColor: theme.colors.textNormal, width: 16 }}
304
+ />
309
305
  </TopHeader>
310
306
  <ScrollView>
311
307
  {!error && (
@@ -773,11 +769,7 @@ export const ProductOptionsUI = (props: any) => {
773
769
  )}
774
770
  </ScrollView>
775
771
  {!loading && !error && product && (
776
- <ProductActions
777
- style={{
778
- paddingBottom: Platform.OS === 'ios' ? bottom + 30 : bottom + 80
779
- }}
780
- >
772
+ <ProductActions>
781
773
  <OText size={16} lineHeight={24} weight={'600'}>
782
774
  {productCart.total ? parsePrice(productCart?.total) : ''}
783
775
  </OText>
@@ -921,7 +913,7 @@ export const ProductOptionsUI = (props: any) => {
921
913
  </View>
922
914
  </ProductActions>
923
915
  )}
924
- </>
916
+ </SafeAreaView>
925
917
  );
926
918
  };
927
919
 
@@ -11,7 +11,8 @@ export const TopHeader = styled.View`
11
11
  align-items: center;
12
12
  justify-content: space-between;
13
13
  z-index: 1;
14
- padding-horizontal: 40px;
14
+ height: 60px;
15
+ min-height: 60px;
15
16
  `
16
17
 
17
18
  export const ProductHeader = styled.ImageBackground`
@@ -89,4 +90,4 @@ export const WeightUnitItem = styled.View`
89
90
  ${({ active }: any) => active && css`
90
91
  background-color: ${(props: any) => props.theme.colors.primary}20;
91
92
  `}
92
- `
93
+ `
@@ -4,9 +4,10 @@ import {
4
4
  UpsellingPage as UpsellingPageController,
5
5
  useUtils,
6
6
  useLanguage,
7
+ useOrder
7
8
  } from 'ordering-components/native'
8
9
  import { useTheme } from 'styled-components/native';
9
- import { OText, OIcon, OModal, OBottomPopup, OButton } from '../shared'
10
+ import { OText, OIcon, OBottomPopup, OButton } from '../shared'
10
11
  import { UpsellingProductsParams } from '../../types'
11
12
  import {
12
13
  Container,
@@ -14,11 +15,9 @@ import {
14
15
  Item,
15
16
  Details,
16
17
  AddButton,
17
- CloseUpselling,
18
18
  TopBar,
19
19
  TopActions
20
20
  } from './styles'
21
- import { ProductForm } from '../ProductForm';
22
21
  import { OrderSummary } from '../OrderSummary';
23
22
  import { ScrollView } from 'react-native-gesture-handler';
24
23
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -28,18 +27,18 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
28
27
  isCustomMode,
29
28
  upsellingProducts,
30
29
  business,
31
- cart,
32
30
  handleUpsellingPage,
33
31
  handleCloseUpsellingPage,
34
32
  openUpselling,
35
33
  canOpenUpselling,
36
34
  setCanOpenUpselling,
37
- isFromCart
35
+ isFromCart,
36
+ onNavigationRedirect,
37
+ onGoBack
38
38
  } = props
39
39
 
40
40
  const theme = useTheme();
41
41
 
42
-
43
42
  const styles = StyleSheet.create({
44
43
  imageStyle: {
45
44
  width: 73,
@@ -66,14 +65,25 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
66
65
  }
67
66
  })
68
67
 
69
- const [actualProduct, setActualProduct] = useState<any>(null)
70
68
  const [modalIsOpen, setModalIsOpen] = useState(false)
69
+ const [{ carts }] = useOrder()
71
70
  const [{ parsePrice }] = useUtils()
72
71
  const [, t] = useLanguage()
73
72
  const { bottom } = useSafeAreaInsets()
74
73
 
74
+ const cart = carts?.[`businessId:${props.businessId}`] ?? {}
75
+ const cartProducts = cart?.products?.length
76
+ ? cart?.products.map((product: any) => product.id)
77
+ : []
78
+
79
+ const productsList = !upsellingProducts.loading && !upsellingProducts.error
80
+ ? upsellingProducts?.products?.length
81
+ ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
82
+ : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
83
+ : []
84
+
75
85
  useEffect(() => {
76
- if (!isCustomMode) {
86
+ if (!isCustomMode && !props.products) {
77
87
  if (!upsellingProducts.loading) {
78
88
  if (upsellingProducts?.products?.length && !isFromCart) {
79
89
  setCanOpenUpselling && setCanOpenUpselling(true)
@@ -81,25 +91,15 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
81
91
  handleUpsellingPage && handleUpsellingPage()
82
92
  }
83
93
  }
84
- // if ((!upsellingProducts?.products?.length && !upsellingProducts.loading && !canOpenUpselling && openUpselling) ||
85
- // (!upsellingProducts?.products?.length && !upsellingProducts.loading && openUpselling)) {
86
- // handleUpsellingPage && handleUpsellingPage()
87
- // }
88
94
  }
89
95
  }, [upsellingProducts.loading, upsellingProducts?.products.length])
90
96
 
91
- useEffect(() => {
92
- if (!cart?.validate && cart?.products?.length == 0) handleCloseUpsellingPage()
93
- }, [cart])
94
-
95
97
  const handleFormProduct = (product: any) => {
96
- setActualProduct(product)
97
- setModalIsOpen(true)
98
- }
99
-
100
- const handleSaveProduct = () => {
101
- setActualProduct(null)
102
- setModalIsOpen(false)
98
+ onNavigationRedirect && onNavigationRedirect('ProductDetails', {
99
+ product: product,
100
+ businessId: product?.api?.businessId,
101
+ businessSlug: business.slug,
102
+ })
103
103
  }
104
104
 
105
105
  const UpsellingLayout = () => {
@@ -114,7 +114,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
114
114
  !upsellingProducts.loading && (
115
115
  <>
116
116
  {
117
- !upsellingProducts.error ? upsellingProducts.products.map((product: any) => (
117
+ !upsellingProducts.error ? productsList.map((product: any) => (
118
118
  <Item key={product.id}>
119
119
  <View style={{ flexBasis: '57%' }}>
120
120
  <Details>
@@ -125,7 +125,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
125
125
  <OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
126
126
  </AddButton>
127
127
  </View>
128
- <View style={{}}>
128
+ <View>
129
129
  <OIcon url={product.images} style={styles.imageStyle} />
130
130
  </View>
131
131
  </Item>
@@ -143,75 +143,73 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
143
143
  )
144
144
  }
145
145
 
146
+ const UpsellingContent = () => {
147
+ return (
148
+ <>
149
+ <TopBar style={{ paddingTop: Platform.OS == 'ios' ? 10 : 30 }}>
150
+ <TopActions onPress={() => onGoBack()}>
151
+ <OIcon src={theme.images.general.arrow_left} width={15} />
152
+ </TopActions>
153
+ <TopActions style={styles.cancelBtn} onPress={() => handleUpsellingPage()}>
154
+ <OText size={12} color={theme.colors.textSecondary}>{t('CANCEL', 'Cancel')}</OText>
155
+ </TopActions>
156
+ </TopBar>
157
+ <ScrollView style={{ marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
158
+ {productsList.length > 0 &&
159
+ <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
160
+ <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
161
+ <UpsellingLayout />
162
+ </View>
163
+ }
164
+ <View style={{ paddingHorizontal: 40 }}>
165
+ <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
166
+ <OrderSummary
167
+ cart={cart}
168
+ isCartPending={cart?.status === 2}
169
+ onNavigationRedirect={onNavigationRedirect}
170
+ />
171
+ </View>
172
+ </ScrollView>
173
+ <View
174
+ style={{
175
+ alignItems: 'center',
176
+ bottom: props.isPage ? 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
177
+ }}
178
+ >
179
+ <OButton
180
+ imgRightSrc=''
181
+ text={t('CHECKOUT', 'Checkout')}
182
+ style={{...styles.closeUpsellingButton}}
183
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
184
+ onClick={() => handleUpsellingPage()}
185
+ />
186
+ </View>
187
+ </>
188
+ )
189
+ }
190
+
146
191
  return (
147
192
  <>
148
193
  {isCustomMode ? (
149
194
  <UpsellingLayout />
150
195
  ) : (
151
196
  <>
152
- {!canOpenUpselling ? null : (
153
- <>
154
- {!modalIsOpen && (
155
- <OBottomPopup
156
- title={''}
157
- open={openUpselling}
158
- onClose={() => handleUpsellingPage()}
159
- isStatusBar
160
- >
161
- <TopBar style={{ paddingTop: Platform.OS == 'ios' ? 10 : 30 }}>
162
- <TopActions onPress={() => handleCloseUpsellingPage()}>
163
- <OIcon src={theme.images.general.arrow_left} width={15} />
164
- </TopActions>
165
- <TopActions style={styles.cancelBtn} onPress={() => handleCloseUpsellingPage()}>
166
- <OText size={12} color={theme.colors.textSecondary}>{t('CANCEL', 'Cancel')}</OText>
167
- </TopActions>
168
- </TopBar>
169
- <ScrollView style={{ marginBottom: bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
170
- {upsellingProducts?.products?.length > 0 &&
171
- <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
172
- <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
173
- <UpsellingLayout />
174
- </View>
175
- }
176
- <View style={{ paddingHorizontal: 40 }}>
177
- <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
178
- <OrderSummary
179
- cart={cart}
180
- isCartPending={cart?.status === 2}
181
- />
182
- </View>
183
- </ScrollView>
184
- <View style={{alignItems: 'center', bottom: Platform.OS === 'ios' ? bottom + 59 : bottom + 125}}>
185
- <OButton
186
- imgRightSrc=''
187
- text={t('CHECKOUT', 'Checkout')}
188
- style={{...styles.closeUpsellingButton}}
189
- textStyle={{ color: theme.colors.white, fontSize: 14 }}
190
- onClick={() => handleUpsellingPage()}
191
- />
192
- </View>
193
- </OBottomPopup>
194
- )}
195
- </>
196
- )}
197
+ {props.isPage ? (
198
+ <UpsellingContent />
199
+ ) : (
200
+ canOpenUpselling && !modalIsOpen && (
201
+ <OBottomPopup
202
+ title={''}
203
+ open={openUpselling}
204
+ onClose={() => handleUpsellingPage()}
205
+ isStatusBar
206
+ >
207
+ <UpsellingContent />
208
+ </OBottomPopup>
209
+ )
210
+ )}
197
211
  </>
198
212
  )}
199
- <OModal
200
- open={modalIsOpen}
201
- onClose={() => setModalIsOpen(false)}
202
- entireModal
203
- customClose
204
- >
205
- {actualProduct && (
206
- <ProductForm
207
- product={actualProduct}
208
- businessId={actualProduct?.api?.businessId}
209
- businessSlug={business.slug}
210
- onSave={() => handleSaveProduct()}
211
- onClose={() => setModalIsOpen(false)}
212
- />
213
- )}
214
- </OModal>
215
213
  </>
216
214
  )
217
215
  }
@@ -438,6 +438,10 @@ export interface UpsellingProductsParams {
438
438
  cart?: any;
439
439
  handleCloseUpsellingPage: () => void;
440
440
  isFromCart?: boolean;
441
+ isPage?: boolean;
442
+ products?: any;
443
+ onNavigationRedirect?: any;
444
+ onGoBack?: any;
441
445
  }
442
446
 
443
447
  export interface GoogleMapsParams {