ordering-ui-react-native 0.14.59 → 0.14.60

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.14.59",
3
+ "version": "0.14.60",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,9 +1,12 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import { StyleSheet, TouchableOpacity, View } from 'react-native';
3
3
  import { useTheme } from 'styled-components/native';
4
+ import moment from 'moment'
4
5
  import { useLanguage, useUtils } from 'ordering-components/native';
5
6
  import { OButton, OIcon, OText } from '../shared';
6
- import { Card, Logo, Information, MyOrderOptions, NotificationIcon, AcceptOrRejectOrder } from './styles';
7
+ import {
8
+ Card, Logo, Information, MyOrderOptions, NotificationIcon, AcceptOrRejectOrder, Timestatus
9
+ } from './styles';
7
10
  import EntypoIcon from 'react-native-vector-icons/Entypo'
8
11
 
9
12
  export const PreviousOrders = (props: any) => {
@@ -18,6 +21,7 @@ export const PreviousOrders = (props: any) => {
18
21
  const [, t] = useLanguage();
19
22
  const [{ parseDate, optimizeImage }] = useUtils();
20
23
  const theme = useTheme();
24
+ const [currentTime, setCurrentTime] = useState()
21
25
 
22
26
  const handlePressOrder = (order: any) => {
23
27
  if (order?.locked && isLogisticOrder) return
@@ -39,17 +43,15 @@ export const PreviousOrders = (props: any) => {
39
43
  height: 75,
40
44
  },
41
45
  logo: {
42
- width: 78,
43
- height: 78,
44
- borderRadius: 25,
45
- shadowColor: 'rgba(0.0, 0.0, 0.0, 0.5)',
46
+ borderRadius: 10,
47
+ shadowColor: "#000",
46
48
  shadowOffset: {
47
49
  width: 0,
48
- height: 1.5,
50
+ height: 1,
49
51
  },
50
- shadowOpacity: 0.21,
51
- shadowRadius: 5,
52
- elevation: 7,
52
+ shadowOpacity: 0.20,
53
+ shadowRadius: 1.41,
54
+ elevation: 2,
53
55
  justifyContent: 'center',
54
56
  alignItems: 'center',
55
57
  marginLeft: 3,
@@ -67,11 +69,10 @@ export const PreviousOrders = (props: any) => {
67
69
  fontFamily: 'Poppins',
68
70
  fontStyle: 'normal',
69
71
  fontWeight: 'normal',
70
- fontSize: 15,
71
- color: theme.colors.unselectText,
72
+ fontSize: 12,
72
73
  },
73
74
  orderType: {
74
- fontSize: 15,
75
+ fontSize: 12,
75
76
  fontFamily: 'Poppins',
76
77
  fontStyle: 'normal',
77
78
  fontWeight: 'normal',
@@ -79,6 +80,32 @@ export const PreviousOrders = (props: any) => {
79
80
  },
80
81
  });
81
82
 
83
+ const getDelayTime = (order: any) => {
84
+ // targetMin = delivery_datetime + eta_time - now()
85
+ const _delivery = order?.delivery_datetime_utc
86
+ const _eta = order?.eta_time
87
+ const tagetedMin = moment(_delivery).add(_eta, 'minutes').diff(moment().utc(), 'minutes')
88
+ let day = Math.floor(tagetedMin / 1440)
89
+ const restMinOfTargetedMin = tagetedMin - 1440 * day
90
+ let restHours: any = Math.floor(restMinOfTargetedMin / 60)
91
+ let restMins: any = restMinOfTargetedMin - 60 * restHours
92
+
93
+ if (order?.time_status === 'in_time' || order?.time_status === 'at_risk') day = Math.abs(day)
94
+ if (restHours < 10) restHours = ('0' + restHours)
95
+ if (restMins < 10) restMins = ('0' + restMins)
96
+ const finalTaget = day + 'day ' + restHours + ':' + restMins
97
+ return finalTaget
98
+ }
99
+
100
+ useEffect(() => {
101
+ const interval = setInterval(() => {
102
+ const date:any = Date.now()
103
+ setCurrentTime(date)
104
+ }, 60000)
105
+
106
+ return () => clearInterval(interval)
107
+ }, [])
108
+
82
109
  let hash: any = {};
83
110
 
84
111
  return (
@@ -103,6 +130,7 @@ export const PreviousOrders = (props: any) => {
103
130
  activeOpacity={1}
104
131
  >
105
132
  <Card key={order.id}>
133
+ <Timestatus style={{backgroundColor: order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : '' }}/>
106
134
  {
107
135
  order.business?.logo && (
108
136
  <Logo style={styles.logo}>
@@ -135,16 +163,20 @@ export const PreviousOrders = (props: any) => {
135
163
  />
136
164
  </NotificationIcon>
137
165
  )}
138
- <OText
139
- style={styles.date}
140
- numberOfLines={1}
141
- adjustsFontSizeToFit
142
- size={20}>
143
- {(order?.order_group_id && order?.order_group && isLogisticOrder ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}` : (t('INVOICE_ORDER_NO', 'Order No.') + order.id)) + ' · '}
144
- {order?.delivery_datetime_utc
145
- ? parseDate(order?.delivery_datetime_utc)
146
- : parseDate(order?.delivery_datetime, { utc: false })}
147
- </OText>
166
+ <View style={{flexDirection: 'row'}}>
167
+ <OText
168
+ style={styles.date}
169
+ color={theme.colors.unselectText}
170
+ numberOfLines={1}
171
+ adjustsFontSizeToFit
172
+ >
173
+ {(order?.order_group_id && order?.order_group && isLogisticOrder ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}` : (t('NO', 'Order No.') + order.id)) + ' · '}
174
+ {order?.delivery_datetime_utc
175
+ ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
176
+ : parseDate(order?.delivery_datetime, { utc: false })}{' · '}
177
+ </OText>
178
+ <OText style={styles.date} color={order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : '' } >{getDelayTime(order)}</OText>
179
+ </View>
148
180
  {!isLogisticOrder && (
149
181
  <MyOrderOptions>
150
182
  <OText
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components/native';
1
+ import styled, { css } from 'styled-components/native';
2
2
 
3
3
  export const Card = styled.View`
4
4
  flex: 1;
@@ -35,4 +35,16 @@ export const AcceptOrRejectOrder = styled.View`
35
35
  justify-content: space-between;
36
36
  flex: 1;
37
37
  margin: 10px;
38
+ `
39
+ export const Timestatus = styled.View`
40
+ position: relative;;
41
+ width: 4px;
42
+ height: 65px;
43
+ border-radius: 20px;
44
+ top: 5px;
45
+ margin-right: 5px;
46
+ ${(props: any) => props.theme?.rtl && css`
47
+ left: unset;
48
+ right: -5px;
49
+ `}
38
50
  `