ordering-ui-react-native 0.14.25 → 0.14.26

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.25",
3
+ "version": "0.14.26",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -45,6 +45,7 @@ const imgOptions = {
45
45
  includeBase64: true,
46
46
  selectionLimit: 0
47
47
  }
48
+ const filterSpecialStatus = ['prepared_in', 'delivered_in']
48
49
 
49
50
  const MessagesUI = (props: MessagesParams) => {
50
51
  const {
@@ -118,7 +119,11 @@ const MessagesUI = (props: MessagesParams) => {
118
119
  const messageConsole = (message: any) => {
119
120
  return message.change?.attribute !== 'driver_id'
120
121
  ?
121
- `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
122
+ `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${
123
+ filterSpecialStatus.includes(message.change.attribute) ?
124
+ `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}` :
125
+ `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
126
+ }`
122
127
  : message.change.new
123
128
  ?
124
129
  `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
@@ -12,6 +12,34 @@ import { MessagesParams } from '../../types'
12
12
  import { useWindowDimensions } from 'react-native'
13
13
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
14
14
 
15
+ const ORDER_STATUS: any = {
16
+ 0: 'ORDER_STATUS_PENDING',
17
+ 1: 'ORDERS_COMPLETED',
18
+ 2: 'ORDER_REJECTED',
19
+ 3: 'ORDER_STATUS_IN_BUSINESS',
20
+ 4: 'ORDER_READY',
21
+ 5: 'ORDER_REJECTED_RESTAURANT',
22
+ 6: 'ORDER_STATUS_CANCELLEDBYDRIVER',
23
+ 7: 'ORDER_STATUS_ACCEPTEDBYRESTAURANT',
24
+ 8: 'ORDER_CONFIRMED_ACCEPTED_BY_DRIVER',
25
+ 9: 'ORDER_PICKUP_COMPLETED_BY_DRIVER',
26
+ 10: 'ORDER_PICKUP_FAILED_BY_DRIVER',
27
+ 11: 'ORDER_DELIVERY_COMPLETED_BY_DRIVER',
28
+ 12: 'ORDER_DELIVERY_FAILED_BY_DRIVER',
29
+ 13: 'PREORDER',
30
+ 14: 'ORDER_NOT_READY',
31
+ 15: 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
32
+ 16: 'ORDER_STATUS_CANCELLED_BY_CUSTOMER',
33
+ 17: 'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
34
+ 18: 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
35
+ 19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
36
+ 20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
37
+ 21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
38
+ }
39
+
40
+ const filterSpecialStatus = ['prepared_in', 'delivered_in']
41
+
42
+
15
43
  const MessagesUI = (props: MessagesParams) => {
16
44
  const {
17
45
  type,
@@ -94,58 +122,6 @@ const MessagesUI = (props: MessagesParams) => {
94
122
  });
95
123
  };
96
124
 
97
- const getStatus = (status: number) => {
98
-
99
- switch (status) {
100
- case 0:
101
- return 'ORDER_STATUS_PENDING'
102
- case 1:
103
- return 'ORDERS_COMPLETED'
104
- case 2:
105
- return 'ORDER_REJECTED'
106
- case 3:
107
- return 'ORDER_STATUS_IN_BUSINESS'
108
- case 4:
109
- return 'ORDER_READY'
110
- case 5:
111
- return 'ORDER_REJECTED_RESTAURANT'
112
- case 6:
113
- return 'ORDER_STATUS_CANCELLEDBYDRIVER'
114
- case 7:
115
- return 'ORDER_STATUS_ACCEPTEDBYRESTAURANT'
116
- case 8:
117
- return 'ORDER_CONFIRMED_ACCEPTED_BY_DRIVER'
118
- case 9:
119
- return 'ORDER_PICKUP_COMPLETED_BY_DRIVER'
120
- case 10:
121
- return 'ORDER_PICKUP_FAILED_BY_DRIVER'
122
- case 11:
123
- return 'ORDER_DELIVERY_COMPLETED_BY_DRIVER'
124
- case 12:
125
- return 'ORDER_DELIVERY_FAILED_BY_DRIVER'
126
- case 13:
127
- return 'PREORDER'
128
- case 14:
129
- return 'ORDER_NOT_READY'
130
- case 15:
131
- return 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER'
132
- case 16:
133
- return 'ORDER_STATUS_CANCELLED_BY_CUSTOMER'
134
- case 17:
135
- return 'ORDER_NOT_PICKEDUP_BY_CUSTOMER'
136
- case 18:
137
- return 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS'
138
- case 19:
139
- return 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER'
140
- case 20:
141
- return 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS'
142
- case 21:
143
- return 'ORDER_CUSTOMER_ARRIVED_BUSINESS'
144
- default:
145
- return status
146
- }
147
- }
148
-
149
125
  const onSubmit = (values: any) => {
150
126
  handleSend && handleSend()
151
127
  setImage && setImage(null)
@@ -154,14 +130,18 @@ const MessagesUI = (props: MessagesParams) => {
154
130
 
155
131
  const messageConsole = (message: any) => {
156
132
  return message.change?.attribute !== 'driver_id'
133
+ ?
134
+ `${t('ORDER', 'Order')} ${t(message.change.attribute.toUpperCase(), message.change.attribute.replace('_', ' '))} ${t('CHANGED_FROM', 'Changed from')} ${
135
+ filterSpecialStatus.includes(message.change.attribute) ?
136
+ `${message.change.old === null ? '0' : message.change.old} ${t('TO', 'to')} ${message.change.new} ${t('MINUTES', 'Minutes')}` :
137
+ `${message.change.old !== null && t(ORDER_STATUS[parseInt(message.change.old, 10)])} ${t('TO', 'to')} ${t(ORDER_STATUS[parseInt(message.change.new, 10)])}`
138
+ }`
139
+ : message.change.new
157
140
  ?
158
- `${t('ORDER', 'Order')} ${message.change.attribute} ${t('CHANGED_FROM', 'Changed from')} ${message.change.old !== null && t(getStatus(parseInt(message.change.old, 10)))} ${t('TO', 'to')} ${t(getStatus(parseInt(message.change.new, 10)))}`
159
- : message.change.new
160
- ?
161
- `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
162
- :
163
- `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`
164
- }
141
+ `${message.driver?.name} ${message.driver?.lastname !== null ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')} ${message.comment ? message.comment.length : ''}`
142
+ :
143
+ `${t('DRIVER_UNASSIGNED', 'Driver unassigned')}`
144
+ }
165
145
 
166
146
  useEffect(() => {
167
147
  let newMessages: Array<any> = []
@@ -894,6 +894,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
894
894
  orderId={order?.id}
895
895
  messages={messages}
896
896
  order={order}
897
+ business={openModalForBusiness}
898
+ driver={openModalForDriver}
897
899
  setMessages={setMessages}
898
900
  onClose={handleCloseModal}
899
901
  />