ordering-ui-react-native 0.18.75 → 0.18.77

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.18.75",
3
+ "version": "0.18.77",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -2,7 +2,8 @@ import React, { useEffect, useState } from 'react'
2
2
  import {
3
3
  OrderList,
4
4
  useLanguage,
5
- useUtils
5
+ useUtils,
6
+ useConfig
6
7
  } from 'ordering-components/native'
7
8
  import { useTheme } from 'styled-components/native';
8
9
  import IconAntDesign from 'react-native-vector-icons/AntDesign'
@@ -34,10 +35,12 @@ const OrderProgressUI = (props: any) => {
34
35
  const theme = useTheme();
35
36
 
36
37
  const [, t] = useLanguage()
37
- const [{ optimizeImage, parseTime }] = useUtils()
38
+ const [{ optimizeImage, parseTime, parseDate }] = useUtils()
39
+ const [{ configs }] = useConfig()
38
40
  const [lastOrder, setLastOrder] = useState<any>(null)
39
41
  const imageFails = theme.images.general.emptyActiveOrders
40
42
  const [initialLoaded, setInitialLoaded] = useState(false)
43
+ const statusToShow = [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21, 22, 23]
41
44
 
42
45
  const styles = StyleSheet.create({
43
46
  main: {
@@ -84,7 +87,15 @@ const OrderProgressUI = (props: any) => {
84
87
  useEffect(() => {
85
88
  if (orderList?.orders.length > 0) {
86
89
  const sortedOrders = orderList.orders.sort((a: any, b: any) => a.id > b.id ? -1 : 1)
87
- setLastOrder(sortedOrders[0])
90
+ const orderInProgress = sortedOrders.find((order: any) => (statusToShow.includes(order.status)))
91
+
92
+ let _lastOrder = null
93
+ if (orderInProgress) {
94
+ _lastOrder = orderInProgress
95
+ } else {
96
+ _lastOrder = sortedOrders[0]
97
+ }
98
+ setLastOrder(_lastOrder)
88
99
  }
89
100
  }, [orderList?.orders])
90
101
 
@@ -135,8 +146,10 @@ const OrderProgressUI = (props: any) => {
135
146
  fontWeight: 'bold',
136
147
  marginBottom: 3
137
148
  }}
138
- >{t('ORDER_IN_PROGRESS', 'Order in progress')}</OText>
139
- <OText size={11} numberOfLines={1} ellipsizeMode='tail'>{t('RESTAURANT_PREPARING_YOUR_ORDER', 'The restaurant is preparing your order')}</OText>
149
+ >{statusToShow.includes(lastOrder?.status) ? t('ORDER_IN_PROGRESS', 'Order in progress') : t('ORDER', 'Order')}</OText>
150
+ {statusToShow.includes(lastOrder?.status) && (
151
+ <OText size={11} numberOfLines={1} ellipsizeMode='tail'>{t('RESTAURANT_PREPARING_YOUR_ORDER', 'The restaurant is preparing your order')}</OText>
152
+ )}
140
153
  <TouchableOpacity onPress={() => handleGoToOrder('MyOrders')}>
141
154
  <View style={styles.navigationButton}>
142
155
  <OText size={11} color={theme.colors.primary}>{t('GO_TO_MY_ORDERS', 'Go to my orders')}</OText>
@@ -157,13 +170,17 @@ const OrderProgressUI = (props: any) => {
157
170
  <ProgressTextWrapper>
158
171
  <OText size={12} style={{ width: '50%' }}>{getOrderStatus(lastOrder.status)?.value}</OText>
159
172
  <TimeWrapper>
160
- <OText size={11}>{t('ESTIMATED_DELIVERY', 'Estimated delivery')}</OText>
173
+ <OText size={11}>{lastOrder?.delivery_type === 1 ? t('ESTIMATED_DELIVERY', 'Estimated delivery') : t('ESTIMATED_TIME', 'Estimated time')}</OText>
161
174
  <OText size={11}>
162
175
  {lastOrder?.delivery_datetime_utc
163
- ? parseTime(lastOrder?.delivery_datetime_utc, { outputFormat: 'hh:mm A' })
176
+ ? parseTime(lastOrder?.delivery_datetime_utc, { outputFormat: configs?.general_hour_format?.value || 'HH:mm' })
164
177
  : parseTime(lastOrder?.delivery_datetime, { utc: false })}
165
178
  &nbsp;-&nbsp;
166
- <OrderEta order={lastOrder} outputFormat='hh:mm A' />
179
+ {statusToShow.includes(lastOrder?.status) ? (
180
+ <OrderEta order={lastOrder} outputFormat={configs?.general_hour_format?.value || 'HH:mm'} />
181
+ ) : (
182
+ parseDate(lastOrder?.reporting_data?.at[`status:${lastOrder.status}`], { outputFormat: configs?.general_hour_format?.value })
183
+ )}
167
184
  </OText>
168
185
  </TimeWrapper>
169
186
  </ProgressTextWrapper>