ordering-ui-react-native 0.14.33 → 0.14.35-release

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 (59) hide show
  1. package/package.json +2 -2
  2. package/src/components/BusinessItemAccordion/index.tsx +2 -2
  3. package/src/components/BusinessProductsListing/index.tsx +10 -26
  4. package/src/components/Cart/index.tsx +136 -62
  5. package/src/components/Cart/styles.tsx +7 -0
  6. package/src/components/Checkout/index.tsx +10 -6
  7. package/src/components/OrderDetails/index.tsx +102 -34
  8. package/src/components/OrderDetails/styles.tsx +7 -0
  9. package/src/components/OrderSummary/index.tsx +142 -58
  10. package/src/components/OrderSummary/styles.tsx +10 -2
  11. package/src/components/ProductForm/index.tsx +47 -10
  12. package/src/components/ProductForm/styles.tsx +1 -1
  13. package/src/components/SingleProductCard/index.tsx +1 -1
  14. package/src/components/StripeElementsForm/index.tsx +28 -13
  15. package/src/components/TaxInformation/index.tsx +58 -26
  16. package/src/components/UpsellingProducts/index.tsx +13 -31
  17. package/src/components/VerifyPhone/styles.tsx +1 -2
  18. package/src/navigators/HomeNavigator.tsx +6 -0
  19. package/src/pages/ProductDetails.tsx +55 -0
  20. package/src/types/index.tsx +2 -0
  21. package/src/types/react-native-color-matrix-image-filters/index.d.ts +1 -0
  22. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  23. package/themes/doordash/src/components/ProductForm/index.tsx +41 -2
  24. package/themes/doordash/src/components/ProductForm/styles.tsx +1 -1
  25. package/themes/instacart/src/components/ProductForm/index.tsx +40 -1
  26. package/themes/instacart/src/components/ProductForm/styles.tsx +1 -1
  27. package/themes/kiosk/src/components/Cart/index.tsx +14 -21
  28. package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
  29. package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
  30. package/themes/kiosk/src/components/Intro/index.tsx +4 -4
  31. package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
  32. package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
  33. package/themes/original/index.tsx +4 -0
  34. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  35. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
  36. package/themes/original/src/components/BusinessPreorder/index.tsx +37 -35
  37. package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +35 -0
  38. package/themes/original/src/components/BusinessProductsListing/index.tsx +22 -49
  39. package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
  40. package/themes/original/src/components/Cart/index.tsx +10 -31
  41. package/themes/original/src/components/Checkout/index.tsx +2 -0
  42. package/themes/original/src/components/Checkout/styles.tsx +1 -0
  43. package/themes/original/src/components/FacebookLogin/index.tsx +20 -5
  44. package/themes/original/src/components/Help/index.tsx +1 -1
  45. package/themes/original/src/components/Home/index.tsx +5 -3
  46. package/themes/original/src/components/LoginForm/index.tsx +50 -49
  47. package/themes/original/src/components/MessageListing/index.tsx +4 -2
  48. package/themes/original/src/components/OrderDetails/index.tsx +3 -1
  49. package/themes/original/src/components/OrderSummary/index.tsx +11 -30
  50. package/themes/original/src/components/PaymentOptionWallet/index.tsx +10 -6
  51. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -0
  52. package/themes/original/src/components/ProductForm/index.tsx +105 -76
  53. package/themes/original/src/components/ProductForm/styles.tsx +10 -3
  54. package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
  55. package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
  56. package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
  57. package/themes/original/src/components/UpsellingProducts/index.tsx +85 -83
  58. package/themes/original/src/types/index.tsx +6 -0
  59. package/themes/uber-eats/src/components/ProductForm/index.tsx +43 -2
@@ -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',
@@ -165,13 +155,10 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
165
155
  const handleTouchDrag = useCallback(() => {
166
156
  setCategoryClicked(false);
167
157
  }, []);
168
-
169
-
170
- useEffect(() => {
171
- if (!orderState.loading) {
172
- handleCloseProductModal()
173
- }
174
- }, [orderState.loading])
158
+
159
+ const handleBackNavigation = () => {
160
+ navigation?.canGoBack() ? navigation.goBack() : navigation.navigate('BottomTab')
161
+ }
175
162
 
176
163
  return (
177
164
  <SafeAreaView
@@ -186,7 +173,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
186
173
  imgLeftSrc={theme.images.general.arrow_left}
187
174
  imgRightSrc={null}
188
175
  style={styles.btnBackArrow}
189
- onClick={() => navigation?.canGoBack() && navigation.goBack()}
176
+ onClick={() => handleBackNavigation()}
190
177
  imgLeftStyle={{ tintColor: theme.colors.textNormal, width: 16 }}
191
178
  />
192
179
  </View>
@@ -248,7 +235,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
248
235
  selectedCategoryId={selectedCategoryId}
249
236
  lazyLoadProductsRecommended={business?.lazy_load_products_recommended}
250
237
  setSelectedCategoryId={setSelectedCategoryId}
251
- setCategoryClicked={setCategoryClicked}
238
+ setCategoryClicked={setCategoryClicked}
252
239
  />
253
240
  )}
254
241
  </>
@@ -304,49 +291,35 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
304
291
  </>
305
292
  )}
306
293
  </BusinessProductsListingContainer>
307
- {!loading && auth && !openUpselling && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
294
+ {!loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
308
295
  <FloatingButton
309
296
  btnText={
310
297
  currentCart?.subtotal >= currentCart?.minimum
311
- ? !openUpselling ? t('VIEW_ORDER', 'View Order') : t('LOADING', 'Loading')
298
+ ? t('VIEW_ORDER', 'View Order')
312
299
  : `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
313
300
  }
314
301
  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}
302
+ btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
303
+ btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
317
304
  btnLeftValue={currentCart?.products?.length}
318
305
  btnRightValue={parsePrice(currentCart?.total)}
319
- disabled={openUpselling || currentCart?.subtotal < currentCart?.minimum}
306
+ disabled={currentCart?.subtotal < currentCart?.minimum}
320
307
  handleClick={() => setOpenUpselling(true)}
321
308
  />
322
309
  )}
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
310
  {openUpselling && (
340
- <UpsellingProducts
311
+ <UpsellingRedirect
341
312
  businessId={currentCart?.business_id}
342
313
  business={currentCart?.business}
343
314
  cartProducts={currentCart?.products}
344
315
  cart={currentCart}
316
+ setOpenUpselling={setOpenUpselling}
345
317
  handleUpsellingPage={handleUpsellingPage}
346
318
  handleCloseUpsellingPage={handleCloseUpsellingPage}
347
319
  openUpselling={openUpselling}
348
320
  canOpenUpselling={canOpenUpselling}
349
321
  setCanOpenUpselling={setCanOpenUpselling}
322
+ onRedirect={onRedirect}
350
323
  />
351
324
  )}
352
325
  </SafeAreaView>
@@ -7,6 +7,7 @@ import {
7
7
  ScrollView,
8
8
  Platform,
9
9
  TouchableOpacity,
10
+ RefreshControl
10
11
  } from 'react-native';
11
12
  import {
12
13
  BusinessList as BusinessesListingController,
@@ -57,11 +58,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
57
58
  handleBusinessClick,
58
59
  paginationProps,
59
60
  handleChangeSearch,
60
- businessId
61
+ businessId
61
62
  } = props;
62
63
 
63
64
  const theme = useTheme();
64
65
  const isFocused = useIsFocused();
66
+ const [refreshing] = useState(false);
65
67
 
66
68
  const styles = StyleSheet.create({
67
69
  container: {
@@ -142,15 +144,15 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
142
144
  };
143
145
 
144
146
  const getDistance = (lat1: any, lon1: any, lat2: any, lon2: any) => {
145
- const R = 6371 // km
146
- const dLat = convertToRadian(lat2 - lat1)
147
- const dLon = convertToRadian(lon2 - lon1)
148
- const curLat1 = convertToRadian(lat1)
149
- const curLat2 = convertToRadian(lat2)
150
- const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(curLat1) * Math.cos(curLat2)
151
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
152
- return R * c
153
- }
147
+ const R = 6371 // km
148
+ const dLat = convertToRadian(lat2 - lat1)
149
+ const dLon = convertToRadian(lon2 - lon1)
150
+ const curLat1 = convertToRadian(lat1)
151
+ const curLat2 = convertToRadian(lat2)
152
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(curLat1) * Math.cos(curLat2)
153
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
154
+ return R * c
155
+ }
154
156
 
155
157
  useEffect(() => {
156
158
  if (businessesList.businesses.length > 0) {
@@ -162,6 +164,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
162
164
  setFeaturedBusinesses(ary);
163
165
  }
164
166
  }, [businessesList.businesses]);
167
+
165
168
  // const resetInactivityTimeout = () => {
166
169
  // clearTimeout(timerId.current)
167
170
  // timerId.current = setInterval(() => {
@@ -173,21 +176,37 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
173
176
  // resetInactivityTimeout()
174
177
  // }, [])
175
178
 
179
+ const handleOnRefresh = () => {
180
+ const hasMore = !(
181
+ paginationProps.totalPages === paginationProps.currentPage
182
+ );
183
+ if (!businessesList.loading && hasMore) {
184
+ getBusinesses();
185
+ }
186
+ }
187
+
176
188
  useEffect(() => {
177
189
  Geolocation.getCurrentPosition((pos) => {
178
- const crd = pos.coords
179
- const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
180
- if (distance > 20) setIsFarAway(true)
190
+ const crd = pos.coords
191
+ const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
192
+ if (distance > 20) setIsFarAway(true)
181
193
  else setIsFarAway(false)
182
- }, (err) => {
183
- console.log(`ERROR(${err.code}): ${err.message}`)
184
- }, {
185
- enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
186
- })
187
- }, [orderState?.options?.address?.location])
194
+ }, (err) => {
195
+ console.log(`ERROR(${err.code}): ${err.message}`)
196
+ }, {
197
+ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
198
+ })
199
+ }, [orderState?.options?.address?.location])
188
200
 
189
201
  return (
190
- <ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}>
202
+ <ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
203
+ refreshControl={
204
+ <RefreshControl
205
+ refreshing={refreshing}
206
+ onRefresh={() => handleOnRefresh()}
207
+ />
208
+ }
209
+ >
191
210
  <HeaderWrapper
192
211
  source={theme.images.backgrounds.business_list_header}
193
212
  style={{ paddingTop: top + 20 }}>
@@ -257,72 +276,78 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
257
276
  />
258
277
  </WrapMomentOption>
259
278
 
260
- {!businessId && (
261
- <SearchBar
262
- onSearch={handleChangeSearch}
263
- searchValue={searchValue}
264
- lazyLoad
265
- isCancelXButtonShow={!!searchValue}
266
- borderStyle={styles.borderStyle}
267
- onCancel={() => handleChangeSearch('')}
268
- placeholder={t('SEARCH', 'Search')}
269
- height={26}
270
- inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? {} : { paddingBottom: 4 } }}
271
- />
272
- )}
279
+ {!businessId && (
280
+ <SearchBar
281
+ onSearch={handleChangeSearch}
282
+ searchValue={searchValue}
283
+ lazyLoad
284
+ isCancelXButtonShow={!!searchValue}
285
+ borderStyle={styles.borderStyle}
286
+ onCancel={() => handleChangeSearch('')}
287
+ placeholder={t('SEARCH', 'Search')}
288
+ height={26}
289
+ inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? {} : { paddingBottom: 4 } }}
290
+ />
291
+ )}
273
292
 
274
293
  </View>
275
294
  </OrderControlContainer>
276
295
  </HeaderWrapper>
277
- {isFocused && (
278
- <OrderProgressWrapper>
279
- <OrderProgress
280
- {...props}
281
- />
282
- </OrderProgressWrapper>
283
- )}
284
- {!businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
285
- <FeaturedWrapper>
286
- <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('FEATURED_BUSINESS', 'Featured business')}</OText>
287
- <ScrollView
288
- showsHorizontalScrollIndicator={false}
289
- nestedScrollEnabled
290
- horizontal contentContainerStyle={{ paddingHorizontal: 40 }}>
291
- {featuredBusiness.map((bAry: any, idx) => (
292
- <View key={'f-listing_' + idx}>
293
- <BusinessFeaturedController
294
- key={bAry[0].id}
295
- business={bAry[0]}
296
- handleCustomClick={handleBusinessClick}
297
- orderType={orderState?.options?.type}
298
- />
299
- {bAry.length > 1 && (
296
+ {
297
+ isFocused && (
298
+ <OrderProgressWrapper>
299
+ <OrderProgress
300
+ {...props}
301
+ />
302
+ </OrderProgressWrapper>
303
+ )
304
+ }
305
+ {
306
+ !businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
307
+ <FeaturedWrapper>
308
+ <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('FEATURED_BUSINESS', 'Featured business')}</OText>
309
+ <ScrollView
310
+ showsHorizontalScrollIndicator={false}
311
+ nestedScrollEnabled
312
+ horizontal contentContainerStyle={{ paddingHorizontal: 40 }}>
313
+ {featuredBusiness.map((bAry: any, idx) => (
314
+ <View key={'f-listing_' + idx}>
300
315
  <BusinessFeaturedController
301
- key={bAry[1].id}
302
- business={bAry[1]}
316
+ key={bAry[0].id}
317
+ business={bAry[0]}
303
318
  handleCustomClick={handleBusinessClick}
304
319
  orderType={orderState?.options?.type}
305
320
  />
306
- )}
307
- </View>
308
- ))}
309
- </ScrollView>
310
- </FeaturedWrapper>
311
- )}
321
+ {bAry.length > 1 && (
322
+ <BusinessFeaturedController
323
+ key={bAry[1].id}
324
+ business={bAry[1]}
325
+ handleCustomClick={handleBusinessClick}
326
+ orderType={orderState?.options?.type}
327
+ />
328
+ )}
329
+ </View>
330
+ ))}
331
+ </ScrollView>
332
+ </FeaturedWrapper>
333
+ )
334
+ }
312
335
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
313
- {!businessId && !props.franchiseId && (
314
- <HighestRatedBusinesses onBusinessClick={handleBusinessClick} navigation={navigation} />
315
- )}
336
+ {
337
+ !businessId && !props.franchiseId && (
338
+ <HighestRatedBusinesses onBusinessClick={handleBusinessClick} navigation={navigation} />
339
+ )
340
+ }
316
341
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
317
342
  <ListWrapper>
318
- {!businessId && (
319
- <BusinessTypeFilter
320
- images={props.images}
321
- businessTypes={props.businessTypes}
322
- defaultBusinessType={props.defaultBusinessType}
323
- handleChangeBusinessType={handleChangeBusinessType}
324
- />
325
- )}
343
+ {!businessId && (
344
+ <BusinessTypeFilter
345
+ images={props.images}
346
+ businessTypes={props.businessTypes}
347
+ defaultBusinessType={props.defaultBusinessType}
348
+ handleChangeBusinessType={handleChangeBusinessType}
349
+ />
350
+ )}
326
351
  {!businessesList.loading && businessesList.businesses.length === 0 && (
327
352
  <NotFoundSource
328
353
  content={t(
@@ -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}
@@ -510,6 +510,7 @@ const CheckoutUI = (props: any) => {
510
510
  <WalletPaymentOptionContainer>
511
511
  <PaymentOptionWallet
512
512
  cart={cart}
513
+ businessId={cart?.business_id}
513
514
  />
514
515
  </WalletPaymentOptionContainer>
515
516
  )}
@@ -546,6 +547,7 @@ const CheckoutUI = (props: any) => {
546
547
  <OrderSummary
547
548
  cart={cart}
548
549
  isCartPending={cart?.status === 2}
550
+ onNavigationRedirect={onNavigationRedirect}
549
551
  />
550
552
  </>
551
553
  )}
@@ -76,6 +76,7 @@ export const ChCart = styled(ChPaymethods)``
76
76
 
77
77
  export const WalletPaymentOptionContainer = styled(ChPaymethods)`
78
78
  padding-bottom: 0;
79
+ margin-left: -20px;
79
80
  `
80
81
 
81
82
  export const ChPlaceOrderBtn = styled.View`
@@ -11,7 +11,8 @@ export const FacebookLogin = (props: any) => {
11
11
  const {
12
12
  handleErrors,
13
13
  handleLoading,
14
- handleSuccessFacebookLogin
14
+ handleSuccessFacebookLogin,
15
+ notificationState
15
16
  } = props
16
17
 
17
18
  const [, t] = useLanguage()
@@ -30,7 +31,14 @@ export const FacebookLogin = (props: any) => {
30
31
 
31
32
  const handleLoginClick = async (accessToken: string) => {
32
33
  try {
33
- const response = await ordering.users().authFacebook({ access_token: accessToken })
34
+ const body: any = {
35
+ access_token: accessToken
36
+ }
37
+ if (notificationState?.notification_token) {
38
+ body.notification_token = notificationState.notification_token
39
+ body.notification_app = notificationState.notification_app
40
+ }
41
+ const response = await ordering.users().authFacebook(body)
34
42
  if (!response.content.error) {
35
43
  if (handleSuccessFacebookLogin) {
36
44
  handleSuccessFacebookLogin(response.content.result)
@@ -38,9 +46,10 @@ export const FacebookLogin = (props: any) => {
38
46
  }
39
47
  } else {
40
48
  handleLoading && handleLoading(false)
49
+ handleErrors && handleErrors(response.content.result)
41
50
  logoutWithFacebook()
42
51
  }
43
- } catch (err) {
52
+ } catch (err: any) {
44
53
  handleLoading && handleLoading(false)
45
54
  handleErrors && handleErrors(err.message)
46
55
  }
@@ -48,7 +57,7 @@ export const FacebookLogin = (props: any) => {
48
57
 
49
58
  const loginWithFacebook = () => {
50
59
  handleLoading && handleLoading(true)
51
- LoginManager && LoginManager.logInWithPermissions(['public_profile']).then(
60
+ LoginManager && LoginManager.logInWithPermissions(['public_profile', 'email']).then(
52
61
  (login: any) => {
53
62
  if (login.isCancelled) {
54
63
  const err = t('LOGIN_WITH_FACEBOOK_CANCELLED', 'Login cancelled')
@@ -58,6 +67,9 @@ export const FacebookLogin = (props: any) => {
58
67
  AccessToken.getCurrentAccessToken().then((data: any) => {
59
68
  const accessToken = data.accessToken.toString();
60
69
  handleLoginClick(accessToken)
70
+ }).catch((err : any) => {
71
+ handleErrors && handleErrors(err.message)
72
+ handleLoading && handleLoading(false)
61
73
  });
62
74
  }
63
75
  },
@@ -68,7 +80,10 @@ export const FacebookLogin = (props: any) => {
68
80
  handleLoading && handleLoading(false)
69
81
  handleErrors && handleErrors(err)
70
82
  },
71
- );
83
+ ).catch((err : any) => {
84
+ handleErrors && handleErrors(err.message)
85
+ handleLoading && handleLoading(false)
86
+ });
72
87
  };
73
88
 
74
89
  const onPressButton = auth
@@ -48,7 +48,7 @@ export const Help = (props: HelpParams) => {
48
48
 
49
49
  <LastOrdersContainer>
50
50
  <OText size={18} weight={600}>{t('LAST_ORDERS', 'Last Orders')}</OText>
51
- <LastOrders businessId={props.businessId} onRedirect={onRedirect} />
51
+ <LastOrders {...props} onRedirect={onRedirect} />
52
52
  </LastOrdersContainer>
53
53
  </>
54
54
  )
@@ -5,11 +5,11 @@ import { StyleSheet, View } from 'react-native';
5
5
  import { OButton, OIcon, OText } from '../shared';
6
6
  import { LanguageSelector } from '../LanguageSelector';
7
7
  import { TouchableOpacity } from 'react-native-gesture-handler';
8
- import { useWindowDimensions } from 'react-native';
8
+ import { useWindowDimensions, Platform } from 'react-native';
9
9
 
10
10
  export const Home = (props: any) => {
11
11
  const { onNavigationRedirect } = props;
12
- const { width } = useWindowDimensions();
12
+ const { width, height } = useWindowDimensions();
13
13
  const [, t] = useLanguage();
14
14
  const [orderState] = useOrder();
15
15
 
@@ -18,7 +18,9 @@ export const Home = (props: any) => {
18
18
  return (
19
19
  <View style={styles.container}>
20
20
  <View>
21
- <LanguageSelector />
21
+ <View style={{paddingTop: (height <= 756 && Platform.OS !== 'ios') ? (height * 0.05) : 0 }}>
22
+ <LanguageSelector />
23
+ </View>
22
24
  <OIcon
23
25
  src={theme.images.logos.logotypeInvert}
24
26
  style={{