ordering-ui-react-native 0.16.12 → 0.16.15

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 (34) hide show
  1. package/package.json +2 -1
  2. package/src/navigators/CheckoutNavigator.tsx +6 -0
  3. package/src/navigators/HomeNavigator.tsx +6 -0
  4. package/src/pages/MultiCheckout.tsx +31 -0
  5. package/src/pages/MultiOrdersDetails.tsx +27 -0
  6. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  7. package/themes/original/index.tsx +6 -0
  8. package/themes/original/src/components/BusinessItemAccordion/index.tsx +3 -2
  9. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +0 -2
  10. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  11. package/themes/original/src/components/BusinessProductsList/index.tsx +9 -26
  12. package/themes/original/src/components/BusinessProductsListing/index.tsx +14 -7
  13. package/themes/original/src/components/BusinessesListing/index.tsx +21 -10
  14. package/themes/original/src/components/Cart/index.tsx +17 -8
  15. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  16. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  17. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  18. package/themes/original/src/components/MultiCheckout/index.tsx +291 -0
  19. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  20. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +370 -0
  21. package/themes/original/src/components/MultiOrdersDetails/index.tsx +250 -0
  22. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  23. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  24. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  25. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +150 -0
  26. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  27. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +51 -0
  28. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  29. package/themes/original/src/components/OrdersOption/index.tsx +102 -28
  30. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  31. package/themes/original/src/components/StripeElementsForm/index.tsx +10 -2
  32. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  33. package/themes/original/src/components/UserDetails/index.tsx +1 -1
  34. package/themes/original/src/types/index.tsx +43 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.16.12",
3
+ "version": "0.16.15",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -109,6 +109,7 @@
109
109
  "react-native-sound": "^0.11.1",
110
110
  "react-native-swipe-gestures": "^1.0.5",
111
111
  "react-native-swiper": "^1.6.0",
112
+ "react-native-tracking-transparency": "^0.1.1",
112
113
  "react-native-uuid": "^2.0.1",
113
114
  "react-native-vector-icons": "^7.1.0",
114
115
  "react-native-webview": "^11.6.4",
@@ -6,6 +6,7 @@ import AddressForm from '../pages/AddressForm'
6
6
  import CartList from '../pages/CartList'
7
7
  import CheckoutPage from '../pages/Checkout';
8
8
  import BusinessProductsList from '../pages/BusinessProductsList';
9
+ import MultiCheckout from '../pages/MultiCheckout';
9
10
 
10
11
  const Stack = createStackNavigator();
11
12
 
@@ -53,6 +54,11 @@ const CheckoutNavigator = (props: any) => {
53
54
  component={AddressForm}
54
55
  options={{ headerShown: false }}
55
56
  />
57
+ <Stack.Screen
58
+ name="MultiCheckout"
59
+ children={() => <MultiCheckout {...checkoutProps} />}
60
+ options={{ headerShown: false }}
61
+ />
56
62
  </Stack.Navigator>
57
63
  );
58
64
  }
@@ -23,6 +23,7 @@ import HelpAccountAndPayment from '../pages/HelpAccountAndPayment'
23
23
  import Sessions from '../pages/Sessions';
24
24
  import Splash from '../pages/Splash';
25
25
  import ProductDetails from '../pages/ProductDetails';
26
+ import MultiOrdersDetails from '../pages/MultiOrdersDetails';
26
27
  const Stack = createStackNavigator();
27
28
 
28
29
  const HomeNavigator = (e : any) => {
@@ -170,6 +171,11 @@ const HomeNavigator = (e : any) => {
170
171
  component={Sessions}
171
172
  options={{ headerShown: false }}
172
173
  />
174
+ <Stack.Screen
175
+ name="MultiOrdersDetails"
176
+ component={MultiOrdersDetails}
177
+ options={{ headerShown: false }}
178
+ />
173
179
  </>
174
180
  )}
175
181
  </>
@@ -0,0 +1,31 @@
1
+ import React from 'react'
2
+ import { Platform, KeyboardAvoidingView, StyleSheet } from 'react-native'
3
+ import { MultiCheckout as MultiCheckoutController } from '../../themes/original/src/components/MultiCheckout'
4
+
5
+ const MultiCheckout = (props: any) => {
6
+ const multiCheckoutProps = {
7
+ ...props,
8
+ onPlaceOrderClick: (orderUuids: any) => {
9
+ props.navigation.navigate('MultiOrdersDetails', { orderUuids: orderUuids, isFromMultiCheckout: true })
10
+ }
11
+ }
12
+
13
+ return (
14
+ <KeyboardAvoidingView
15
+ enabled
16
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
17
+ style={styles.container}
18
+ >
19
+ <MultiCheckoutController {...multiCheckoutProps} />
20
+ </KeyboardAvoidingView>
21
+ )
22
+ }
23
+
24
+ const styles = StyleSheet.create({
25
+ container: {
26
+ flexGrow: 1,
27
+ paddingBottom: 70,
28
+ },
29
+ });
30
+
31
+ export default MultiCheckout
@@ -0,0 +1,27 @@
1
+ import React from 'react'
2
+ import { Platform } from 'react-native'
3
+ import { MultiOrdersDetails as MultiOrdersDetailsController } from '../../themes/original/src/components/MultiOrdersDetails'
4
+ import styled from 'styled-components/native';
5
+
6
+ const SafeAreaContainer = styled.SafeAreaView`
7
+ flex: 1;
8
+ background-color: ${(props: any) => props.theme.colors.backgroundPage};
9
+ padding-top: ${Platform.OS === 'ios' ? '0px' : '24px'};
10
+ `;
11
+
12
+ const MultiOrdersDetails = ({ navigation, route }: any) => {
13
+ const multiOrdersDetailsProps = {
14
+ navigation,
15
+ orderUuids: route.params?.orderUuids || [],
16
+ isFromMultiCheckout: route.params?.isFromMultiCheckout,
17
+ onRedirectPage: () => navigation.navigate('BusinessList')
18
+ }
19
+
20
+ return (
21
+ <SafeAreaContainer>
22
+ <MultiOrdersDetailsController {...multiOrdersDetailsProps} />
23
+ </SafeAreaContainer>
24
+ )
25
+ }
26
+
27
+ export default MultiOrdersDetails
@@ -327,6 +327,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
327
327
  justifyContent: 'center',
328
328
  paddingVertical: 10,
329
329
  paddingHorizontal: 80,
330
+ position: 'absolute'
330
331
  },
331
332
  showButton: {
332
333
  alignSelf: 'center',
@@ -490,14 +491,14 @@ export const DriverMap = (props: GoogleMapsParams) => {
490
491
  </View>
491
492
  </View>
492
493
  </View>
493
- <View style={styles.buttonContainer}>
494
+ <View style={{
495
+ ...styles.buttonContainer,
496
+ bottom: showAcceptOrReject ? 80 : 0
497
+ }}>
494
498
  <OButton
495
499
  imgRightSrc=''
496
500
  textStyle={{ color: theme.colors.white }}
497
- style={{
498
- ...styles.showButton,
499
- bottom: showAcceptOrReject ? 80 : 0
500
- }}
501
+ style={styles.showButton}
501
502
  onClick={() => showLocation({
502
503
  latitude: destination.latitude,
503
504
  longitude: destination.longitude,
@@ -32,6 +32,7 @@ import { ReviewDriver } from './src/components/ReviewDriver';
32
32
  import { UserProfile } from './src/components/UserProfile';
33
33
  import { MessageListing } from './src/components/MessageListing';
34
34
  import { Messages } from './src/components/Messages';
35
+ import { MyOrders } from './src/components/MyOrders';
35
36
  import { Help } from './src/components/Help';
36
37
  import { HelpAccountAndPayment } from './src/components/HelpAccountAndPayment';
37
38
  import { HelpGuide } from './src/components/HelpGuide';
@@ -47,6 +48,8 @@ import { UpsellingProducts } from './src/components/UpsellingProducts';
47
48
  import { UserVerification } from './src/components/UserVerification';
48
49
  import { BusinessListingSearch } from './src/components/BusinessListingSearch';
49
50
  import { LastOrders } from './src/components/LastOrders';
51
+ import { MultiCheckout } from './src/components/MultiCheckout'
52
+ import { MultiOrdersDetails } from './src/components/MultiOrdersDetails'
50
53
  import NavBar from './src/components/NavBar';
51
54
  import { BusinessTypeFilter } from './src/components/BusinessTypeFilter';
52
55
  import { BusinessController } from './src/components/BusinessController';
@@ -187,6 +190,8 @@ export {
187
190
  HelpAccountAndPayment,
188
191
  HelpGuide,
189
192
  HelpOrder,
193
+ MultiCheckout,
194
+ MultiOrdersDetails,
190
195
  NetworkError,
191
196
  NotFoundSource,
192
197
  OrderTypeSelector,
@@ -240,6 +245,7 @@ export {
240
245
  UserFormDetailsUI,
241
246
  WalletTransactionItem,
242
247
  Promotions,
248
+ MyOrders,
243
249
  ORDER_TYPES,
244
250
  USER_TYPE,
245
251
 
@@ -21,7 +21,8 @@ export const BusinessItemAccordion = (props: any) => {
21
21
  singleBusiness,
22
22
  handleClearProducts,
23
23
  handleClickCheckout,
24
- checkoutButtonDisabled
24
+ checkoutButtonDisabled,
25
+ isMultiCheckout
25
26
  } = props
26
27
 
27
28
  const [orderState] = useOrder();
@@ -139,7 +140,7 @@ export const BusinessItemAccordion = (props: any) => {
139
140
  )}
140
141
  </BIActions>
141
142
  </BIHeader>
142
- {!isActive && !isClosed && !!isProducts && (
143
+ {!isActive && !isClosed && !!isProducts && !isMultiCheckout && (
143
144
  <PriceContainer>
144
145
  <OText>{parsePrice(cart?.total)}</OText>
145
146
  {cart?.valid_products && (
@@ -7,10 +7,8 @@ export const BIContainer = styled.View`
7
7
  opacity: 1;
8
8
  border-radius: 7.6px;
9
9
  overflow: hidden;
10
- min-height: 120px;
11
10
  ${(props: any) => props.isClosed && css`
12
11
  opacity: 0.5;
13
- min-height: 60px;
14
12
  `}
15
13
  `
16
14
 
@@ -0,0 +1,44 @@
1
+ import React from 'react'
2
+ import { OModal, OText, OIcon } from '../../shared'
3
+ import { ScrollView } from 'react-native'
4
+ import { useUtils } from 'ordering-components/native'
5
+
6
+ interface CategoryDescriptionParams {
7
+ openDescription?: {name: string, image: string, description: string} | null,
8
+ setOpenDescription: any;
9
+ }
10
+
11
+ function categoryDescriptionPropsAreEqual(prev : any, next : any) {
12
+ return prev.openDescription === next.openDescription
13
+ }
14
+
15
+ const CategoryDescription = (props : CategoryDescriptionParams) => {
16
+ const [{ optimizeImage }] = useUtils()
17
+ return (
18
+ <OModal
19
+ open={!!props.openDescription}
20
+ onClose={() => props.setOpenDescription(null)}
21
+ styleContainerCloseButton={{
22
+ marginLeft: -37,
23
+ width: 55,
24
+ height: 55,
25
+ marginTop: 2
26
+ }}
27
+ >
28
+ <OText size={20} style={{ paddingLeft: 70, paddingRight: 20, bottom: 25 }}>{props.openDescription?.name}</OText>
29
+ <ScrollView style={{ padding: 20 }}>
30
+ {!!props.openDescription?.image && (
31
+ <OIcon
32
+ url={optimizeImage(props.openDescription?.image, 'h_100,c_limit')}
33
+ width={240}
34
+ height={240}
35
+ style={{ borderRadius: 7.6 }}
36
+ />
37
+ )}
38
+ <OText mBottom={60}>{props.openDescription?.description}</OText>
39
+ </ScrollView>
40
+ </OModal>
41
+ )
42
+ }
43
+
44
+ export const CategoryDescriptionMemoized = React.memo(CategoryDescription,categoryDescriptionPropsAreEqual)
@@ -10,6 +10,7 @@ import { View, ScrollView } from 'react-native';
10
10
  import { StyleSheet } from 'react-native';
11
11
  import { useTheme } from 'styled-components/native';
12
12
  import { shape } from '../../utils'
13
+ import { CategoryDescriptionMemoized } from './CategoryDescription';
13
14
 
14
15
  const BusinessProductsListUI = (props: BusinessProductsListParams) => {
15
16
  const {
@@ -33,8 +34,8 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
33
34
  subcategoriesSelected,
34
35
  onClickCategory,
35
36
  lazyLoadProductsRecommended,
36
- isFiltMode,
37
- handleUpdateProducts
37
+ handleUpdateProducts,
38
+ isFiltMode
38
39
  } = props;
39
40
 
40
41
  const [, t] = useLanguage();
@@ -104,7 +105,6 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
104
105
  )
105
106
  }
106
107
 
107
-
108
108
  return (
109
109
  <ProductsContainer renderToHardwareTextureAndroid={categoryState.loading || isBusinessLoading}>
110
110
  <HeaderWrapper>
@@ -317,29 +317,12 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
317
317
  <OText>{e}</OText>
318
318
  </ErrorMessage>
319
319
  ))}
320
- <OModal
321
- open={!!openDescription}
322
- onClose={() => setOpenDescription(null)}
323
- styleContainerCloseButton={{
324
- marginLeft: -30,
325
- width: 55,
326
- height: 55,
327
- marginTop: 2
328
- }}
329
- >
330
- <OText size={20} style={{ paddingLeft: 70, paddingRight: 20, bottom: 25 }}>{openDescription?.name}</OText>
331
- <ScrollView style={{ padding: 20 }}>
332
- {!!openDescription?.image && (
333
- <OIcon
334
- url={optimizeImage(openDescription?.image, 'h_100,c_limit')}
335
- width={240}
336
- height={240}
337
- style={{ borderRadius: 7.6 }}
338
- />
339
- )}
340
- <OText mBottom={60}>{openDescription?.description}</OText>
341
- </ScrollView>
342
- </OModal>
320
+ {!!openDescription && (
321
+ <CategoryDescriptionMemoized
322
+ openDescription={openDescription}
323
+ setOpenDescription={setOpenDescription}
324
+ />
325
+ )}
343
326
  </ProductsContainer>
344
327
  );
345
328
  };
@@ -102,6 +102,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
102
102
  const [isCategoryClicked, setCategoryClicked] = useState(false)
103
103
  const [subcategoriesSelected, setSubcategoriesSelected] = useState([])
104
104
 
105
+ const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
105
106
  const currentCart: any = Object.values(orderState.carts).find((cart: any) => cart?.business?.slug === business?.slug) ?? {}
106
107
  const isOpenFiltProducts = isOpenSearchBar && !!searchValue
107
108
  const filtProductsHeight = Platform.OS === 'ios' ? 0 : 35
@@ -123,13 +124,19 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
123
124
  }
124
125
 
125
126
  const handleUpsellingPage = () => {
126
- onRedirect('CheckoutNavigator', {
127
- screen: 'CheckoutPage',
128
- cartUuid: currentCart?.uuid,
129
- businessLogo: logo,
130
- businessName: business?.name,
131
- cartTotal: currentCart?.total
132
- })
127
+ if (isCheckoutMultiBusinessEnabled) {
128
+ onRedirect('CheckoutNavigator', {
129
+ screen: 'MultiCheckout'
130
+ })
131
+ } else {
132
+ onRedirect('CheckoutNavigator', {
133
+ screen: 'CheckoutPage',
134
+ cartUuid: currentCart?.uuid,
135
+ businessLogo: logo,
136
+ businessName: business?.name,
137
+ cartTotal: currentCart?.total
138
+ })
139
+ }
133
140
  setOpenUpselling(false)
134
141
  }
135
142
 
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
3
3
  import Geolocation from '@react-native-community/geolocation'
4
+ import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
4
5
  import {
5
6
  View,
6
7
  StyleSheet,
@@ -194,17 +195,27 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
194
195
  }
195
196
  }
196
197
 
198
+ const checkUserLocation = async () => {
199
+ let trackingStatus = await getTrackingStatus()
200
+ if (trackingStatus === 'not-determined') {
201
+ trackingStatus = await requestTrackingPermission()
202
+ }
203
+ if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
204
+ Geolocation.getCurrentPosition((pos) => {
205
+ const crd = pos.coords
206
+ const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
207
+ if (distance > 20) setIsFarAway(true)
208
+ else setIsFarAway(false)
209
+ }, (err) => {
210
+ console.log(`ERROR(${err.code}): ${err.message}`)
211
+ }, {
212
+ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
213
+ })
214
+ }
215
+ }
216
+
197
217
  useEffect(() => {
198
- Geolocation.getCurrentPosition((pos) => {
199
- const crd = pos.coords
200
- const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
201
- if (distance > 20) setIsFarAway(true)
202
- else setIsFarAway(false)
203
- }, (err) => {
204
- console.log(`ERROR(${err.code}): ${err.message}`)
205
- }, {
206
- enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
207
- })
218
+ checkUserLocation()
208
219
  }, [orderState?.options?.address?.location])
209
220
 
210
221
  useEffect(() => {
@@ -39,7 +39,8 @@ const CartUI = (props: any) => {
39
39
  handleChangeComment,
40
40
  commentState,
41
41
  onNavigationRedirect,
42
- handleRemoveOfferClick
42
+ handleRemoveOfferClick,
43
+ isMultiCheckout
43
44
  } = props
44
45
 
45
46
  const theme = useTheme();
@@ -59,6 +60,7 @@ const CartUI = (props: any) => {
59
60
 
60
61
  const isCartPending = cart?.status === 2
61
62
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
63
+ const isCheckoutMultiBusinessEnabled: Boolean = configs?.checkout_multi_business_enabled?.value === '1'
62
64
 
63
65
  const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
64
66
  const businessId = business?.business_id ?? null
@@ -96,13 +98,19 @@ const CartUI = (props: any) => {
96
98
  const handleUpsellingPage = () => {
97
99
  setOpenUpselling(false)
98
100
  setCanOpenUpselling(false)
99
- props.onNavigationRedirect('CheckoutNavigator', {
100
- screen: 'CheckoutPage',
101
- cartUuid: cart?.uuid,
102
- businessLogo: cart?.business?.logo,
103
- businessName: cart?.business?.name,
104
- cartTotal: cart?.total
105
- })
101
+ if (isCheckoutMultiBusinessEnabled) {
102
+ props.onNavigationRedirect('CheckoutNavigator', {
103
+ screen: 'MultiCheckout'
104
+ })
105
+ } else {
106
+ props.onNavigationRedirect('CheckoutNavigator', {
107
+ screen: 'CheckoutPage',
108
+ cartUuid: cart?.uuid,
109
+ businessLogo: cart?.business?.logo,
110
+ businessName: cart?.business?.name,
111
+ cartTotal: cart?.total
112
+ })
113
+ }
106
114
  }
107
115
 
108
116
  const getIncludedTaxes = () => {
@@ -165,6 +173,7 @@ const CartUI = (props: any) => {
165
173
  handleChangeStore={() => setOpenChangeStore(true)}
166
174
  handleClickCheckout={() => setOpenUpselling(true)}
167
175
  checkoutButtonDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
176
+ isMultiCheckout={isMultiCheckout}
168
177
  >
169
178
  {cart?.products?.length > 0 && cart?.products.map((product: any, i: number) => (
170
179
  <ProductItemAccordion
@@ -1,4 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react'
2
+ import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
2
3
  import Geolocation from '@react-native-community/geolocation'
3
4
  import Geocoder from 'react-native-geocoding'
4
5
  import { GpsButtonStyle } from './styles'
@@ -55,14 +56,20 @@ export const GPSButton = (props: any) => {
55
56
  })
56
57
  }
57
58
 
58
- const getCurrentPosition = () => {
59
- setLoading(true);
60
- Geolocation.getCurrentPosition((pos) => {
61
- geoCodePosition(pos.coords);
62
- }, (err) => {
63
- setLoading(false);
64
- console.log(err);
65
- });
59
+ const getCurrentPosition = async () => {
60
+ let trackingStatus = await getTrackingStatus()
61
+ if (trackingStatus === 'not-determined') {
62
+ trackingStatus = await requestTrackingPermission()
63
+ }
64
+ if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
65
+ setLoading(true);
66
+ Geolocation.getCurrentPosition((pos) => {
67
+ geoCodePosition(pos.coords);
68
+ }, (err) => {
69
+ setLoading(false);
70
+ console.log(err);
71
+ });
72
+ }
66
73
  }
67
74
 
68
75
  useEffect(() => {