ordering-ui-react-native 0.15.35 → 0.15.37-release

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 (187) hide show
  1. package/package.json +4 -2
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessController/index.tsx +8 -2
  4. package/src/components/BusinessTypeFilter/index.tsx +4 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +23 -3
  7. package/src/components/DriverTips/index.tsx +11 -6
  8. package/src/components/LanguageSelector/index.tsx +7 -2
  9. package/src/components/LoginForm/index.tsx +3 -1
  10. package/src/components/OrderDetails/index.tsx +2 -2
  11. package/src/components/PaymentOptions/index.tsx +9 -16
  12. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  13. package/src/components/SignupForm/index.tsx +3 -1
  14. package/src/components/SingleProductCard/index.tsx +16 -4
  15. package/src/components/StripeElementsForm/index.tsx +27 -48
  16. package/src/components/StripeMethodForm/index.tsx +1 -2
  17. package/src/components/UpsellingProducts/index.tsx +1 -1
  18. package/src/components/UserProfileForm/index.tsx +63 -6
  19. package/src/components/UserProfileForm/styles.tsx +8 -0
  20. package/src/components/VerifyPhone/styles.tsx +1 -2
  21. package/src/components/shared/OModal.tsx +1 -1
  22. package/src/config.json +0 -2
  23. package/src/hooks/useCountdownTimer.tsx +26 -0
  24. package/src/navigators/CheckoutNavigator.tsx +6 -0
  25. package/src/navigators/HomeNavigator.tsx +12 -0
  26. package/src/pages/BusinessProductsList.tsx +1 -0
  27. package/src/pages/BusinessesListing.tsx +1 -1
  28. package/src/pages/Checkout.tsx +1 -1
  29. package/src/pages/MultiCheckout.tsx +31 -0
  30. package/src/pages/MultiOrdersDetails.tsx +27 -0
  31. package/src/pages/Sessions.tsx +22 -0
  32. package/src/types/index.tsx +5 -11
  33. package/src/utils/index.tsx +68 -1
  34. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  35. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  36. package/themes/business/src/components/Chat/index.tsx +38 -86
  37. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  38. package/themes/business/src/components/Home/index.tsx +128 -55
  39. package/themes/business/src/components/Home/styles.tsx +8 -1
  40. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  41. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  42. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  43. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  44. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  45. package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
  46. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +157 -89
  47. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  48. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  49. package/themes/business/src/components/OrdersListManager/index.tsx +52 -49
  50. package/themes/business/src/components/OrdersOption/index.tsx +57 -50
  51. package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
  52. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  53. package/themes/business/src/components/shared/OModal.tsx +1 -1
  54. package/themes/business/src/types/index.tsx +5 -1
  55. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  57. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  58. package/themes/kiosk/src/components/Cart/index.tsx +99 -25
  59. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  60. package/themes/kiosk/src/components/Checkout/index.tsx +34 -22
  61. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  62. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  63. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  64. package/themes/kiosk/src/components/OrderDetails/index.tsx +165 -65
  65. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  66. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  67. package/themes/kiosk/src/components/PaymentOptions/index.tsx +1 -1
  68. package/themes/kiosk/src/components/ProductForm/index.tsx +2 -2
  69. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  70. package/themes/kiosk/src/types/index.d.ts +2 -0
  71. package/themes/original/index.tsx +190 -1
  72. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  73. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  74. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  75. package/themes/original/src/components/AddressList/index.tsx +56 -18
  76. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  77. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  78. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  79. package/themes/original/src/components/BusinessController/index.tsx +56 -16
  80. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  81. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  82. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  83. package/themes/original/src/components/BusinessItemAccordion/index.tsx +4 -3
  84. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  85. package/themes/original/src/components/BusinessListingSearch/index.tsx +200 -58
  86. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  87. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  88. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
  89. package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
  90. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  91. package/themes/original/src/components/BusinessProductsList/index.tsx +139 -36
  92. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  93. package/themes/original/src/components/BusinessProductsListing/index.tsx +125 -21
  94. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  95. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  96. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  97. package/themes/original/src/components/BusinessesListing/index.tsx +143 -81
  98. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  99. package/themes/original/src/components/Cart/index.tsx +60 -43
  100. package/themes/original/src/components/CartContent/index.tsx +2 -2
  101. package/themes/original/src/components/Checkout/index.tsx +59 -48
  102. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  103. package/themes/original/src/components/Favorite/index.tsx +91 -0
  104. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  105. package/themes/original/src/components/FavoriteList/index.tsx +287 -0
  106. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  107. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  108. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  109. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  110. package/themes/original/src/components/Help/index.tsx +21 -4
  111. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  112. package/themes/original/src/components/Home/index.tsx +1 -1
  113. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  114. package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
  115. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  116. package/themes/original/src/components/LoginForm/index.tsx +394 -155
  117. package/themes/original/src/components/LoginForm/styles.tsx +7 -4
  118. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  119. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  120. package/themes/original/src/components/Messages/index.tsx +6 -1
  121. package/themes/original/src/components/Messages/styles.tsx +1 -3
  122. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  123. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  124. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  125. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  126. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  127. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  128. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  129. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  130. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  131. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  132. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  133. package/themes/original/src/components/OrderDetails/index.tsx +56 -33
  134. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  135. package/themes/original/src/components/OrderProgress/index.tsx +3 -3
  136. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  137. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  138. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  139. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  140. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  141. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  142. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  143. package/themes/original/src/components/OrdersOption/index.tsx +133 -41
  144. package/themes/original/src/components/OrdersOption/styles.tsx +4 -7
  145. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  146. package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
  147. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  148. package/themes/original/src/components/PaymentOptions/index.tsx +9 -21
  149. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  150. package/themes/original/src/components/PreviousOrders/index.tsx +18 -145
  151. package/themes/original/src/components/ProductForm/index.tsx +76 -61
  152. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  153. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  154. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  155. package/themes/original/src/components/Promotions/index.tsx +250 -0
  156. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  157. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  158. package/themes/original/src/components/Sessions/index.tsx +160 -0
  159. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  160. package/themes/original/src/components/SignupForm/index.tsx +9 -4
  161. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  162. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  163. package/themes/original/src/components/SingleProductCard/index.tsx +95 -32
  164. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  165. package/themes/original/src/components/StripeElementsForm/index.tsx +10 -2
  166. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  167. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  168. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  169. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  170. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  171. package/themes/original/src/components/UserProfile/index.tsx +62 -8
  172. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  173. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  174. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  175. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  176. package/themes/original/src/components/Wallets/index.tsx +76 -9
  177. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  178. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  179. package/themes/original/src/components/shared/OModal.tsx +4 -2
  180. package/themes/original/src/components/shared/index.tsx +2 -0
  181. package/themes/original/src/config/constants.tsx +6 -6
  182. package/themes/original/src/types/index.tsx +132 -9
  183. package/themes/original/src/utils/index.tsx +28 -2
  184. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  185. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  186. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  187. package/themes/uber-eats/src/components/BusinessesListing/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>
@@ -153,7 +153,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
153
153
  {(
154
154
  productInfo?.()?.ingredients?.length > 0 ||
155
155
  productInfo?.()?.options?.length > 0 ||
156
- product.comment
156
+ !!product.comment
157
157
  ) && !isClickableEvent && (
158
158
  <MaterialCommunityIcon name="chevron-down" size={12} />
159
159
  )}
@@ -278,7 +278,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
278
278
  </ProductOptionsList>
279
279
  )}
280
280
 
281
- {product.comment && (
281
+ {!!product.comment && (
282
282
  <ProductComment>
283
283
  <OText
284
284
  size={12}
@@ -165,7 +165,7 @@ const OModal = (props: Props): React.ReactElement => {
165
165
  transparent={isTransparent}
166
166
  visible={open}
167
167
  onRequestClose={() => {
168
- onClose();
168
+ onClose && onClose();
169
169
  }}
170
170
  style={{
171
171
  height: '100%',
@@ -20,6 +20,9 @@ export interface LoginParams {
20
20
  passwordInputIcon?: any;
21
21
  allowedLevels?: any;
22
22
  useRootPoint?: any;
23
+ notificationState?: any;
24
+ handleReCaptcha?: any;
25
+ enableReCaptcha?: any;
23
26
  }
24
27
  export interface ProfileParams {
25
28
  navigation?: any;
@@ -373,6 +376,7 @@ export interface OrderDetailsParams {
373
376
  handleClickLogisticOrder?: (status: number, orderId: number) => void;
374
377
  orderTitle?: any;
375
378
  forceUpdate?: number;
379
+ getPermissions?: any
376
380
  }
377
381
  export interface ProductItemAccordionParams {
378
382
  isCartPending?: boolean;
@@ -578,4 +582,4 @@ export interface ReviewCustomerParams {
578
582
 
579
583
  export interface NoNetworkParams {
580
584
  image?: any;
581
- }
585
+ }
@@ -197,7 +197,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
197
197
  {isFarAway && (
198
198
  <FarAwayMessage style={styles.farAwayMsg}>
199
199
  <Ionicons name='md-warning-outline' style={styles.iconStyle} />
200
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
200
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'Your are far from this address')}</OText>
201
201
  </FarAwayMessage>
202
202
  )}
203
203
  {!auth && (
@@ -410,8 +410,7 @@ const LoginFormUI = (props: LoginParams) => {
410
410
  textInputProps={{
411
411
  returnKeyType: 'next',
412
412
  onSubmitEditing: () => inputRef?.current?.focus?.(),
413
- style: { borderWidth: 0, fontSize: 12 },
414
- maxLength: 10
413
+ style: { borderWidth: 0, fontSize: 12 }
415
414
  }}
416
415
  textWrapStyle={{ borderColor: theme.colors.clear, borderWidth: 0, height: 40, paddingStart: 0 }}
417
416
  />
@@ -155,7 +155,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
155
155
  {isFarAway && (
156
156
  <FarAwayMessage style={styles.farAwayMsg}>
157
157
  <Ionicons name='md-warning-outline' style={styles.iconStyle} />
158
- <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
158
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'Your are far from this address')}</OText>
159
159
  </FarAwayMessage>
160
160
  )}
161
161
  <View style={styles.wrapperOrderOptions}>
@@ -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 > 0 ? ' + ' : ''}`}{fee.percentage > 0 && `${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
+ `
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react';
2
-
2
+ import { _retrieveStoreData } from '../../../../../src/providers/StoreUtil';
3
3
  import {
4
4
  Checkout as CheckoutController,
5
5
  useOrder,
@@ -35,28 +35,40 @@ const CheckoutUI = (props: any) => {
35
35
  } = props
36
36
 
37
37
  const [errorCash, setErrorCash] = useState(false);
38
+ const [customerName, setCustomerName] = useState(null);
39
+
40
+ const getCustomerName = async () => {
41
+ const data = await _retrieveStoreData('customer_name');
42
+ setCustomerName(data?.customerName)
43
+ }
44
+
45
+ useEffect(() => {
46
+ if (!cartState.loading && cart && !cart?.valid && cart?.status === 2) {
47
+ navigation?.canGoBack() && navigation.goBack()
48
+ } else {
49
+ getCustomerName()
50
+ }
51
+ }, [cart])
38
52
 
39
53
  return (
40
54
  <>
41
- {!cartState.loading && cart && cart?.status !== 2 && cart?.valid && (
42
- <PaymentOptions
43
- navigation={navigation}
44
- cart={cart}
45
- errors={errors}
46
- onPaymentChange={handlePaymethodChange}
47
- onNavigationRedirect={onNavigationRedirect}
48
- paySelected={paymethodSelected}
49
- handlerClickPlaceOrder={handlerClickPlaceOrder}
50
- placing={placing}
51
-
52
- errorCash={errorCash}
53
- isDisabled={cart?.status === 2}
54
- businessId={businessDetails?.business?.id}
55
- isLoading={businessDetails.loading}
56
- paymethods={businessDetails?.business?.paymethods}
57
- setErrorCash={setErrorCash}
58
- />
59
- )}
55
+ <PaymentOptions
56
+ navigation={navigation}
57
+ cart={cart}
58
+ errors={errors}
59
+ customerName={customerName}
60
+ onPaymentChange={handlePaymethodChange}
61
+ onNavigationRedirect={onNavigationRedirect}
62
+ paySelected={paymethodSelected}
63
+ handlerClickPlaceOrder={handlerClickPlaceOrder}
64
+ placing={placing}
65
+ errorCash={errorCash}
66
+ isDisabled={cart?.status === 2}
67
+ businessId={businessDetails?.business?.id}
68
+ isLoading={cartState.loading || businessDetails.loading}
69
+ paymethods={businessDetails?.business?.paymethods}
70
+ setErrorCash={setErrorCash}
71
+ />
60
72
  </>
61
73
  )
62
74
  }
@@ -107,7 +119,7 @@ export const Checkout = (props: any) => {
107
119
  loading: false,
108
120
  cart: result
109
121
  })
110
- } catch (error) {
122
+ } catch (error: any) {
111
123
  showToast(ToastType.Error, error?.toString() || error.message)
112
124
  }
113
125
  } else {
@@ -119,7 +131,7 @@ export const Checkout = (props: any) => {
119
131
  error: cart ? null : result
120
132
  })
121
133
  }
122
- } catch (e) {
134
+ } catch (e: any) {
123
135
  setCartState({
124
136
  ...cartState,
125
137
  loading: false,
@@ -113,12 +113,6 @@ const CustomerName = (props: Props): React.ReactElement => {
113
113
  style={{ bottom: 20 }}
114
114
  >
115
115
  {t('WHATS_YOUR_NAME', "What's your name?")}
116
- {/* <OText
117
- size={orientationState?.dimensions?.width * 0.05}
118
- weight={'700'}
119
- >
120
- {`${t('ORDER_BE_FOR', 'order be for?')}`}
121
- </OText> */}
122
116
  </OText>
123
117
  <Controller
124
118
  control={control}
@@ -5,6 +5,7 @@ import { ImageStyle, TextStyle, View, Platform } from 'react-native'
5
5
  import { OrderTypeSelector } from '../OrderTypeSelector'
6
6
  import { useConfig, useLanguage } from 'ordering-components/native'
7
7
  import { useTheme } from 'styled-components/native'
8
+
8
9
  const Wrapper = styled.View`
9
10
  background-color: ${(props: any) => props.theme.colors.white};
10
11
  padding: 10px 0px 20px 0px;
@@ -64,28 +65,27 @@ const NavBar = (props: Props) => {
64
65
 
65
66
  return (
66
67
  <Wrapper style={{ paddingTop: props.paddingTop, ...props.style }}>
67
- {(props?.onActionLeft) && (
68
+ {(props?.onActionLeft || props?.leftImg) && (
68
69
  <OButton
69
- imgLeftSrc={props.leftImg}
70
+ imgLeftSrc={props.leftImg || theme.images.general.arrow_left}
70
71
  imgRightSrc={null}
71
72
  style={{ ...btnBackArrow, ...props.btnStyle }}
72
73
  onClick={props.onActionLeft}
73
- imgLeftStyle={props.imgLeftStyle}
74
- {...(!props.leftImg && { iconProps: { name: 'arrowleft', size: 28, color: props.btnStyle?.color } })}
74
+ imgLeftStyle= {props.imgLeftStyle}
75
75
  />)
76
76
  }
77
77
  <TitleTopWrapper>
78
78
  {props.withIcon
79
79
  ? (
80
- <OIcon
81
- url={props.icon}
82
- style={{
83
- borderColor: theme.colors.lightGray,
84
- borderRadius: 20,
85
- }}
86
- width={60}
87
- height={60}
88
- />
80
+ <OIcon
81
+ url={props.icon}
82
+ style={{
83
+ borderColor: theme.colors.lightGray,
84
+ borderRadius: 20,
85
+ }}
86
+ width={60}
87
+ height={60}
88
+ />
89
89
  )
90
90
  : null
91
91
  }
@@ -125,7 +125,7 @@ const NavBar = (props: Props) => {
125
125
  </View>
126
126
  )}
127
127
 
128
- {props.rightComponent}
128
+ { props.rightComponent }
129
129
  </Wrapper>
130
130
  )
131
131
  }
@@ -95,7 +95,7 @@ interface Props {
95
95
  style?: ViewStyle;
96
96
  bgImage: ImageSourcePropType;
97
97
  innerStyle?: ViewStyle;
98
- icon?: ImageSourcePropType;
98
+ icon: ImageSourcePropType;
99
99
  iconStyle?: ImageStyle;
100
100
  callToActionText: string;
101
101
  callToActionTextStyle?: TextStyle;