ordering-ui-react-native 0.14.23 → 0.14.27

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.23",
3
+ "version": "0.14.27",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -150,10 +150,10 @@ const CheckoutUI = (props: any) => {
150
150
  const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
151
151
  const cartsWithProducts = carts && Object.values(carts).filter((cart: any) => cart.products.length) || null
152
152
 
153
- const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map(option => {
153
+ const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map((option: any) => {
154
154
  return {
155
- value: option?.id, key: option?.id, label: option?.name
156
- }
155
+ value: option?.id, key: option?.id, label: t(option?.name.toUpperCase().replace(/\s/g, '_'), option?.name)
156
+ }
157
157
  })
158
158
 
159
159
  const handlePlaceOrder = () => {
@@ -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 : ''}`
@@ -15,5 +15,5 @@ export const WrapperNotFound = styled.View`
15
15
  export const ProductsWrapper = styled.View`
16
16
  flex-direction: row;
17
17
  flex-wrap: wrap;
18
- align-items: flex-start;
18
+ margin-bottom: 20px;
19
19
  `
@@ -6,7 +6,7 @@ import {
6
6
  CardInfo,
7
7
  SoldOut
8
8
  } from './styles'
9
- import { StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
9
+ import { StyleSheet, TouchableOpacity, Dimensions, View } from 'react-native'
10
10
  import { OText, OIcon } from '../shared'
11
11
  import { useTheme } from 'styled-components/native'
12
12
 
@@ -23,11 +23,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
23
23
 
24
24
  const styles = StyleSheet.create({
25
25
  container: {
26
- width: (windowWidth - 80) / 2,
27
- height: (windowWidth - 80) / 2 + 40
28
- },
29
- textStyle: {
30
- flex: 1,
26
+ width: (windowWidth - 80) / 2
31
27
  },
32
28
  soldOutTextStyle : {
33
29
  textTransform: 'capitalize',
@@ -35,9 +31,14 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
35
31
  fontSize: 12,
36
32
  lineHeight: 18
37
33
  },
38
- productStyle: {
34
+ imageWrapper: {
39
35
  width: (windowWidth - 160) / 2,
40
36
  height: (windowWidth - 160) / 2,
37
+ position: 'relative'
38
+ },
39
+ productStyle: {
40
+ width: '100%',
41
+ height: '100%',
41
42
  borderRadius: 3,
42
43
  marginTop: 5
43
44
  },
@@ -74,26 +75,30 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
74
75
  onPress={() => onProductClick?.(product)}
75
76
  activeOpacity={0.8}
76
77
  >
77
- <OIcon
78
- url={optimizeImage(product?.images, 'h_200,c_limit')}
79
- src={!product?.images && theme.images.dummies.product}
80
- style={{...styles.productStyle, opacity: (isSoldOut || maxProductQuantity <= 0) ? 0.4 : 1}}
81
- />
78
+ <View
79
+ style={styles.imageWrapper}
80
+ >
81
+ <OIcon
82
+ url={optimizeImage(product?.images, 'h_200,c_limit')}
83
+ src={!product?.images && theme.images.dummies.product}
84
+ style={{...styles.productStyle, opacity: (isSoldOut || maxProductQuantity <= 0) ? 0.4 : 1}}
85
+ />
86
+ {(isSoldOut || maxProductQuantity <= 0) && (
87
+ <SoldOut>
88
+ <OText size={10} style={styles.soldOutTextStyle}>{t('SOLD_OUT', 'SOLD OUT')}</OText>
89
+ </SoldOut>
90
+ )}
91
+ </View>
82
92
  <CardInfo>
83
93
  <OText color={theme.colors.textPrimary} style={{...theme.labels.normal, marginTop: 9}}>{parsePrice(product?.price)}</OText>
84
- <OText numberOfLines={1} ellipsizeMode='tail' style={{...styles.textStyle, ...theme.labels.small}}>{product?.name}</OText>
85
- <OText color={theme.colors.textSecondary} size={9} numberOfLines={2} ellipsizeMode='tail' style={{...styles.textStyle, ...theme.labels.small}}>{product?.description}</OText>
94
+ <OText numberOfLines={1} ellipsizeMode='tail' style={{...theme.labels.small}}>{product?.name}</OText>
95
+ <OText color={theme.colors.textSecondary} size={9} numberOfLines={2} ellipsizeMode='tail' style={{...theme.labels.small}}>{product?.description}</OText>
86
96
  </CardInfo>
87
97
 
88
98
  <TouchableOpacity style={styles.addBtn} onPress={() => onProductClick?.(product)} activeOpacity={0.7}>
89
99
  <OIcon src={theme.images.general.plus_circle} />
90
100
  </TouchableOpacity>
91
101
 
92
- {(isSoldOut || maxProductQuantity <= 0) && (
93
- <SoldOut>
94
- <OText size={10} style={styles.soldOutTextStyle}>{t('SOLD_OUT', 'SOLD OUT')}</OText>
95
- </SoldOut>
96
- )}
97
102
  </CardContainer>
98
103
  )
99
104
  }
@@ -1,12 +1,9 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
3
  export const CardContainer = styled.TouchableOpacity`
4
- /* flex-grow: 1; */
5
- align-items: flex-start;
4
+ flex-direction: column;
6
5
  padding: 10px;
7
6
  position: relative;
8
- /* margin-end: 10px; */
9
- border-radius: 3px;
10
7
  `
11
8
  export const CardInfo = styled.View`
12
9
  flex: 1;
@@ -16,6 +13,7 @@ export const SoldOut = styled.View`
16
13
  position: absolute;
17
14
  background: ${(props: any) => props.theme.colors.black} 0% 0% no-repeat padding-box;
18
15
  padding: 3px 9px;
19
- top: 91px;
20
- left: 10px;
16
+ left: 0px;
17
+ bottom: -5px;
18
+ border-radius: 3px;
21
19
  `
@@ -17,6 +17,7 @@ export const BusinessItemAccordion = (props: any) => {
17
17
  const {
18
18
  cart,
19
19
  moment,
20
+ singleBusiness,
20
21
  handleClearProducts
21
22
  } = props
22
23
 
@@ -29,7 +30,7 @@ export const BusinessItemAccordion = (props: any) => {
29
30
  const isClosed = !cart?.valid_schedule
30
31
  const isProducts = cart?.products?.length
31
32
 
32
- const [isActive, setActiveState] = useState(false)
33
+ const [isActive, setActiveState] = useState(!!singleBusiness)
33
34
 
34
35
  useEffect(() => {
35
36
  const cartsArray = Object.values(orderState?.carts)
@@ -113,6 +113,15 @@ const CartUI = (props: any) => {
113
113
  }
114
114
  }
115
115
 
116
+ const walletName: any = {
117
+ cash: {
118
+ name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
119
+ },
120
+ credit_point: {
121
+ name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
122
+ }
123
+ }
124
+
116
125
  return (
117
126
  <CContainer>
118
127
  {openUpselling && (
@@ -130,6 +139,7 @@ const CartUI = (props: any) => {
130
139
  )}
131
140
  <BusinessItemAccordion
132
141
  cart={cart}
142
+ singleBusiness={props.singleBusiness}
133
143
  moment={momentFormatted}
134
144
  handleClearProducts={handleClearProducts}
135
145
  handleCartOpen={handleCartOpen}
@@ -191,7 +201,7 @@ const CartUI = (props: any) => {
191
201
  cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
192
202
  <OSTable key={fee?.id}>
193
203
  <OSRow>
194
- <OText numberOfLines={1}>
204
+ <OText numberOfLines={1} size={12} lineHeight={18}>
195
205
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
196
206
  ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
197
207
  </OText>
@@ -203,6 +213,15 @@ const CartUI = (props: any) => {
203
213
  </OSTable>
204
214
  ))
205
215
  }
216
+ {cart?.service_fee > 0 && !cart?.fees?.length && (
217
+ <OSTable>
218
+ <OText size={12} lineHeight={18}>
219
+ {t('SERVICE_FEE', 'Service Fee')}
220
+ {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
221
+ </OText>
222
+ <OText size={12} lineHeight={18}>{parsePrice(cart?.service_fee)}</OText>
223
+ </OSTable>
224
+ )}
206
225
  {orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
207
226
  <OSTable>
208
227
  <OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
@@ -223,15 +242,14 @@ const CartUI = (props: any) => {
223
242
  <OText size={12} lineHeight={18}>{parsePrice(cart?.driver_tip)}</OText>
224
243
  </OSTable>
225
244
  )}
226
- {cart?.service_fee > 0 && (
227
- <OSTable>
228
- <OText size={12} lineHeight={18}>
229
- {t('SERVICE_FEE', 'Service Fee')}
230
- {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
245
+ {cart?.payment_events?.length > 0 && cart?.payment_events?.map((event: any) => (
246
+ <OSTable key={event.id}>
247
+ <OText size={12} numberOfLines={1}>
248
+ {walletName[cart?.wallets?.find((wallet: any) => wallet.id === event.wallet_id)?.type]?.name}
231
249
  </OText>
232
- <OText size={12} lineHeight={18}>{parsePrice(cart?.service_fee)}</OText>
250
+ <OText size={12}>-{parsePrice(event.amount)}</OText>
233
251
  </OSTable>
234
- )}
252
+ ))}
235
253
  {isCouponEnabled && !isCartPending && (
236
254
  <OSTable>
237
255
  <OSCoupon>
@@ -249,7 +267,7 @@ const CartUI = (props: any) => {
249
267
  {t('TOTAL', 'Total')}
250
268
  </OText>
251
269
  <OText size={14} lineHeight={21} weight={'600'}>
252
- {cart?.total >= 1 && parsePrice(cart?.total)}
270
+ {parsePrice(cart?.balance ?? cart?.total)}
253
271
  </OText>
254
272
  </OSTable>
255
273
  </OSTotal>
@@ -30,6 +30,7 @@ export const CartContent = (props: any) => {
30
30
  {cart.products.length > 0 && (
31
31
  <>
32
32
  <Cart
33
+ singleBusiness={props.singleBusiness}
33
34
  isFranchiseApp={props.isFranchiseApp}
34
35
  cart={cart}
35
36
  cartuuid={cart.uuid}
@@ -137,7 +137,7 @@ const CheckoutUI = (props: any) => {
137
137
 
138
138
  const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map((option: any) => {
139
139
  return {
140
- value: option?.id, key: option?.id, label: option?.name
140
+ value: option?.id, key: option?.id, label: t(option?.name.toUpperCase().replace(/\s/g, '_'), option?.name)
141
141
  }
142
142
  })
143
143
 
@@ -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
  />
@@ -177,6 +177,14 @@ const OrderSummaryUI = (props: any) => {
177
177
  <OText size={12}>{parsePrice(cart?.driver_tip)}</OText>
178
178
  </OSTable>
179
179
  )}
180
+ {cart?.payment_events?.length > 0 && cart?.payment_events?.map((event: any) => (
181
+ <OSTable key={event.id}>
182
+ <OText size={12} numberOfLines={1}>
183
+ {walletName[cart?.wallets?.find((wallet: any) => wallet.id === event.wallet_id)?.type]?.name}
184
+ </OText>
185
+ <OText size={12}>-{parsePrice(event.amount)}</OText>
186
+ </OSTable>
187
+ ))}
180
188
  {isCouponEnabled && !isCartPending && (
181
189
  <View>
182
190
  <View style={{ paddingVertical: 5 }}>
@@ -194,7 +202,7 @@ const OrderSummaryUI = (props: any) => {
194
202
  {t('TOTAL', 'Total')}
195
203
  </OText>
196
204
  <OText size={14} style={{ fontWeight: 'bold' }} >
197
- {parsePrice(cart?.total)}
205
+ {parsePrice(cart?.balance ?? cart?.total)}
198
206
  </OText>
199
207
  </OSTable>
200
208
  </View>
@@ -232,52 +240,6 @@ const OrderSummaryUI = (props: any) => {
232
240
  </View>
233
241
  </OSTable>
234
242
  )}
235
- {cart?.payment_events?.length > 0 && (
236
- <View
237
- style={{
238
- width: '100%',
239
- marginTop: 20
240
- }}
241
- >
242
- {cart?.payment_events?.map((event: any) => (
243
- <View
244
- key={event.id}
245
- style={{
246
- display: 'flex',
247
- flexDirection: 'row',
248
- justifyContent: 'space-between',
249
- marginBottom: 10
250
- }}
251
- >
252
- <OText>
253
- {walletName[cart?.wallets?.find((wallet: any) => wallet.id === event.wallet_id)?.type]?.name}
254
- </OText>
255
- <OText>
256
- -{parsePrice(event.amount)}
257
- </OText>
258
- </View>
259
- ))}
260
- <View
261
- style={{
262
- display: 'flex',
263
- flexDirection: 'row',
264
- justifyContent: 'space-between',
265
- marginBottom: 10
266
- }}
267
- >
268
- <OText
269
- weight={'bold'}
270
- >
271
- {t('TOTAL_TO_PAY', 'Total to pay')}
272
- </OText>
273
- <OText
274
- weight={'bold'}
275
- >
276
- {parsePrice(cart?.balance)}
277
- </OText>
278
- </View>
279
- </View>
280
- )}
281
243
  </OSBill>
282
244
  )}
283
245
  <OModal