ordering-ui-react-native 0.17.59 → 0.17.61

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.17.59",
3
+ "version": "0.17.61",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -5,7 +5,7 @@ import { useTheme } from 'styled-components/native';
5
5
  import { getTraduction } from '../../utils'
6
6
 
7
7
  const fadeDuration = 300;
8
- const bottomPosition = 20;
8
+ const topPosition = 20;
9
9
 
10
10
  export const Toast = (props: any) => {
11
11
  const [toastConfig, { hideToast }] = useToast();
@@ -54,7 +54,7 @@ export const Toast = (props: any) => {
54
54
  backgroundColor = theme.colors.toastInfo || '#6BA4FF';
55
55
  break;
56
56
  case ToastType.Error:
57
- backgroundColor = theme.colors.toastError || '#D83520' ;
57
+ backgroundColor = theme.colors.toastError || '#D83520';
58
58
  break;
59
59
  case ToastType.Success:
60
60
  backgroundColor = theme.colors.toastSuccess || '#90C68E';
@@ -65,7 +65,7 @@ export const Toast = (props: any) => {
65
65
  <Animated.View
66
66
  style={[
67
67
  styles.container,
68
- { bottom: bottomPosition, opacity },
68
+ { top: topPosition, opacity },
69
69
  ]}
70
70
  >
71
71
  <View style={[styles.toast, { backgroundColor }]}>
@@ -472,7 +472,7 @@ const ChatUI = (props: MessagesParams) => {
472
472
  const firstMessage = {
473
473
  _id: 0,
474
474
  text: console,
475
- createdAt: order?.created_at,
475
+ createdAt: parseDate(order?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
476
476
  system: true,
477
477
  };
478
478
  messages?.messages.map((message: any) => {
@@ -488,7 +488,7 @@ const ChatUI = (props: MessagesParams) => {
488
488
  newMessage = {
489
489
  _id: message.id,
490
490
  text: message.type === 1 ? messageConsole(message) : message.comment,
491
- createdAt: message.type !== 0 && message.created_at,
491
+ createdAt: message.type !== 0 && parseDate(message?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
492
492
  image: message.source,
493
493
  system: message.type === 1,
494
494
  user: {
@@ -139,7 +139,7 @@ export const PreviousOrders = (props: any) => {
139
139
  const interval = setInterval(() => {
140
140
  const date: any = Date.now()
141
141
  setCurrentTime(date)
142
- }, slaSettingTime)
142
+ }, slaSettingTime ?? 6000)
143
143
 
144
144
  return () => clearInterval(interval)
145
145
  }, [])
@@ -4,8 +4,8 @@ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
4
4
  import { FavoriteParams } from '../../types';
5
5
  import { SingleOrderCard } from '../SingleOrderCard';
6
6
  import {
7
- FavoriteList as FavoriteListController,
8
- useOrder,
7
+ FavoriteList as FavoriteListController,
8
+ useOrder,
9
9
  useLanguage
10
10
  } from 'ordering-components/native';
11
11
  import { useTheme } from 'styled-components/native';
@@ -19,7 +19,7 @@ import moment from 'moment';
19
19
 
20
20
 
21
21
  const FavoriteListUI = (props: FavoriteParams) => {
22
- const {
22
+ const {
23
23
  favoriteList,
24
24
  handleUpdateFavoriteList,
25
25
  pagination,
@@ -31,9 +31,9 @@ const FavoriteListUI = (props: FavoriteParams) => {
31
31
  isBusiness,
32
32
  isOrder,
33
33
  isProduct
34
- } = props
34
+ } = props
35
35
 
36
- const theme = useTheme();
36
+ const theme = useTheme();
37
37
  const [, t] = useLanguage()
38
38
  const [orderState] = useOrder();
39
39
  const [{ carts }] = useOrder()
@@ -79,34 +79,39 @@ const FavoriteListUI = (props: FavoriteParams) => {
79
79
  const businessId = product?.category?.business?.id
80
80
  if (!categoryId || !businessId) return
81
81
  onNavigationRedirect && onNavigationRedirect('ProductDetails', {
82
- productId: product?.id,
83
- categoryId: categoryId,
84
- businessId: businessId
85
- })
82
+ isRedirect: 'business',
83
+ productId: product?.id,
84
+ businessId: businessId,
85
+ categoryId: categoryId,
86
+ business: {
87
+ store: product?.category?.business.slug,
88
+ header: product?.category?.header,
89
+ }
90
+ })
86
91
  }
87
92
 
88
93
  useEffect(() => {
89
- const _businessId = 'businessId:' + reorderState?.result?.business_id
90
- if (reorderState?.error) {
91
- if (reorderState?.result?.business_id) {
92
- _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
93
- onNavigationRedirect && onNavigationRedirect('Business', { store: reorderState?.result?.business?.slug })
94
- }
95
- }
96
- if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
97
- const cartProducts = carts?.[_businessId]?.products
98
- const available = cartProducts.every((product: any) => product.valid === true)
99
- const orderProducts = favoriteList?.favorites.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
94
+ const _businessId = 'businessId:' + reorderState?.result?.business_id
95
+ if (reorderState?.error) {
96
+ if (reorderState?.result?.business_id) {
97
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
98
+ onNavigationRedirect && onNavigationRedirect('Business', { store: reorderState?.result?.business?.slug })
99
+ }
100
+ }
101
+ if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
102
+ const cartProducts = carts?.[_businessId]?.products
103
+ const available = cartProducts.every((product: any) => product.valid === true)
104
+ const orderProducts = favoriteList?.favorites.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
100
105
 
101
- if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
102
- onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
103
- } else {
104
- _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
105
- cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
106
- onNavigationRedirect && onNavigationRedirect('Business', { store: reorderState?.result?.business?.slug })
107
- }
108
- }
109
- }, [reorderState])
106
+ if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
107
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
108
+ } else {
109
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
110
+ cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
111
+ onNavigationRedirect && onNavigationRedirect('Business', { store: reorderState?.result?.business?.slug })
112
+ }
113
+ }
114
+ }, [reorderState])
110
115
 
111
116
  const handleBusinessClick = (business: any) => {
112
117
  onNavigationRedirect && onNavigationRedirect('Business', {
@@ -195,12 +200,12 @@ const FavoriteListUI = (props: FavoriteParams) => {
195
200
  )
196
201
  }
197
202
 
198
- return (
199
- <Container>
203
+ return (
204
+ <Container>
200
205
  {isBusiness && (
201
206
  <>
202
207
  {favoriteList?.favorites?.length > 0 && (
203
- favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((business: any, i:number) => (
208
+ favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((business: any, i: number) => (
204
209
  <BusinessController
205
210
  key={`${business.id}_` + i}
206
211
  business={business}
@@ -237,7 +242,7 @@ const FavoriteListUI = (props: FavoriteParams) => {
237
242
  {isOrder && (
238
243
  <>
239
244
  {favoriteList?.favorites?.length > 0 && (
240
- favoriteList.favorites?.sort((a: any, b:any) => moment(a?.delivery_datetime_utc).valueOf() - moment(b?.delivery_datetime_utc).valueOf())
245
+ favoriteList.favorites?.sort((a: any, b: any) => moment(a?.delivery_datetime_utc).valueOf() - moment(b?.delivery_datetime_utc).valueOf())
241
246
  .map((order: any, i: number) => (
242
247
  <SingleOrderCard
243
248
  key={`${order?.id}_${i}`}
@@ -250,7 +255,7 @@ const FavoriteListUI = (props: FavoriteParams) => {
250
255
  handleReorder={handleReorder}
251
256
  reorderLoading={reorderState?.loading}
252
257
  />
253
- ))
258
+ ))
254
259
  )}
255
260
  {favoriteList?.loading && (
256
261
  [...Array(5).keys()].map(i => (
@@ -294,18 +299,18 @@ const FavoriteListUI = (props: FavoriteParams) => {
294
299
  )}
295
300
 
296
301
  {!favoriteList?.loading && pagination.totalPages && pagination.currentPage < pagination.totalPages && (
297
- <WrappButton>
298
- <OButton
299
- onClick={() => getFavoriteList(pagination?.currentPage + 1)}
300
- text={t('LOAD_MORE_ITEMS', 'Load more items')}
301
- imgRightSrc={null}
302
- textStyle={{ color: theme.colors.white }}
303
- style={{ borderRadius: 7.6, shadowOpacity: 0, marginTop: 20 }}
304
- />
305
- </WrappButton>
306
- )}
302
+ <WrappButton>
303
+ <OButton
304
+ onClick={() => getFavoriteList(pagination?.currentPage + 1)}
305
+ text={t('LOAD_MORE_ITEMS', 'Load more items')}
306
+ imgRightSrc={null}
307
+ textStyle={{ color: theme.colors.white }}
308
+ style={{ borderRadius: 7.6, shadowOpacity: 0, marginTop: 20 }}
309
+ />
310
+ </WrappButton>
311
+ )}
307
312
  </Container>
308
- )
313
+ )
309
314
  }
310
315
 
311
316
  export const FavoriteList = (props: any) => {
@@ -141,7 +141,7 @@ const MessagesUI = (props: MessagesParams) => {
141
141
  const firstMessage = {
142
142
  _id: 0,
143
143
  text: _console,
144
- createdAt: order?.created_at,
144
+ createdAt: parseDate(order?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
145
145
  system: true
146
146
  }
147
147
  const newMessage: any = [];
@@ -150,7 +150,7 @@ const MessagesUI = (props: MessagesParams) => {
150
150
  newMessage.push({
151
151
  _id: message?.id,
152
152
  text: message.type === 1 ? messageConsole(message) : message.comment,
153
- createdAt: message.type !== 0 && message.created_at,
153
+ createdAt: message.type !== 0 && parseDate(message?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
154
154
  image: message.source,
155
155
  system: message.type === 1,
156
156
  user: {
@@ -165,7 +165,7 @@ const MessagesUI = (props: MessagesParams) => {
165
165
  newMessage.push({
166
166
  _id: message?.id,
167
167
  text: message.type === 1 ? messageConsole(message) : message.comment,
168
- createdAt: message.type !== 0 && message.created_at,
168
+ createdAt: message.type !== 0 && parseDate(message?.created_at, { outputFormat: 'YYYY-MM-DD HH:mm:ss' }),
169
169
  image: message.source,
170
170
  system: message.type === 1,
171
171
  user: {
@@ -103,15 +103,15 @@ export const MyOrders = (props: any) => {
103
103
  }}
104
104
  />
105
105
  <OText
106
- size={24}
107
- style={{
108
- textTransform: 'capitalize',
109
- marginLeft: 20,
110
- top: 2
111
- }}
112
- >
113
- {t('MY_ORDERS', 'My Orders')}
114
- </OText>
106
+ size={24}
107
+ style={{
108
+ textTransform: 'capitalize',
109
+ marginLeft: 20,
110
+ top: 2
111
+ }}
112
+ >
113
+ {t('MY_ORDERS', 'My Orders')}
114
+ </OText>
115
115
  </View>
116
116
  )}
117
117
  {!hideOrders && !isChewLayout && !showNavbar && (
@@ -145,16 +145,18 @@ export const MyOrders = (props: any) => {
145
145
  )}
146
146
  {selectedOption === 'orders' && (
147
147
  <>
148
- <View style={{ paddingLeft: 40, paddingRight: 40 }}>
149
- <OrdersOption
150
- {...props}
151
- activeOrders
152
- ordersLength={ordersLength}
153
- setOrdersLength={setOrdersLength}
154
- setRefreshOrders={setRefreshOrders}
155
- refreshOrders={refreshOrders}
156
- />
157
- </View>
148
+ {ordersLength?.activeOrdersLength > 0 && (
149
+ <View style={{ paddingLeft: 40, paddingRight: 40 }}>
150
+ <OrdersOption
151
+ {...props}
152
+ activeOrders
153
+ ordersLength={ordersLength}
154
+ setOrdersLength={setOrdersLength}
155
+ setRefreshOrders={setRefreshOrders}
156
+ refreshOrders={refreshOrders}
157
+ />
158
+ </View>
159
+ )}
158
160
  <View style={{ paddingLeft: 40, paddingRight: 40 }}>
159
161
  <OrdersOption
160
162
  {...props}
@@ -118,6 +118,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
118
118
  const mapValidStatuses = [9, 19, 23]
119
119
  const placeSpotTypes = [3, 4, 5]
120
120
  const directionTypes = [2, 3, 4, 5]
121
+ const activeStatus = [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23]
121
122
  const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
122
123
 
123
124
  const walletName: any = {
@@ -595,9 +596,13 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
595
596
  titleWrapStyle={{ paddingHorizontal: 0 }}
596
597
  titleStyle={{ marginRight: 0, marginLeft: 0 }}
597
598
  subTitle={<OText size={12} lineHeight={18} color={theme.colors.textNormal}>
598
- {order?.delivery_datetime_utc
599
- ? parseDate(order?.delivery_datetime_utc)
600
- : parseDate(order?.delivery_datetime, { utc: false })}
599
+ {
600
+ activeStatus.includes(order?.status)
601
+ ? order?.eta_time + 'min'
602
+ : order?.delivery_datetime_utc
603
+ ? parseDate(order?.delivery_datetime_utc)
604
+ : parseDate(order?.delivery_datetime, { utc: false })
605
+ }
601
606
  </OText>}
602
607
  />
603
608
  {enabledPoweredByOrdering && (
@@ -109,14 +109,11 @@ const OrderProgressUI = (props: any) => {
109
109
  }
110
110
 
111
111
  const convertDiffToHours = (order: any) => {
112
- const time = order.delivery_type === 1 ? order?.business?.delivery_time : order?.business?.pickup_time
112
+ const minute = order?.eta_time
113
113
  const deliveryTime = order?.delivery_datetime_utc
114
114
  ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD HH:mm' })
115
115
  : parseDate(order?.delivery_datetime, { utc: false, outputFormat: 'YYYY-MM-DD HH:mm' })
116
- const hour = time?.split(':')?.[0]
117
- const minute = time?.split(':')?.[1]
118
- const result = time ? (parseInt(hour, 10) * 60) + parseInt(minute, 10) : 0
119
- const returnedDate = moment(deliveryTime).add(result, 'minutes').format('hh:mm A')
116
+ const returnedDate = moment(deliveryTime).add(minute, 'minutes').format('hh:mm A')
120
117
  return returnedDate
121
118
  }
122
119
 
@@ -131,7 +131,7 @@ const ReviewDriverUI = (props: ReviewDriverParams) => {
131
131
  if (!order?.user_review && !isDriverReviewed) {
132
132
  onSubmit()
133
133
  } else {
134
- onNavigationRedirect && onNavigationRedirect('MyOrders')
134
+ onNavigationRedirect('BottomTab', { screen: 'MyOrders' })
135
135
  }
136
136
  }
137
137
 
@@ -145,7 +145,7 @@ const ReviewDriverUI = (props: ReviewDriverParams) => {
145
145
  }
146
146
  if (!formState.loading && !formState.result?.error && alertState.success) {
147
147
  setIsDriverReviewed && setIsDriverReviewed(true)
148
- onNavigationRedirect('MyOrders')
148
+ onNavigationRedirect('BottomTab', { screen: 'MyOrders' })
149
149
  }
150
150
  }, [formState])
151
151
 
@@ -186,7 +186,7 @@ const ReviewDriverUI = (props: ReviewDriverParams) => {
186
186
  <NavBar
187
187
  title={t('REVIEW_DRIVER', 'Review driver')}
188
188
  titleAlign={'center'}
189
- onActionLeft={() => onNavigationRedirect('BottomTab')}
189
+ onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'MyOrders' })}
190
190
  showCall={false}
191
191
  btnStyle={{ paddingLeft: 0 }}
192
192
  style={{ flexDirection: 'column', alignItems: 'flex-start' }}
@@ -56,7 +56,7 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
56
56
  if (order?.driver && !order?.user_review) {
57
57
  onNavigationRedirect('ReviewDriver', { order: order })
58
58
  } else {
59
- onNavigationRedirect('MyOrders')
59
+ onNavigationRedirect('BottomTab', { screen: 'MyOrders' })
60
60
  }
61
61
  }
62
62
  }, [formState])
@@ -67,7 +67,7 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
67
67
  <NavBar
68
68
  title={t('REVIEW_PRODUCT', 'Review product')}
69
69
  titleAlign={'center'}
70
- onActionLeft={() => onNavigationRedirect('BottomTab')}
70
+ onActionLeft={() => onNavigationRedirect('BottomTab', { screen: 'MyOrders' })}
71
71
  showCall={false}
72
72
  btnStyle={{ paddingLeft: 0 }}
73
73
  style={{ flexDirection: 'column', alignItems: 'flex-start' }}
@@ -87,7 +87,10 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
87
87
  <FloatingBottomContainer>
88
88
  <ActionContainer>
89
89
  <SkipButton
90
- onPress={() => (order?.driver && !order?.user_review) ? onNavigationRedirect('ReviewDriver', { order: order }) : onNavigationRedirect('MyOrders')}
90
+ onPress={() => (order?.driver && !order?.user_review) ?
91
+ onNavigationRedirect('ReviewDriver', { order: order }) :
92
+ onNavigationRedirect('BottomTab', { screen: 'MyOrders' })
93
+ }
91
94
  >
92
95
  <OText weight={700} size={18} color={theme.colors.textNormal}>{t('FRONT_VISUALS_SKIP', 'Skip')}</OText>
93
96
  </SkipButton>
@@ -95,7 +98,7 @@ const ReviewProductsUI = (props: ReviewProductParams) => {
95
98
  textStyle={{ color: theme.colors.white, paddingRight: 10 }}
96
99
  text={order?.driver && !order?.user_review ? t('CONTINUE', 'Continue') : t('SEND_REVIEW', 'Send Review')}
97
100
  style={{ borderRadius: 8 }}
98
- imgRightSrc={theme.images.general.arrow_right}
101
+ imgRightSrc={theme.images.general.arrow_right}
99
102
  imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
100
103
  isDisabled={formState.loading || formState?.changes?.length === 0}
101
104
  onClick={() => handleContinueClick()}
@@ -282,7 +282,11 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
282
282
  color={theme.colors.textSecondary}
283
283
  style={{ marginVertical: 3 }}
284
284
  numberOfLines={1}>
285
- {order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })}
285
+ {
286
+ pastOrders
287
+ ? order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })
288
+ : order?.eta_time + 'min'
289
+ }
286
290
  </OText>
287
291
  </View>
288
292
  <OText