ordering-ui-react-native 0.22.38 → 0.22.40

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.22.38",
3
+ "version": "0.22.40",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -69,11 +69,20 @@ export const DriverMap = (props: GoogleMapsParams) => {
69
69
  stopFollowUserLocation,
70
70
  } = useLocation();
71
71
 
72
- const origin = {
73
- latitude: initialPosition.latitude,
74
- longitude: initialPosition.longitude,
72
+ const destination = {
73
+ latitude: typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat || 0,
74
+ longitude: typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng || 0
75
75
  };
76
- const destination = { latitude: location.lat, longitude: location.lng };
76
+
77
+ const parsedInitialPosition = {
78
+ latitude: typeof initialPosition.latitude === 'string' ? parseFloat(initialPosition.latitude) || 0 : initialPosition.latitude || 0,
79
+ longitude: typeof initialPosition.longitude === 'string' ? parseFloat(initialPosition.longitude) || 0 : initialPosition.longitude || 0,
80
+ }
81
+
82
+ const parsedUserLocation = {
83
+ latitude: typeof userLocation?.latitude === 'string' ? parseFloat(userLocation?.latitude) || 0 : userLocation?.latitude || 0,
84
+ longitude: typeof userLocation?.longitude === 'string' ? parseFloat(userLocation?.longitude) || 0 : userLocation?.longitude || 0
85
+ }
77
86
 
78
87
  useEffect(() => {
79
88
  if (isToFollow) {
@@ -161,7 +170,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
161
170
  if (driverUpdateLocation.error) return;
162
171
 
163
172
  calculateDistance(
164
- { lat: userLocation.latitude, lng: userLocation.longitude },
173
+ { lat: parsedUserLocation.latitude, lng: parsedUserLocation.longitude },
165
174
  destination,
166
175
  );
167
176
  // geocodePosition(userLocation);
@@ -169,13 +178,13 @@ export const DriverMap = (props: GoogleMapsParams) => {
169
178
  if (!following.current) return;
170
179
  fitCoordinates();
171
180
 
172
- const { latitude, longitude } = userLocation;
181
+ const { latitude, longitude } = parsedUserLocation;
173
182
 
174
183
  mapRef.current?.animateCamera({
175
184
  center: { latitude, longitude },
176
185
  });
177
186
 
178
- }, [userLocation]);
187
+ }, [parsedUserLocation]);
179
188
 
180
189
  const handleArrowBack: any = () => {
181
190
  setDriverUpdateLocation?.({
@@ -241,8 +250,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
241
250
  [
242
251
  { latitude: location.lat, longitude: location.lng },
243
252
  {
244
- latitude: initialPosition.latitude,
245
- longitude: initialPosition.longitude,
253
+ latitude: parsedInitialPosition.latitude,
254
+ longitude: parsedInitialPosition.longitude,
246
255
  },
247
256
  ],
248
257
  {
@@ -255,7 +264,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
255
264
 
256
265
  useEffect(() => {
257
266
  const interval = setInterval(() => {
258
- if (initialPosition.latitude !== 0 && autoFit.current) {
267
+ if (parsedInitialPosition.latitude !== 0 && autoFit.current) {
259
268
  if (mapRef.current) {
260
269
  fitCoordinates();
261
270
  autoFit.current = false;
@@ -263,7 +272,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
263
272
  }
264
273
  }, 1000);
265
274
  return () => clearInterval(interval);
266
- }, [initialPosition]);
275
+ }, [parsedInitialPosition]);
267
276
 
268
277
  const fitCoordinatesZoom = () => {
269
278
  following.current = false;
@@ -346,8 +355,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
346
355
  ref={mapRef}
347
356
  provider={PROVIDER_GOOGLE}
348
357
  initialRegion={{
349
- latitude: initialPosition.latitude,
350
- longitude: initialPosition.longitude,
358
+ latitude: parsedInitialPosition.latitude,
359
+ longitude: parsedInitialPosition.longitude,
351
360
  latitudeDelta: 0.001,
352
361
  longitudeDelta: 0.001 * ASPECT_RATIO,
353
362
  }}
@@ -369,8 +378,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
369
378
  <>
370
379
  <Marker
371
380
  coordinate={{
372
- latitude: location.lat,
373
- longitude: location.lng,
381
+ latitude: destination.latitude,
382
+ longitude: destination.longitude
374
383
  }}
375
384
  title={location.title}>
376
385
  <Icon
@@ -387,7 +396,10 @@ export const DriverMap = (props: GoogleMapsParams) => {
387
396
  />
388
397
  </View>
389
398
  </Marker>
390
- <Marker coordinate={userLocation}>
399
+ <Marker coordinate={{
400
+ latitude: parsedUserLocation.latitude,
401
+ longitude: parsedUserLocation.longitude
402
+ }}>
391
403
  <View style={styles.driverIcon}>
392
404
  <OIcon
393
405
  style={styles.image}
@@ -401,8 +413,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
401
413
  ) : (
402
414
  <Marker
403
415
  coordinate={{
404
- latitude: userLocation.latitude,
405
- longitude: userLocation.longitude,
416
+ latitude: parsedUserLocation.latitude,
417
+ longitude: parsedUserLocation.longitude
406
418
  }}
407
419
  title={markerTitle || t('YOUR_LOCATION', 'Your Location')}
408
420
  />
@@ -516,8 +528,8 @@ export const DriverMap = (props: GoogleMapsParams) => {
516
528
  options={{
517
529
  latitude: destination.latitude,
518
530
  longitude: destination.longitude,
519
- sourceLatitude: userLocation.latitude,
520
- sourceLongitude: userLocation.longitude,
531
+ sourceLatitude: parsedUserLocation.latitude,
532
+ sourceLongitude: parsedUserLocation.longitude,
521
533
  naverCallerName: 'com.deliveryapp',
522
534
  dialogTitle: t('SHOW_IN_OTHER_MAPS', 'Show in other maps'),
523
535
  dialogMessage: t('WHAT_APP_WOULD_YOU_USE', 'What app would you like to use?'),
@@ -539,7 +551,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
539
551
  secondButton={true}
540
552
  firstColorCustom={theme.colors.red}
541
553
  secondColorCustom={theme.colors.green}
542
- widthButton={isHideRejectButtons ? '100%': '45%'}
554
+ widthButton={isHideRejectButtons ? '100%' : '45%'}
543
555
  isPadding
544
556
  isHideRejectButtons={isHideRejectButtons}
545
557
  />
@@ -50,12 +50,16 @@ export const GoogleMap = (props: GoogleMapsParams) => {
50
50
  const ASPECT_RATIO = width / height;
51
51
  const [isMapReady, setIsMapReady] = useState(false);
52
52
  const [markerPosition, setMarkerPosition] = useState({
53
- latitude: locations ? locations[locations.length - 1].lat : location.lat,
54
- longitude: locations ? locations[locations.length - 1].lng : location.lng,
53
+ latitude: locations
54
+ ? typeof locations[locations.length - 1].lat === 'string' ? parseFloat(locations[locations.length - 1].lat) || 0 : locations[locations.length - 1].lat || 0
55
+ : typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat || 0,
56
+ longitude: locations
57
+ ? typeof locations[locations.length - 1].lng === 'string' ? parseFloat(locations[locations.length - 1].lng) || 0 : locations[locations.length - 1].lng || 0
58
+ : typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng || 0,
55
59
  });
56
60
  const [region, setRegion] = useState({
57
- latitude: location.lat,
58
- longitude: location.lng,
61
+ latitude: typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat || 0,
62
+ longitude: typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng || 0,
59
63
  latitudeDelta: 0.001,
60
64
  longitudeDelta: 0.001 * ASPECT_RATIO,
61
65
  });
@@ -78,12 +82,15 @@ export const GoogleMap = (props: GoogleMapsParams) => {
78
82
  let MARKERS =
79
83
  locations &&
80
84
  locations.map((location: { lat: number; lng: number; level: number }) => {
81
- return location.level === 4 && driverLocation?.lat
85
+ return location.level === 4 && driverLocation?.lat && driverLocation?.lng
82
86
  ? {
83
- latitude: driverLocation?.lat,
84
- longitude: driverLocation?.lng,
87
+ latitude: typeof driverLocation?.lat === 'string' ? parseFloat(driverLocation?.lat) || 0 : driverLocation?.lat,
88
+ longitude: typeof driverLocation?.lng === 'string' ? parseFloat(driverLocation?.lng) || 0 : driverLocation?.lng,
85
89
  }
86
- : { latitude: location.lat, longitude: location.lng };
90
+ : {
91
+ latitude: typeof location?.lat === 'string' ? parseFloat(location?.lat) || 0 : location?.lat,
92
+ longitude: typeof location?.lng === 'string' ? parseFloat(location?.lng) || 0 : location?.lng
93
+ };
87
94
  });
88
95
 
89
96
  const handleArrowBack: any = () => {
@@ -859,8 +859,9 @@ const AddressFormUI = (props: AddressFormParams) => {
859
859
  ) : (
860
860
  <OButton
861
861
  text={t('CANCEL', 'Cancel')}
862
- bgColor={theme.colors.white}
863
- borderColor={theme.colors.primary}
862
+ bgColor={theme.colors.secundary}
863
+ borderColor={theme.colors.secundary}
864
+ textStyle={{ color: theme.colors.black }}
864
865
  style={{ borderRadius: 7.6, borderWidth: 1, shadowOpacity: 0 }}
865
866
  onClick={() => navigation?.canGoBack() && navigation.goBack()}
866
867
  />
@@ -887,6 +888,8 @@ const AddressFormUI = (props: AddressFormParams) => {
887
888
  <OButton
888
889
  text={t('SAVE', 'Save')}
889
890
  textStyle={{ color: theme.colors.white }}
891
+ bgColor={theme.colors.primary}
892
+ borderColor={theme.colors.primary}
890
893
  imgRightSrc={null}
891
894
  style={{ marginHorizontal: 30, marginBottom: 10 }}
892
895
  onClick={() => setSaveMapLocation(true)}
@@ -620,13 +620,15 @@ const CheckoutUI = (props: any) => {
620
620
  <OButton
621
621
  text={t('SIGN_UP', 'Sign up')}
622
622
  textStyle={{ color: theme.colors.white }}
623
+ bgColor={theme.colors.primary}
624
+ borderColor={theme.colors.primary}
623
625
  style={{ borderRadius: 7.6, marginTop: 20 }}
624
626
  onClick={() => setOpenModal({ ...openModal, signup: true })}
625
627
  />
626
628
  <OButton
627
629
  text={t('LOGIN', 'Login')}
628
- textStyle={{ color: theme.colors.primary }}
629
- bgColor={theme.colors.white}
630
+ textStyle={{ color: theme.colors.white }}
631
+ bgColor={theme.colors.primary}
630
632
  borderColor={theme.colors.primary}
631
633
  style={{ borderRadius: 7.6, marginTop: 20 }}
632
634
  onClick={() => setOpenModal({ ...openModal, login: true })}
@@ -5,7 +5,7 @@ import { TouchableOpacity, View } from 'react-native'
5
5
  import { OButton, OText } from '../shared';
6
6
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
7
7
 
8
- export const ActionButton = (props : any) => {
8
+ export const ActionButton = (props: any) => {
9
9
  const {
10
10
  navigation,
11
11
  isHaveWeight,
@@ -23,18 +23,20 @@ export const ActionButton = (props : any) => {
23
23
  handleUpdateGuest,
24
24
  actionStatus
25
25
  } = props
26
- const [,t] = useLanguage()
26
+ const [, t] = useLanguage()
27
27
  const [{ auth }] = useSession()
28
28
  const [orderState] = useOrder()
29
29
  const theme = useTheme()
30
- const [{ configs }] = useConfig()
30
+ const [{ configs }] = useConfig()
31
31
  const unaddressedTypes = configs?.unaddressed_order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
32
- const isAllowUnaddressOrderType = unaddressedTypes.includes(orderState?.options?.type)
33
-
32
+ const isAllowUnaddressOrderType = unaddressedTypes.includes(orderState?.options?.type)
34
33
  const saveErrors =
35
- orderState.loading ||
36
- maxProductQuantity === 0 ||
37
- Object.keys(errors)?.length > 0;
34
+ orderState.loading ||
35
+ maxProductQuantity === 0 ||
36
+ Object.keys(errors)?.length > 0;
37
+ const buttonColor = saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && ((productCart?.quantity + productAddedToCartLength) < product?.minimum_per_order)) || (product?.maximum_per_order && ((productCart?.quantity + productAddedToCartLength) > product?.maximum_per_order))
38
+
39
+
38
40
 
39
41
  return (
40
42
  <View
@@ -60,9 +62,9 @@ export const ActionButton = (props : any) => {
60
62
  color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
61
63
  fontSize: orderState.loading || editMode ? 10 : 14
62
64
  }}
65
+ bgColor={buttonColor ? theme.colors.lightGray : theme.colors.primary}
66
+ borderColor={!buttonColor ? theme.colors.white : theme.colors.primary}
63
67
  style={{
64
- backgroundColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && ((productCart?.quantity + productAddedToCartLength) < product?.minimum_per_order)) || (product?.maximum_per_order && ((productCart?.quantity + productAddedToCartLength) > product?.maximum_per_order)) ? theme.colors.lightGray : theme.colors.primary,
65
- borderColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && ((productCart?.quantity + productAddedToCartLength) < product?.minimum_per_order)) || (product?.maximum_per_order && ((productCart?.quantity + productAddedToCartLength) > product?.maximum_per_order)) ? theme.colors.white : theme.colors.primary,
66
68
  opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
67
69
  borderRadius: 7.6,
68
70
  height: 44,
@@ -182,7 +182,7 @@ const PromotionsUI = (props: PromotionParams) => {
182
182
  title={``}
183
183
  onClose={() => setOpenModal(false)}
184
184
  >
185
- <View style={{ padding: 20 }}>
185
+ <ScrollView style={{ padding: 20 }}>
186
186
  <OText style={{ alignSelf: 'center', fontWeight: '700' }} mBottom={20}>
187
187
  {offerSelected?.name} / {t('VALUE_OF_OFFER', 'Value of offer')}: {offerSelected?.rate_type === 1 ? `${offerSelected?.rate}%` : `${parsePrice(offerSelected?.rate)}`}
188
188
  </OText>
@@ -210,10 +210,7 @@ const PromotionsUI = (props: PromotionParams) => {
210
210
  <OText style={{ marginTop: 10, marginBottom: 10 }}>
211
211
  {t('AVAILABLE_BUSINESSES_FOR_OFFER', 'Available businesses for this offer')}:
212
212
  </OText>
213
- <ScrollView
214
- showsVerticalScrollIndicator={false}
215
- style={{ height: '68%' }}
216
- >
213
+ <View style={{ marginBottom: 70 }}>
217
214
  {offerSelected?.businesses?.map((business: any) => {
218
215
  return (
219
216
  <SingleBusinessOffer key={business.id}>
@@ -244,8 +241,8 @@ const PromotionsUI = (props: PromotionParams) => {
244
241
  </SingleBusinessOffer>
245
242
  )
246
243
  })}
247
- </ScrollView>
248
- </View>
244
+ </View>
245
+ </ScrollView>
249
246
  </OModal>
250
247
  </PromotionsContainer>
251
248
  </Container>
@@ -20,7 +20,7 @@ import IconAntDesign from 'react-native-vector-icons/AntDesign';
20
20
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
21
21
  import { UpsellingLayout } from './UpsellingLayout';
22
22
 
23
- export const UpsellingContent = (props : any) => {
23
+ export const UpsellingContent = (props: any) => {
24
24
  const {
25
25
  onGoBack,
26
26
  handleUpsellingPage,
@@ -44,12 +44,10 @@ export const UpsellingContent = (props : any) => {
44
44
  const commentDelayTime = isChewLayout ? 500 : null
45
45
 
46
46
  const cartList = (carts && Object.values(carts).filter((_cart: any) => _cart?.products?.length > 0 && _cart.uuid !== cart?.uuid)) || []
47
-
47
+
48
48
  const styles = StyleSheet.create({
49
49
  closeUpsellingButton: {
50
50
  borderRadius: 7.6,
51
- borderColor: theme.colors.primary,
52
- backgroundColor: theme.colors.primary,
53
51
  borderWidth: 1,
54
52
  alignSelf: 'center',
55
53
  height: 44,
@@ -160,8 +158,10 @@ export const UpsellingContent = (props : any) => {
160
158
  <OButton
161
159
  imgRightSrc=''
162
160
  text={t('CHECKOUT', 'Checkout')}
163
- style={{ ...styles.closeUpsellingButton }}
164
161
  textStyle={{ color: theme.colors.white, fontSize: 14 }}
162
+ bgColor={theme.colors.primary}
163
+ borderColor={theme.colors.primary}
164
+ style={{ ...styles.closeUpsellingButton }}
165
165
  onClick={() => handleUpsellingPage(cart)}
166
166
  />
167
167
  </View>