ordering-ui-react-native 0.16.10 → 0.16.13

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.16.10",
3
+ "version": "0.16.13",
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",
@@ -102,7 +102,7 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
102
102
  shippingMethods: [
103
103
  {
104
104
  amount: cart?.balance?.toString() ?? cart?.total?.toString?.(),
105
- identifier: 'DPS',
105
+ identifier: 'standard',
106
106
  label: 'Courier',
107
107
  detail: 'Delivery',
108
108
  type: 'final',
@@ -125,7 +125,6 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
125
125
  last4: paymentMethod.Card.last4
126
126
  }
127
127
  })
128
- onCancel()
129
128
  }
130
129
  }
131
130
 
@@ -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,
@@ -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: -30,
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>
@@ -118,7 +118,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
118
118
  !subcategoriesSelected.find((subcategory: any) => subcategory?.parent_category_id === category?.id) ||
119
119
  subcategoriesSelected?.some((subcategory: any) => subcategory.id === product?.category_id))
120
120
  ?.sort((a: any, b: any) => a.rank - b.rank)
121
- ?.map((product: any, i : number) => (
121
+ ?.map((product: any, i: number) => (
122
122
  <SingleProductCard
123
123
  key={'prod_' + product.id + `_${i}`}
124
124
  isSoldOut={product.inventoried && !product.quantity}
@@ -317,23 +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
- >
324
- <OText size={20} style={{paddingLeft: 70, paddingRight: 20, bottom: 25}}>{openDescription?.name}</OText>
325
- <ScrollView style={{ padding: 20 }}>
326
- {!!openDescription?.image && (
327
- <OIcon
328
- url={optimizeImage(openDescription?.image, 'h_100,c_limit')}
329
- width={240}
330
- height={240}
331
- style={{ borderRadius: 7.6 }}
332
- />
333
- )}
334
- <OText mBottom={60}>{openDescription?.description}</OText>
335
- </ScrollView>
336
- </OModal>
320
+ {!!openDescription && (
321
+ <CategoryDescriptionMemoized
322
+ openDescription={openDescription}
323
+ setOpenDescription={setOpenDescription}
324
+ />
325
+ )}
337
326
  </ProductsContainer>
338
327
  );
339
328
  };
@@ -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(() => {
@@ -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(() => {
@@ -1027,7 +1027,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1027
1027
  )}
1028
1028
  </View>
1029
1029
  <OText>
1030
- -{parsePrice(event.amount)}
1030
+ -{parsePrice(event.amount, {isTruncable: true})}
1031
1031
  </OText>
1032
1032
  </View>
1033
1033
  ))}
@@ -45,7 +45,7 @@ const PaymentOptionWalletUI = (props: any) => {
45
45
  new Array(walletsState.result?.length).fill(false)
46
46
  );
47
47
 
48
- const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate)}`
48
+ const creditBalance: any = (wallet: any) => ` = ${parsePrice(wallet.balance / wallet.redemption_rate, { isTruncable: true })}`
49
49
 
50
50
  const walletName: any = {
51
51
  cash: {
@@ -87,65 +87,65 @@ const PaymentOptionWalletUI = (props: any) => {
87
87
  {!walletsState.loading &&
88
88
  !walletsState.error &&
89
89
  walletsState.result?.length > 0 &&
90
- (
91
- <>
92
- {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
93
- <Container
94
- key={wallet.id}
95
- isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
- onPress={() => handleOnChange(idx, wallet)}
97
- disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
98
- >
99
- <SectionLeft>
100
- {checkedState[idx] ? (
101
- <MaterialCommunityIcons
102
- name="checkbox-marked"
103
- size={25}
104
- color={theme.colors.primary}
105
- />
106
- ) : (
107
- <MaterialCommunityIcons
108
- name="checkbox-blank-outline"
109
- size={25}
110
- color={theme.colors.disabled}
111
- />
112
- )}
113
- <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
114
- <View>
115
- <OText
116
- style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ?{
117
- color: theme.colors.disabled
118
- } : {}}
119
- >
120
- {walletName[wallet.type]?.name}
121
- </OText>
90
+ (
91
+ <>
92
+ {walletsState.result?.map((wallet: any, idx: any) => wallet.valid && wallet.balance >= 0 && walletName[wallet.type]?.isActive && (
93
+ <Container
94
+ key={wallet.id}
95
+ isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
+ onPress={() => handleOnChange(idx, wallet)}
97
+ disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
98
+ >
99
+ <SectionLeft>
100
+ {checkedState[idx] ? (
101
+ <MaterialCommunityIcons
102
+ name="checkbox-marked"
103
+ size={25}
104
+ color={theme.colors.primary}
105
+ />
106
+ ) : (
107
+ <MaterialCommunityIcons
108
+ name="checkbox-blank-outline"
109
+ size={25}
110
+ color={theme.colors.disabled}
111
+ />
112
+ )}
113
+ <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
114
+ <View>
115
+ <OText
116
+ style={((cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0) ? {
117
+ color: theme.colors.disabled
118
+ } : {}}
119
+ >
120
+ {walletName[wallet.type]?.name}
121
+ </OText>
122
+ </View>
122
123
  </View>
123
- </View>
124
- </SectionLeft>
125
-
126
- <View style={{maxWidth: '35%', alignItems: 'flex-end' }}>
127
- {wallet.type === 'cash' && (
128
- <OText>
129
- {parsePrice(wallet?.balance)}
130
- </OText>
131
- )}
132
- {wallet.type === 'credit_point' && (
133
- <OText>
134
- <OText color={theme.colors.primary} weight='bold'>
135
- {`${wallet?.balance} ${t('POINTS', 'Points')}`}
124
+ </SectionLeft>
125
+
126
+ <View style={{ maxWidth: '35%', alignItems: 'flex-end' }}>
127
+ {wallet.type === 'cash' && (
128
+ <OText>
129
+ {parsePrice(wallet?.balance, { isTruncable: true })}
136
130
  </OText>
131
+ )}
132
+ {wallet.type === 'credit_point' && (
137
133
  <OText>
138
- {wallet?.balance > 0
139
- ? creditBalance(wallet)
140
- : null}
134
+ <OText color={theme.colors.primary} weight='bold'>
135
+ {`${wallet?.balance} ${t('POINTS', 'Points')}`}
136
+ </OText>
137
+ <OText>
138
+ {wallet?.balance > 0
139
+ ? creditBalance(wallet)
140
+ : null}
141
+ </OText>
141
142
  </OText>
142
- </OText>
143
- )}
144
- </View>
145
- </Container>
146
- ))}
147
- </>
148
- )}
143
+ )}
144
+ </View>
145
+ </Container>
146
+ ))}
147
+ </>
148
+ )}
149
149
 
150
150
  {walletsState?.loading && (
151
151
  <View>
@@ -21,6 +21,7 @@ interface Props {
21
21
  isNotDecoration?: boolean;
22
22
  styleCloseButton?: any,
23
23
  isAvoidKeyBoardView?: boolean;
24
+ styleContainerCloseButton?: any;
24
25
  }
25
26
  const KeyboardView = styled.KeyboardAvoidingView`
26
27
  flex-grow: 1;
@@ -45,6 +46,7 @@ const OModal = (props: Props): React.ReactElement => {
45
46
  isNotDecoration,
46
47
  style,
47
48
  styleCloseButton,
49
+ styleContainerCloseButton,
48
50
  isAvoidKeyBoardView
49
51
  } = props
50
52
 
@@ -55,7 +57,7 @@ const OModal = (props: Props): React.ReactElement => {
55
57
  {!entireModal ? (
56
58
  <View style={styles.centeredView}>
57
59
  <View style={titleSectionStyle ? titleSectionStyle : styles.titleSection}>
58
- <TouchableOpacity style={styles.wrapperIcon} onPress={onClose}>
60
+ <TouchableOpacity style={{...styles.wrapperIcon, ...styleContainerCloseButton}} onPress={onClose}>
59
61
  <OIcon
60
62
  src={theme.images.general.close}
61
63
  width={16}