ordering-ui-react-native 0.21.95 → 0.21.96

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.21.95",
3
+ "version": "0.21.96",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -20,7 +20,9 @@ import {
20
20
  useEvent,
21
21
  useLanguage,
22
22
  useSession,
23
- useConfig
23
+ useConfig,
24
+ useToast,
25
+ ToastType
24
26
  } from 'ordering-components/native'
25
27
 
26
28
  import { OIcon, OText } from '../shared'
@@ -108,11 +110,12 @@ const SoundPlayerComponent = (props: any) => {
108
110
 
109
111
  const NewOrderNotificationUI = (props: any) => {
110
112
  const { isBusinessApp, evtList } = props
111
-
113
+ const [, t] = useLanguage()
112
114
  const [events] = useEvent()
113
115
  const [{ user, token }] = useSession()
114
116
  const [ordering] = useApi()
115
117
  const [{ configs }] = useConfig()
118
+ const [, { showToast }] = useToast()
116
119
  const { getCurrentLocation } = useLocation()
117
120
  const [currentEvent, setCurrentEvent] = useState<any>(null)
118
121
 
@@ -124,6 +127,10 @@ const NewOrderNotificationUI = (props: any) => {
124
127
  if (value?.driver) {
125
128
  try {
126
129
  const location = await getCurrentLocation()
130
+ if (!location?.latitude || !location?.longitude) {
131
+ showToast(t('ERROR_UPDATING_COORDS', 'Error updating coords'), ToastType.Error)
132
+ return
133
+ }
127
134
  await fetch(`${ordering.root}/users/${user.id}/locations`, {
128
135
  method: 'POST',
129
136
  body: JSON.stringify({
@@ -50,6 +50,7 @@ const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
50
50
 
51
51
  const OrdersOptionUI = (props: OrdersOptionParams) => {
52
52
  const {
53
+ navigation,
53
54
  setCurrentFilters,
54
55
  tabs,
55
56
  currentTabSelected,
@@ -385,6 +386,13 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
385
386
  setTags({ values: [] })
386
387
  }, [currentTabSelected])
387
388
 
389
+ useEffect(() => {
390
+ const unsubcribe = navigation.addListener('focus', () => {
391
+ currentTabSelected === 'logisticOrders' ? loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })
392
+ })
393
+ return unsubcribe
394
+ }, [navigation, loadOrders, loadLogisticOrders])
395
+
388
396
  return (
389
397
  <>
390
398
  <View style={styles.header}>
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { Platform, PlatformIOSStatic, StyleSheet, TouchableOpacity, View } from 'react-native';
2
+ import { Platform, PlatformIOSStatic, Pressable, StyleSheet, View } from 'react-native';
3
3
  import DeviceInfo from 'react-native-device-info';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import { useLanguage, useUtils, useConfig } from 'ordering-components/native';
@@ -138,8 +138,7 @@ export const OrderItem = React.memo((props: any) => {
138
138
  }, [configState.loading])
139
139
 
140
140
  return (
141
- <TouchableOpacity
142
- activeOpacity={1}
141
+ <Pressable
143
142
  disabled={order?.locked && isLogisticOrder}
144
143
  style={styles.cardButton}
145
144
  onPress={() => handlePressOrder({ ...order, logistic_order_id: _order?.id })}
@@ -237,6 +236,6 @@ export const OrderItem = React.memo((props: any) => {
237
236
  )}
238
237
  </Information>
239
238
  </Card>
240
- </TouchableOpacity>
239
+ </Pressable>
241
240
  )
242
241
  }, OrderItemPropsAreEqual)
@@ -48,8 +48,8 @@ export const useLocation = () => {
48
48
  GeoLocation.getCurrentPosition(
49
49
  ({ coords }) => {
50
50
  resolve({
51
- latitude: coords.latitude,
52
- longitude: coords.longitude,
51
+ latitude: typeof coords.latitude !== 'number' && !Number.isNaN(coords.latitude) ? coords.latitude : 0,
52
+ longitude: typeof coords.longitude !== 'number' && !Number.isNaN(coords.longitude) ? coords.longitude : 0,
53
53
  speed: coords.speed,
54
54
  });
55
55
  },
@@ -63,9 +63,10 @@ export const useLocation = () => {
63
63
  watchId.current = GeoLocation.watchPosition(
64
64
  ({ coords }) => {
65
65
  if (!isMounted.current) return;
66
+ if (typeof coords.latitude !== 'number' || typeof coords.longitude !== 'number') return
66
67
  const location: Location = {
67
- latitude: coords.latitude,
68
- longitude: coords.longitude,
68
+ latitude: coords.latitude || 0,
69
+ longitude: coords.longitude || 0,
69
70
  speed: coords.speed,
70
71
  };
71
72
  setUserLocation(location);
@@ -35,7 +35,12 @@ import FastImage from 'react-native-fast-image'
35
35
  import { LottieAnimation } from '../LottieAnimation';
36
36
  import { CardAnimation } from '../shared/CardAnimation';
37
37
 
38
- export const BusinessControllerUI = (props: BusinessControllerParams) => {
38
+ function BusinessControllerPropsAreEqual (prevProps: any, nextProps: any) {
39
+ return JSON.stringify(prevProps.business) === JSON.stringify(nextProps.business) &&
40
+ prevProps.isBusinessOpen === nextProps.isBusinessOpen
41
+ }
42
+
43
+ export const BusinessControllerUI = React.memo((props: BusinessControllerParams) => {
39
44
  const {
40
45
  business,
41
46
  handleClick,
@@ -184,7 +189,7 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
184
189
  }
185
190
 
186
191
  return (
187
- <InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeInterSection(inView)}>
192
+ <View style={{ minHeight: 200 }}>
188
193
  {isIntersectionObserver ? (
189
194
  <CardAnimation
190
195
  style={[style, styles.container]}
@@ -376,9 +381,9 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
376
381
  </View>
377
382
  </Placeholder>
378
383
  )}
379
- </InView>
384
+ </View>
380
385
  );
381
- };
386
+ }, BusinessControllerPropsAreEqual);
382
387
 
383
388
  export const BusinessController = (props: BusinessControllerParams) => {
384
389
  const BusinessControllerProps = {
@@ -27,7 +27,7 @@ export const Home = (props: any) => {
27
27
  return (
28
28
  <View style={styles.container}>
29
29
  <View>
30
- <View style={{paddingTop: (height <= 756 && Platform.OS !== 'ios') ? (height * 0.05) : 0 }}>
30
+ <View style={{ paddingTop: (height <= 756 && Platform.OS !== 'ios') ? (height * 0.05) : 0 }}>
31
31
  <LanguageSelector />
32
32
  </View>
33
33
  <OIcon
@@ -49,11 +49,11 @@ export const Home = (props: any) => {
49
49
  </OText>
50
50
  <OButton
51
51
  text={t('LOGIN_NOW', 'Login now')}
52
- bgColor={theme.colors.primary}
53
- borderColor={theme.colors.primary}
52
+ bgColor={theme.general.components.buttons.color ?? theme.colors.primary}
53
+ borderColor={theme.general.components.buttons.color ?? theme.colors.primary}
54
54
  style={styles.buttons}
55
55
  isCircle={false}
56
- textStyle={{ color: 'white' }}
56
+ textStyle={{ color: `${theme.general.components.buttons.buttonTextColor ?? 'white'}` }}
57
57
  onClick={() => onNavigationRedirect('Login')}
58
58
  imgRightSrc={null}
59
59
  />
@@ -9,6 +9,7 @@ import { ScrollView } from 'react-native-gesture-handler';
9
9
  import { Tab } from './styles'
10
10
  import { useTheme } from 'styled-components/native';
11
11
  import { Container } from '../../layouts/Container';
12
+ import NavBar from '../NavBar'
12
13
 
13
14
  export const MyOrders = (props: any) => {
14
15
  const {
@@ -93,29 +94,15 @@ export const MyOrders = (props: any) => {
93
94
  ...props.titleStyle
94
95
  }}>
95
96
  {!props.hideBackBtn && (!isChewLayout || (isChewLayout && hideOrdersTheme)) && (
96
- <OButton
97
- imgLeftStyle={{ width: 18 }}
98
- imgRightSrc={null}
99
- style={{
100
- borderWidth: 0,
101
- width: 26,
102
- height: 26,
103
- backgroundColor: '#FFF',
104
- borderColor: '#FFF',
105
- shadowColor: '#FFF',
106
- paddingLeft: 0,
107
- paddingRight: 0,
108
- marginTop: 30,
109
- }}
110
- onClick={goToBack}
111
- icon={AntDesignIcon}
112
- iconProps={{
113
- name: 'arrowleft',
114
- size: 26
115
- }}
97
+ <NavBar
98
+ title={t('MY_ORDERS', 'My Orders')}
99
+ titleAlign={'center'}
100
+ onActionLeft={goToBack}
101
+ showCall={false}
102
+ paddingTop={30}
103
+ btnStyle={{ paddingLeft: 0 }}
116
104
  />
117
105
  )}
118
- <HeaderTitle ph={10} text={t('MY_ORDERS', 'My Orders')} />
119
106
  </View>
120
107
  )}
121
108
  {!hideOrders && !isChewLayout && !showNavbar && (
@@ -125,7 +112,7 @@ export const MyOrders = (props: any) => {
125
112
  <ScrollView
126
113
  horizontal
127
114
  style={{ ...styles.container, borderBottomWidth: 1 }}
128
- contentContainerStyle={{ paddingHorizontal: !!businessesSearchList ? 0 : 20 }}
115
+ contentContainerStyle={{ paddingHorizontal: !!businessesSearchList ? 0 : 20 }}
129
116
  showsHorizontalScrollIndicator={false}
130
117
  scrollEventThrottle={16}
131
118
  >
@@ -149,7 +136,7 @@ export const MyOrders = (props: any) => {
149
136
  )}
150
137
  {selectedOption === 'orders' && (
151
138
  <>
152
- <View style={{ paddingHorizontal: 20 }}>
139
+ <View style={{ paddingHorizontal: 20 }}>
153
140
  <OrdersOption
154
141
  {...props}
155
142
  preOrders
@@ -216,9 +203,9 @@ export const MyOrders = (props: any) => {
216
203
  setOrdersLength={setOrdersLength}
217
204
  />
218
205
  )}
219
-
206
+
220
207
  {selectedOption === 'giftCards' && (
221
- <View style={{ paddingHorizontal: 20 }}>
208
+ <View style={{ paddingHorizontal: 20 }}>
222
209
  <GiftCardOrdersList
223
210
  onNavigationRedirect={props?.onNavigationRedirect}
224
211
  />
@@ -23,6 +23,7 @@ import {
23
23
  OrderProgressWrapper
24
24
  } from './styles'
25
25
  import { getOrderStatuPickUp, getOrderStatus } from '../../utils'
26
+ import DeviceInfo from 'react-native-device-info'
26
27
 
27
28
  const OrderProgressUI = (props: any) => {
28
29
  const {
@@ -56,7 +57,9 @@ const OrderProgressUI = (props: any) => {
56
57
  shadowColor: '#000',
57
58
  shadowOpacity: 0.2,
58
59
  shadowRadius: 2,
59
- elevation: 3
60
+ elevation: 3,
61
+ borderWidth: Platform.OS === 'android' && Number(DeviceInfo?.getSystemVersion?.()) < 5 ? 1 : 0,
62
+ borderColor: 'rgba(0,0,0,0.2)'
60
63
  },
61
64
  logoWrapper: {
62
65
  overflow: 'hidden',
@@ -74,9 +74,9 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
74
74
 
75
75
  const [isActive, setActiveState] = useState(false)
76
76
  const [isServiceOpen, setIsServiceOpen] = useState(false)
77
+ const [productQuantityState, setProductQuantityState] = useState(product.quantity.toString())
77
78
  // const [setHeight, setHeightState] = useState({ height: new Animated.Value(0) })
78
79
  // const [setRotate, setRotateState] = useState({ angle: new Animated.Value(0) })
79
- let productQuantity = product.quantity.toString()
80
80
 
81
81
  const productInfo = () => {
82
82
  if (isCartProduct) {
@@ -120,7 +120,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
120
120
 
121
121
  const handleChangeQuantity = (value: string) => {
122
122
  if (!orderState.loading) {
123
- productQuantity = value
123
+ setProductQuantityState(value)
124
124
  if (parseInt(value) === 0) {
125
125
  onDeleteProduct && onDeleteProduct(product)
126
126
  } else {
@@ -210,7 +210,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
210
210
  <RNPickerSelect
211
211
  items={productOptions}
212
212
  onValueChange={handleChangeQuantity}
213
- value={productQuantity}
213
+ value={productQuantityState}
214
214
  style={pickerStyle}
215
215
  useNativeAndroidPickerStyle={false}
216
216
  placeholder={{}}
@@ -286,15 +286,15 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
286
286
  {productInfo().ingredients.length > 0 && productInfo().ingredients.some((ingredient: any) => !ingredient.selected) && (
287
287
  <ProductOptionsList>
288
288
  <OText size={10} color={theme.colors.textSecondary}>{t('INGREDIENTS', 'Ingredients')}</OText>
289
- {productInfo().ingredients.map((ingredient: any) => !ingredient.selected && (
290
- <OText size={10} color={theme.colors.textThird} key={ingredient.id} style={{ marginLeft: 10 }}>{t('NO', 'No')} {ingredient.name}</OText>
289
+ {productInfo().ingredients.map((ingredient: any, i) => !ingredient.selected && (
290
+ <OText size={10} color={theme.colors.textThird} key={ingredient.id + i} style={{ marginLeft: 10 }}>{t('NO', 'No')} {ingredient.name}</OText>
291
291
  ))}
292
292
  </ProductOptionsList>
293
293
  )}
294
294
  {productInfo().options.length > 0 && (
295
295
  <ProductOptionsList>
296
- {productInfo().options.sort((a: any, b: any) => a.rank - b.rank).map((option: any, i: number) => (
297
- <ProductOption key={option.id + i}>
296
+ {productInfo().options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => (
297
+ <ProductOption key={option.id}>
298
298
  <OText size={10} color={theme.colors.textSecondary}>{option.name}</OText>
299
299
  {option.suboptions.map((suboption: any) => (
300
300
  <ProductSubOption key={suboption.id}>
@@ -119,7 +119,7 @@ const OButton = (props: Props): React.ReactElement => {
119
119
  style={{ width: props.isCircle ? 52 : props.style?.width, ...props.parentStyle }}
120
120
  disabled={props.isDisabledWithSameStyles}
121
121
  >
122
- <StyledButton style={props.bgColor ? { ...props.style, backgroundColor: props.bgColor, borderColor: props.borderColor, borderRadius: parseInt(theme?.general?.components?.buttons?.borderRadius) || props.style?.borderRadius } : { ...props.style, borderRadius: parseInt(theme?.general?.components?.buttons?.borderRadius) || props.style?.borderRadius }}>
122
+ <StyledButton style={{ ...props.style, backgroundColor: props.bgColor ?? theme?.general?.components?.buttons?.color, borderColor: props.borderColor, borderRadius: parseInt(theme?.general?.components?.buttons?.borderRadius) || props.style?.borderRadius }}>
123
123
  {props.icon ? (
124
124
  <props.icon {...props.iconProps} />
125
125
  ) : null}
@@ -127,7 +127,7 @@ const OButton = (props: Props): React.ReactElement => {
127
127
  <OIcon style={props.imgLeftStyle} src={props.imgLeftSrc} color={theme.colors.textNormal} />
128
128
  ) : null}
129
129
  {props.text ? (
130
- <StyledText style={props.textStyle}>{props.text}</StyledText>
130
+ <StyledText style={{ ...props.textStyle, color: props?.textStyle?.color ?? theme?.general?.components?.buttons?.buttonTextColor }}>{props.text}</StyledText>
131
131
  ) : null}
132
132
  {props.imgRightSrc ? (
133
133
  <EndImage style={props.imgRightStyle} source={props.imgRightSrc} />