ordering-ui-react-native 0.15.37 → 0.15.38-test

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.
Files changed (79) hide show
  1. package/package.json +3 -2
  2. package/src/components/BusinessTypeFilter/index.tsx +4 -1
  3. package/src/components/LanguageSelector/index.tsx +1 -0
  4. package/src/components/OrderDetails/index.tsx +2 -2
  5. package/src/components/PaymentOptions/index.tsx +2 -2
  6. package/src/components/StripeMethodForm/index.tsx +22 -21
  7. package/src/pages/BusinessProductsList.tsx +1 -0
  8. package/src/pages/BusinessesListing.tsx +1 -1
  9. package/themes/business/src/components/Home/index.tsx +128 -55
  10. package/themes/business/src/components/Home/styles.tsx +8 -1
  11. package/themes/business/src/components/NewOrderNotification/index.tsx +59 -98
  12. package/themes/business/src/components/OrderDetails/Delivery.tsx +9 -9
  13. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +152 -91
  14. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  15. package/themes/business/src/components/OrdersListManager/index.tsx +51 -48
  16. package/themes/business/src/components/OrdersOption/index.tsx +52 -48
  17. package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
  18. package/themes/kiosk/src/components/Cart/index.tsx +99 -25
  19. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  20. package/themes/kiosk/src/components/OrderDetails/index.tsx +134 -39
  21. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  22. package/themes/kiosk/src/components/ProductForm/index.tsx +2 -2
  23. package/themes/kiosk/src/types/index.d.ts +2 -0
  24. package/themes/original/index.tsx +165 -0
  25. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  26. package/themes/original/src/components/AddressList/index.tsx +28 -2
  27. package/themes/original/src/components/AppleLogin/index.tsx +118 -77
  28. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  29. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  30. package/themes/original/src/components/BusinessController/index.tsx +28 -9
  31. package/themes/original/src/components/BusinessController/styles.tsx +22 -0
  32. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  33. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  34. package/themes/original/src/components/BusinessListingSearch/index.tsx +4 -0
  35. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  36. package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
  37. package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
  38. package/themes/original/src/components/BusinessProductsList/index.tsx +126 -21
  39. package/themes/original/src/components/BusinessProductsList/styles.tsx +32 -2
  40. package/themes/original/src/components/BusinessProductsListing/index.tsx +12 -5
  41. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  42. package/themes/original/src/components/BusinessesListing/index.tsx +1 -2
  43. package/themes/original/src/components/Cart/index.tsx +1 -3
  44. package/themes/original/src/components/CartContent/index.tsx +2 -2
  45. package/themes/original/src/components/Checkout/index.tsx +2 -1
  46. package/themes/original/src/components/Home/index.tsx +1 -1
  47. package/themes/original/src/components/LoginForm/index.tsx +73 -2
  48. package/themes/original/src/components/LoginForm/styles.tsx +6 -1
  49. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  50. package/themes/original/src/components/Messages/index.tsx +5 -0
  51. package/themes/original/src/components/Messages/styles.tsx +1 -3
  52. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  53. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  54. package/themes/original/src/components/OrderDetails/index.tsx +1 -3
  55. package/themes/original/src/components/OrderProgress/index.tsx +3 -3
  56. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  57. package/themes/original/src/components/OrderSummary/index.tsx +2 -2
  58. package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
  59. package/themes/original/src/components/PaymentOptions/index.tsx +3 -1
  60. package/themes/original/src/components/PhoneInputNumber/index.tsx +10 -4
  61. package/themes/original/src/components/PreviousOrders/index.tsx +14 -12
  62. package/themes/original/src/components/ProductForm/index.tsx +4 -4
  63. package/themes/original/src/components/Promotions/index.tsx +232 -0
  64. package/themes/original/src/components/Promotions/styles.tsx +80 -0
  65. package/themes/original/src/components/SignupForm/index.tsx +109 -13
  66. package/themes/original/src/components/SingleProductCard/index.tsx +39 -18
  67. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  68. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  69. package/themes/original/src/components/UserFormDetails/index.tsx +13 -2
  70. package/themes/original/src/components/UserProfile/index.tsx +53 -8
  71. package/themes/original/src/components/Wallets/index.tsx +57 -3
  72. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  73. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  74. package/themes/original/src/components/shared/index.tsx +2 -0
  75. package/themes/original/src/config/constants.tsx +6 -6
  76. package/themes/original/src/types/index.tsx +21 -1
  77. package/themes/original/src/utils/index.tsx +9 -0
  78. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  79. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
2
2
  import { StyleSheet, TouchableOpacity, View, Platform, PlatformIOSStatic } from 'react-native';
3
3
  import { useTheme } from 'styled-components/native';
4
4
  import moment from 'moment'
5
- import { useLanguage, useUtils } from 'ordering-components/native';
5
+ import { useLanguage, useUtils, useConfig } from 'ordering-components/native';
6
6
  import { OButton, OIcon, OText } from '../shared';
7
7
  import {
8
8
  Card, Logo, Information, MyOrderOptions, NotificationIcon, AcceptOrRejectOrder, Timestatus
@@ -27,8 +27,14 @@ export const PreviousOrders = (props: any) => {
27
27
  } = props;
28
28
  const [, t] = useLanguage();
29
29
  const [{ parseDate, optimizeImage }] = useUtils();
30
+ const [configState] = useConfig()
30
31
  const theme = useTheme();
31
- const [currentTime, setCurrentTime] = useState()
32
+ const [, setCurrentTime] = useState()
33
+ const [allowColumns, setAllowColumns] = useState({
34
+ timer: true,
35
+ slaBar: true,
36
+ })
37
+
32
38
  const [orientationState] = useDeviceOrientation();
33
39
 
34
40
  const IS_PORTRAIT = orientationState.orientation === PORTRAIT
@@ -93,23 +99,42 @@ export const PreviousOrders = (props: any) => {
93
99
  },
94
100
  });
95
101
 
96
- const getDelayTime = (order: any) => {
102
+ const getDelayMinutes = (order: any) => {
97
103
  // targetMin = delivery_datetime + eta_time - now()
104
+ const offset = 300
105
+ const cdtToutc = moment(order?.delivery_datetime).add(offset, 'minutes').format('YYYY-MM-DD HH:mm:ss')
98
106
  const _delivery = order?.delivery_datetime_utc
107
+ ? parseDate(order?.delivery_datetime_utc)
108
+ : parseDate(cdtToutc)
99
109
  const _eta = order?.eta_time
100
- const tagetedMin = moment(_delivery).add(_eta, 'minutes').diff(moment().utc(), 'minutes')
101
- let day = Math.floor(tagetedMin / 1440)
110
+ const diffTimeAsSeconds = moment(_delivery, 'YYYY-MM-DD hh:mm A').add(_eta, 'minutes').diff(moment().utc(), 'seconds')
111
+ return Math.ceil(diffTimeAsSeconds / 60)
112
+ }
113
+
114
+ const displayDelayedTime = (order: any) => {
115
+ let tagetedMin = getDelayMinutes(order)
116
+ // get day, hour and minutes
117
+ const sign = tagetedMin >= 0 ? '' : '- '
118
+ tagetedMin = Math.abs(tagetedMin)
119
+ let day: string | number = Math.floor(tagetedMin / 1440)
102
120
  const restMinOfTargetedMin = tagetedMin - 1440 * day
103
- let restHours: any = Math.floor(restMinOfTargetedMin / 60)
104
- let restMins: any = restMinOfTargetedMin - 60 * restHours
121
+ let restHours: string | number = Math.floor(restMinOfTargetedMin / 60)
122
+ let restMins: string | number = restMinOfTargetedMin - 60 * restHours
123
+ // make standard time format
124
+ day = day === 0 ? '' : day + 'day '
125
+ restHours = restHours < 10 ? '0' + restHours : restHours
126
+ restMins = restMins < 10 ? '0' + restMins : restMins
105
127
 
106
- if (order?.time_status === 'in_time' || order?.time_status === 'at_risk') day = Math.abs(day)
107
- if (restHours < 10) restHours = ('0' + restHours)
108
- if (restMins < 10) restMins = ('0' + restMins)
109
- const finalTaget = day + 'day ' + restHours + ':' + restMins
128
+ const finalTaget = sign + day + restHours + ':' + restMins
110
129
  return finalTaget
111
130
  }
112
131
 
132
+ const getStatusClassName = (minutes: number) => {
133
+ if (isNaN(Number(minutes))) return 'in_time'
134
+ const delayTime = configState?.configs?.order_deadlines_delayed_time?.value
135
+ return minutes > 0 ? 'in_time' : Math.abs(minutes) <= delayTime ? 'at_risk' : 'delayed'
136
+ }
137
+
113
138
  useEffect(() => {
114
139
  const interval = setInterval(() => {
115
140
  const date: any = Date.now()
@@ -119,6 +144,15 @@ export const PreviousOrders = (props: any) => {
119
144
  return () => clearInterval(interval)
120
145
  }, [])
121
146
 
147
+ useEffect(() => {
148
+ const slaSettings = configState?.configs?.order_deadlines_enabled?.value === '1'
149
+ setAllowColumns({
150
+ ...allowColumns,
151
+ timer: slaSettings,
152
+ slaBar: slaSettings
153
+ })
154
+ }, [configState.loading])
155
+
122
156
  let hash: any = {};
123
157
 
124
158
  return (
@@ -144,7 +178,9 @@ export const PreviousOrders = (props: any) => {
144
178
  activeOpacity={1}
145
179
  >
146
180
  <Card key={order.id}>
147
- <Timestatus style={{ backgroundColor: order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : '' }} />
181
+ {allowColumns?.slaBar && (
182
+ <Timestatus style={{ backgroundColor: getStatusClassName(getDelayMinutes(order)) === 'in_time' ? '#00D27A' : getStatusClassName(getDelayMinutes(order)) === 'at_risk' ? '#FFC700' : getStatusClassName(getDelayMinutes(order)) === 'delayed' ? '#E63757' : '' }} />
183
+ )}
148
184
  {
149
185
  order.business?.logo && (
150
186
  <Logo style={styles.logo}>
@@ -189,10 +225,10 @@ export const PreviousOrders = (props: any) => {
189
225
  ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
190
226
  : parseDate(order?.delivery_datetime, { utc: false })}
191
227
  </OText>
192
- {(currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && (
228
+ {((currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && allowColumns?.timer) && (
193
229
  <>
194
230
  <OText> · </OText>
195
- <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>
231
+ <OText style={styles.date} color={getStatusClassName(getDelayMinutes(order)) === 'in_time' ? '#00D27A' : getStatusClassName(getDelayMinutes(order)) === 'at_risk' ? '#FFC700' : getStatusClassName(getDelayMinutes(order)) === 'delayed' ? '#E63757' : ''} >{displayDelayedTime(order)}</OText>
196
232
  </>
197
233
  )}
198
234
  </View>
@@ -10,7 +10,7 @@ import {
10
10
  useValidationFields,
11
11
  } from 'ordering-components/native';
12
12
 
13
- import { CheckoutAction, OrderTypeWrapper, FloatingLayout } from './styles';
13
+ import { CheckoutAction, OrderTypeWrapper, FloatingLayout, OSRow } from './styles';
14
14
 
15
15
  import { OSBill, OSCoupon, OSTable } from '../OrderSummary/styles';
16
16
 
@@ -90,6 +90,20 @@ const CartUI = (props: any) => {
90
90
 
91
91
  const goToBack = () => navigation.goBack();
92
92
 
93
+ const getIncludedTaxes = () => {
94
+ if (cart?.taxes === null) {
95
+ return cart.business.tax_type === 1 ? cart?.tax : 0
96
+ } else {
97
+ return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
98
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
99
+ }, 0)
100
+ }
101
+ }
102
+
103
+ const getIncludedTaxesDiscounts = () => {
104
+ return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
105
+ }
106
+
93
107
  return (
94
108
  <>
95
109
  <Container>
@@ -177,13 +191,10 @@ const CartUI = (props: any) => {
177
191
  <OSTable>
178
192
  <OText>{t('SUBTOTAL', 'Subtotal')}</OText>
179
193
  <OText>
180
- {cart.business.tax_type === 1
181
- ? parsePrice((cart?.subtotal + cart?.tax) || 0)
182
- : parsePrice(cart?.subtotal || 0)}
194
+ {parsePrice(cart?.subtotal + getIncludedTaxes())}
183
195
  </OText>
184
196
  </OSTable>
185
- {cart?.discount > 0 && cart?.total >= 0 && orientationState?.orientation == PORTRAIT && (
186
-
197
+ {cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && orientationState?.orientation == PORTRAIT && (
187
198
  <OSTable
188
199
  style={{
189
200
  backgroundColor: theme.colors.success,
@@ -226,44 +237,107 @@ const CartUI = (props: any) => {
226
237
  </OText>
227
238
  </OSTable>
228
239
  )}
229
- {cart.business.tax_type !== 1 && (
240
+ {
241
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
242
+ <OSTable key={offer.id}>
243
+ <OSRow>
244
+ <OText>{offer.name}</OText>
245
+ {offer.rate_type === 1 && (
246
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
247
+ )}
248
+ </OSRow>
249
+ <OText>
250
+ - {parsePrice(offer?.summary?.discount)}
251
+ </OText>
252
+ </OSTable>
253
+ ))
254
+ }
255
+ {cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
230
256
  <OSTable>
231
- <OText>
232
- {t('TAX', 'Tax')}
233
- {`(${verifyDecimals(cart?.business?.tax, parseNumber)}%)`}
234
- </OText>
235
- <OText>{parsePrice(cart?.tax || 0)}</OText>
257
+ <OText numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
258
+ {cart?.business?.tax_type === 1 ? (
259
+ <OText>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
260
+ ) : (
261
+ <OText>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
262
+ )}
236
263
  </OSTable>
237
264
  )}
265
+ {
266
+ cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
267
+ <OSTable key={tax.id}>
268
+ <OSRow>
269
+ <OText>
270
+ {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
271
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
272
+ </OText>
273
+ </OSRow>
274
+ <OText>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
275
+ </OSTable>
276
+ ))
277
+ }
278
+ {
279
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
280
+ <OSTable key={fee?.id}>
281
+ <OSRow>
282
+ <OText>
283
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
284
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
285
+ </OText>
286
+ </OSRow>
287
+ <OText>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
288
+ </OSTable>
289
+ ))
290
+ }
291
+ {
292
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
293
+ <OSTable key={offer.id}>
294
+ <OSRow>
295
+ <OText>{offer.name}</OText>
296
+ {offer.rate_type === 1 && (
297
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
298
+ )}
299
+ </OSRow>
300
+ <OText>
301
+ - {parsePrice(offer?.summary?.discount)}
302
+ </OText>
303
+ </OSTable>
304
+ ))
305
+ }
238
306
  {selectedOrderType === 1 && cart?.delivery_price > 0 && (
239
307
  <OSTable>
240
308
  <OText>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
241
309
  <OText>{parsePrice(cart?.delivery_price)}</OText>
242
310
  </OSTable>
243
311
  )}
312
+ {
313
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
314
+ <OSTable key={offer.id}>
315
+ <OSRow>
316
+ <OText>{offer.name}</OText>
317
+ {offer.rate_type === 1 && (
318
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
319
+ )}
320
+ </OSRow>
321
+ <OText>
322
+ - {parsePrice(offer?.summary?.discount)}
323
+ </OText>
324
+ </OSTable>
325
+ ))
326
+ }
244
327
  {cart?.driver_tip > 0 && (
245
328
  <OSTable>
246
329
  <OText>
247
330
  {t('DRIVER_TIP', 'Driver tip')}
248
331
  {cart?.driver_tip_rate > 0 &&
249
332
  parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
250
- !!!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
333
+ !parseInt(configs?.driver_tip_use_custom?.value, 10) &&
251
334
  (
252
- `(${parseNumber(cart?.driver_tip_rate)}%)`
335
+ `(${verifyDecimals(cart?.driver_tip_rate, parseNumber)}%)`
253
336
  )}
254
337
  </OText>
255
338
  <OText>{parsePrice(cart?.driver_tip)}</OText>
256
339
  </OSTable>
257
340
  )}
258
- {cart?.service_fee > 0 && (
259
- <OSTable>
260
- <OText>
261
- {t('SERVICE_FEE', 'Service Fee')}
262
- {`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
263
- </OText>
264
- <OText>{parsePrice(cart?.service_fee)}</OText>
265
- </OSTable>
266
- )}
267
341
  {!cart?.discount_type && isCouponEnabled && !isCartPending && orientationState?.orientation == PORTRAIT && (
268
342
  <OSTable>
269
343
  <OSCoupon>
@@ -279,7 +353,7 @@ const CartUI = (props: any) => {
279
353
  {t('TOTAL', 'Total')}
280
354
  </OText>
281
355
  <OText weight='bold' color={theme.colors.primary}>
282
- {cart?.total >= 1 && parsePrice(cart?.total)}
356
+ {parsePrice(cart?.total >= 0 ? cart?.total : 0)}
283
357
  </OText>
284
358
  </OSTable>
285
359
  </OSBill>
@@ -379,7 +453,7 @@ const CartUI = (props: any) => {
379
453
  <ProductForm
380
454
  productCart={curProduct}
381
455
  businessSlug={cart?.business?.slug}
382
- businessId={cart?.business_id}
456
+ businessId={curProduct?.business_id}
383
457
  categoryId={curProduct?.category_id}
384
458
  productId={curProduct?.id}
385
459
  onSave={handlerProductAction}
@@ -68,3 +68,9 @@ export const FloatingLayout = styled.View`
68
68
  padding-bottom: 20px;
69
69
  `)}
70
70
  `
71
+
72
+ export const OSRow = styled.View`
73
+ flex-direction: row;
74
+ overflow: hidden;
75
+ width: 80%;
76
+ `
@@ -23,6 +23,7 @@ import {
23
23
  Table,
24
24
  OrderBill,
25
25
  Total,
26
+ OSRow,
26
27
  } from './styles'
27
28
  import { OrderDetailsParams, Product } from '../../types'
28
29
  import { Container } from '../../layouts/Container';
@@ -178,6 +179,20 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
178
179
  setIsLoading(false)
179
180
  }
180
181
 
182
+ const getIncludedTaxes = () => {
183
+ if (order?.taxes?.length === 0) {
184
+ return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
185
+ } else {
186
+ return order?.taxes.reduce((taxIncluded: number, tax: any) => {
187
+ return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
188
+ }, 0)
189
+ }
190
+ }
191
+
192
+ const getIncludedTaxesDiscounts = () => {
193
+ return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
194
+ }
195
+
181
196
  useEffect(() => {
182
197
  const backAction = () => {
183
198
  Alert.alert(`${t('HOLD_ON', 'Hold on')}!`, `${t('ARE_YOU_SURE_YOU_WANT_TO_GO_BACK', 'Are you sure you want to go back')}?`, [
@@ -209,7 +224,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
209
224
  const getCustomerName = async () => {
210
225
  try {
211
226
  const { customerName: name } = await _retrieveStoreData('customer_name')
212
- setCustomerName(name)
227
+ setCustomerName(name)
213
228
  } catch (e) {
214
229
  if (e) {
215
230
  setCustomerName(null)
@@ -217,8 +232,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
217
232
  }
218
233
  }
219
234
  getCustomerName()
220
- const redirectHome = setTimeout(() =>{
221
- _setStoreData('customer_name', {customerName: ''});
235
+ const redirectHome = setTimeout(() => {
236
+ _setStoreData('customer_name', { customerName: '' });
222
237
  navigation.reset({
223
238
  routes: [{ name: 'Intro' }],
224
239
  });
@@ -345,7 +360,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
345
360
  <OButton
346
361
  text={`${t('YOU_ARE_DONE', 'You are done! Click to close')}!`}
347
362
  onClick={() => {
348
- _setStoreData('customer_name', {customerName: ''});
363
+ _setStoreData('customer_name', { customerName: '' });
349
364
  navigation.reset({
350
365
  routes: [{ name: 'Intro' }],
351
366
  });
@@ -419,46 +434,135 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
419
434
  <Table>
420
435
  <OText>{t('SUBTOTAL', 'Subtotal')}</OText>
421
436
  <OText>
422
- {parsePrice(isTaxIncluded
423
- ? (order?.summary?.subtotal + order?.summary?.tax) ?? 0
424
- : order?.summary?.subtotal ?? 0
425
- )}
437
+ {parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()))}
426
438
  </OText>
427
439
  </Table>
428
- {order?.summary?.discount > 0 && (
440
+ {(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
429
441
  <Table>
430
442
  {order?.offer_type === 1 ? (
431
443
  <OText>
432
444
  {t('DISCOUNT', 'Discount')}
433
- <OText>{`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}</OText>
445
+ <OText>{`(${verifyDecimals(
446
+ order?.offer_rate,
447
+ parsePrice,
448
+ )}%)`}</OText>
434
449
  </OText>
435
450
  ) : (
436
451
  <OText>{t('DISCOUNT', 'Discount')}</OText>
437
452
  )}
438
- <OText>- {parsePrice(order?.summary?.discount)}</OText>
453
+ <OText>
454
+ - {parsePrice(order?.summary?.discount || order?.discount)}
455
+ </OText>
439
456
  </Table>
440
457
  )}
458
+ {
459
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
460
+ <Table key={offer.id}>
461
+ <OSRow>
462
+ <OText>
463
+ {offer.name}
464
+ {offer.rate_type === 1 && (
465
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
466
+ )}
467
+ </OText>
468
+ </OSRow>
469
+ <OText>- {parsePrice(offer?.summary?.discount)}</OText>
470
+ </Table>
471
+ ))
472
+ }
441
473
  {order?.summary?.subtotal_with_discount > 0 && order?.summary?.discount > 0 && order?.summary?.total >= 0 && (
442
474
  <Table>
443
475
  <OText>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
444
- <OText>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
445
- </Table>
446
- )}
447
- {order?.tax_type !== 1 && (
448
- <Table>
449
- <OText>
450
- {t('TAX', 'Tax')}
451
- {`(${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%)`}
452
- </OText>
453
- <OText>{parsePrice(order?.summary?.tax)}</OText>
476
+ {order?.tax_type === 1 ? (
477
+ <OText>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0))}</OText>
478
+ ) : (
479
+ <OText>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
480
+ )}
454
481
  </Table>
455
482
  )}
483
+ {
484
+ order?.taxes?.length === 0 && order?.tax_type === 2 && (
485
+ <Table>
486
+ <OText>
487
+ {t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
488
+ </OText>
489
+ <OText>{parsePrice(order?.summary?.tax || 0)}</OText>
490
+ </Table>
491
+ )
492
+ }
493
+ {
494
+ order?.fees?.length === 0 && (
495
+ <Table>
496
+ <OText>
497
+ {t('SERVICE_FEE', 'Service fee')}
498
+ {`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
499
+ </OText>
500
+ <OText>{parsePrice(order?.summary?.service_fee || 0)}</OText>
501
+ </Table>
502
+ )
503
+ }
504
+ {
505
+ order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
506
+ <Table key={tax.id}>
507
+ <OSRow>
508
+ <OText>
509
+ {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
510
+ {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
511
+ </OText>
512
+ </OSRow>
513
+ <OText>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
514
+ </Table>
515
+ ))
516
+ }
517
+ {
518
+ order?.fees?.length > 0 && order?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
519
+ <Table key={fee.id}>
520
+ <OSRow>
521
+ <OText>
522
+ {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
523
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
524
+ </OText>
525
+ </OSRow>
526
+ <OText>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
527
+ </Table>
528
+ ))
529
+ }
530
+ {
531
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
532
+ <Table key={offer.id}>
533
+ <OSRow>
534
+ <OText>
535
+ {offer.name}
536
+ {offer.rate_type === 1 && (
537
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
538
+ )}
539
+ </OText>
540
+ </OSRow>
541
+ <OText>- {parsePrice(offer?.summary?.discount)}</OText>
542
+ </Table>
543
+ ))
544
+ }
456
545
  {order?.summary?.delivery_price > 0 && (
457
546
  <Table>
458
547
  <OText>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
459
548
  <OText>{parsePrice(order?.summary?.delivery_price)}</OText>
460
549
  </Table>
461
550
  )}
551
+ {
552
+ order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
553
+ <Table key={offer.id}>
554
+ <OSRow>
555
+ <OText>
556
+ {offer.name}
557
+ {offer.rate_type === 1 && (
558
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
559
+ )}
560
+ </OText>
561
+ </OSRow>
562
+ <OText>- {parsePrice(offer?.summary?.discount)}</OText>
563
+ </Table>
564
+ ))
565
+ }
462
566
  {order?.summary?.driver_tip > 0 && (
463
567
  <Table>
464
568
  <OText>
@@ -470,23 +574,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
470
574
  `(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
471
575
  )}
472
576
  </OText>
473
- <OText>{parsePrice(order?.summary?.driver_tip ?? 0)}</OText>
474
- </Table>
475
- )}
476
- {order?.summary?.service_fee > 0 && (
477
- <Table>
478
- <OText>
479
- {t('SERVICE_FEE', 'Service Fee')}
480
- {`(${verifyDecimals(order?.summary?.service_fee, parseNumber)}%)`}
481
- </OText>
482
- <OText>{parsePrice(order?.summary?.service_fee)}</OText>
577
+ <OText>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip)}</OText>
483
578
  </Table>
484
579
  )}
485
580
  <Total>
486
581
  <Table>
487
582
  <OText style={styles.textBold}>{t('TOTAL', 'Total')}</OText>
488
583
  <OText style={styles.textBold} color={theme.colors.primary}>
489
- {parsePrice(order?.summary?.total ?? 0)}
584
+ {parsePrice(order?.summary?.total ?? order?.total)}
490
585
  </OText>
491
586
  </Table>
492
587
  </Total>
@@ -508,14 +603,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
508
603
  <OIconButton
509
604
  bgColor="transparent"
510
605
  borderColor="transparent"
511
- RenderIcon={() =>
512
- <EvilIcons
513
- name={'close'}
514
- size={40}
515
- color={theme.colors.primary}
516
- />
606
+ RenderIcon={() =>
607
+ <EvilIcons
608
+ name={'close'}
609
+ size={40}
610
+ color={theme.colors.primary}
611
+ />
517
612
  }
518
- style={{ flex:1, justifyContent: 'flex-end', left: 30 }}
613
+ style={{ flex: 1, justifyContent: 'flex-end', left: 30 }}
519
614
  onClick={() => {
520
615
  navigation.reset({
521
616
  routes: [{ name: 'Intro' }],
@@ -51,3 +51,8 @@ export const Total = styled.View`
51
51
  padding-vertical: 10px;
52
52
  `
53
53
 
54
+ export const OSRow = styled.View`
55
+ flex-direction: row;
56
+ overflow: hidden;
57
+ width: 80%;
58
+ `
@@ -446,7 +446,7 @@ export const ProductOptionsUI = (props: any) => {
446
446
  </WrapperIngredients>
447
447
  </View>
448
448
  )}
449
- {product?.extras.map((extra: any) => extra.options.map((option: any) => {
449
+ {product?.extras.map((extra: any) => extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
450
450
  const currentState = productCart.options[`id:${option.id}`] || {}
451
451
  return (
452
452
  <React.Fragment key={option.id}>
@@ -460,7 +460,7 @@ export const ProductOptionsUI = (props: any) => {
460
460
  >
461
461
  <WrapperSubOption style={{ backgroundColor: isError(option.id) }}>
462
462
  {
463
- option.suboptions.map((suboption: any) => {
463
+ option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map((suboption: any) => {
464
464
  const currentState = productCart.options[`id:${option.id}`]?.suboptions[`id:${suboption.id}`] || {}
465
465
  const balance = productCart.options[`id:${option.id}`]?.balance || 0
466
466
  return (
@@ -472,6 +472,8 @@ export interface Cart {
472
472
  delivery_price_with_discount: number;
473
473
  total: number;
474
474
  clearInactivityTimeout: any;
475
+ taxes: Array<any>;
476
+ fees: Array<any>;
475
477
  }
476
478
 
477
479
  export interface NoNetworkParams {