ordering-ui-react-native 0.15.90 → 0.15.91-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 (239) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +1 -1
  5. package/src/components/AddressForm/index.tsx +18 -2
  6. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  7. package/src/components/BusinessController/index.tsx +16 -8
  8. package/src/components/BusinessInformation/index.tsx +14 -0
  9. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  10. package/src/components/BusinessesListing/index.tsx +1 -1
  11. package/src/components/Checkout/index.tsx +25 -3
  12. package/src/components/DriverTips/index.tsx +11 -6
  13. package/src/components/LanguageSelector/index.tsx +21 -16
  14. package/src/components/LoginForm/index.tsx +120 -30
  15. package/src/components/LoginForm/styles.tsx +6 -0
  16. package/src/components/Messages/index.tsx +2 -2
  17. package/src/components/NotificationSetting/index.tsx +85 -0
  18. package/src/components/OrderDetails/index.tsx +7 -21
  19. package/src/components/PaymentOptions/index.tsx +335 -365
  20. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  21. package/src/components/ReviewDriver/index.tsx +1 -1
  22. package/src/components/ReviewOrder/index.tsx +2 -1
  23. package/src/components/ReviewProducts/index.tsx +11 -0
  24. package/src/components/SignupForm/index.tsx +145 -61
  25. package/src/components/SingleProductCard/index.tsx +16 -4
  26. package/src/components/SingleProductReview/index.tsx +1 -1
  27. package/src/components/StripeElementsForm/index.tsx +25 -16
  28. package/src/components/StripeMethodForm/index.tsx +22 -24
  29. package/src/components/UpsellingProducts/index.tsx +1 -1
  30. package/src/components/UserProfileForm/index.tsx +63 -6
  31. package/src/components/UserProfileForm/styles.tsx +8 -0
  32. package/src/components/VerifyPhone/styles.tsx +1 -2
  33. package/src/components/shared/OBottomPopup.tsx +6 -2
  34. package/src/components/shared/OModal.tsx +1 -1
  35. package/src/index.tsx +2 -0
  36. package/src/navigators/CheckoutNavigator.tsx +6 -0
  37. package/src/navigators/HomeNavigator.tsx +6 -0
  38. package/src/pages/BusinessesListing.tsx +7 -6
  39. package/src/pages/MultiCheckout.tsx +31 -0
  40. package/src/pages/MultiOrdersDetails.tsx +27 -0
  41. package/src/pages/OrderDetails.tsx +1 -1
  42. package/src/pages/ReviewDriver.tsx +2 -2
  43. package/src/pages/ReviewOrder.tsx +2 -2
  44. package/src/theme.json +0 -1
  45. package/src/types/index.tsx +18 -11
  46. package/src/utils/index.tsx +1 -2
  47. package/themes/business/index.tsx +4 -0
  48. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +1 -1
  49. package/themes/business/src/components/Chat/index.tsx +52 -92
  50. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  51. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  52. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  53. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  54. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  55. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  56. package/themes/business/src/components/MapView/index.tsx +1 -1
  57. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  58. package/themes/business/src/components/NewOrderNotification/index.tsx +24 -13
  59. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  60. package/themes/business/src/components/OrderDetails/Delivery.tsx +17 -7
  61. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +26 -18
  62. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  63. package/themes/business/src/components/OrdersOption/index.tsx +66 -20
  64. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  65. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  66. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  67. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  68. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  69. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  70. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  71. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  72. package/themes/business/src/components/PreviousMessages/index.tsx +1 -0
  73. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  74. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  75. package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
  76. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  77. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  78. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  79. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  80. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  81. package/themes/business/src/components/shared/OModal.tsx +41 -38
  82. package/themes/business/src/types/index.tsx +15 -7
  83. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  84. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  85. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  86. package/themes/kiosk/src/components/BusinessMenu/index.tsx +25 -26
  87. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  88. package/themes/kiosk/src/components/Cart/index.tsx +10 -11
  89. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  90. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  91. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  92. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  93. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  94. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  95. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  96. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  97. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  98. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  99. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  100. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  101. package/themes/kiosk/src/components/PaymentOptions/index.tsx +55 -53
  102. package/themes/kiosk/src/components/ProductForm/index.tsx +6 -7
  103. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  104. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  105. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  106. package/themes/kiosk/src/types/index.d.ts +1 -0
  107. package/themes/original/index.tsx +22 -0
  108. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  109. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  110. package/themes/original/src/components/AddressForm/index.tsx +137 -134
  111. package/themes/original/src/components/AddressList/index.tsx +2 -2
  112. package/themes/original/src/components/AppleLogin/index.tsx +6 -8
  113. package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
  114. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  115. package/themes/original/src/components/BusinessController/index.tsx +179 -96
  116. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  117. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -8
  118. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  119. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  120. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  121. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  122. package/themes/original/src/components/BusinessListingSearch/index.tsx +217 -127
  123. package/themes/original/src/components/BusinessListingSearch/styles.tsx +29 -11
  124. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  125. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  126. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  127. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  128. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  129. package/themes/original/src/components/BusinessProductsList/index.tsx +66 -73
  130. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  131. package/themes/original/src/components/BusinessProductsListing/index.tsx +296 -178
  132. package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -0
  133. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  134. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
  135. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  136. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
  137. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  138. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +673 -0
  139. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  140. package/themes/original/src/components/BusinessesListing/index.tsx +102 -462
  141. package/themes/original/src/components/Cart/index.tsx +82 -37
  142. package/themes/original/src/components/Cart/styles.tsx +4 -0
  143. package/themes/original/src/components/CartContent/index.tsx +22 -16
  144. package/themes/original/src/components/Checkout/index.tsx +141 -93
  145. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  146. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  147. package/themes/original/src/components/Favorite/index.tsx +92 -0
  148. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  149. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  150. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  151. package/themes/original/src/components/GPSButton/index.tsx +25 -17
  152. package/themes/original/src/components/GoogleMap/index.tsx +21 -12
  153. package/themes/original/src/components/Help/index.tsx +21 -4
  154. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
  155. package/themes/original/src/components/HelpGuide/index.tsx +8 -3
  156. package/themes/original/src/components/HelpOrder/index.tsx +8 -3
  157. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  158. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  159. package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -3
  160. package/themes/original/src/components/LoginForm/index.tsx +52 -13
  161. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  162. package/themes/original/src/components/Messages/index.tsx +17 -17
  163. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  164. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  165. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  166. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  167. package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
  168. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  169. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  170. package/themes/original/src/components/MultiOrdersDetails/index.tsx +262 -0
  171. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  172. package/themes/original/src/components/MyOrders/index.tsx +132 -27
  173. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  174. package/themes/original/src/components/NavBar/index.tsx +11 -5
  175. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  176. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  177. package/themes/original/src/components/OrderDetails/index.tsx +154 -77
  178. package/themes/original/src/components/OrderDetails/styles.tsx +5 -2
  179. package/themes/original/src/components/OrderItAgain/index.tsx +73 -0
  180. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  181. package/themes/original/src/components/OrderProgress/index.tsx +8 -2
  182. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  183. package/themes/original/src/components/OrderTypeSelector/index.tsx +84 -36
  184. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  185. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +140 -0
  186. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  187. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  188. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  189. package/themes/original/src/components/OrdersOption/index.tsx +138 -46
  190. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  191. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  192. package/themes/original/src/components/PaymentOptionWallet/index.tsx +15 -22
  193. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  194. package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
  195. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  196. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  197. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  198. package/themes/original/src/components/ProductForm/index.tsx +737 -682
  199. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  200. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  201. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  202. package/themes/original/src/components/ProductOptionSubOption/index.tsx +13 -9
  203. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  204. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  205. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  206. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  207. package/themes/original/src/components/Promotions/index.tsx +22 -6
  208. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  209. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  210. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  211. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  212. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  213. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  214. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  215. package/themes/original/src/components/SignupForm/index.tsx +237 -127
  216. package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
  217. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  218. package/themes/original/src/components/SingleProductCard/index.tsx +204 -95
  219. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  220. package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
  221. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  222. package/themes/original/src/components/UpsellingProducts/index.tsx +7 -3
  223. package/themes/original/src/components/UserDetails/index.tsx +32 -18
  224. package/themes/original/src/components/UserFormDetails/index.tsx +108 -74
  225. package/themes/original/src/components/UserProfile/index.tsx +4 -0
  226. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  227. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  228. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  229. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  230. package/themes/original/src/components/Wallets/index.tsx +176 -162
  231. package/themes/original/src/components/Wallets/styles.tsx +10 -8
  232. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  233. package/themes/original/src/components/shared/OButton.tsx +10 -3
  234. package/themes/original/src/components/shared/OInput.tsx +3 -2
  235. package/themes/original/src/components/shared/OModal.tsx +4 -2
  236. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  237. package/themes/original/src/types/index.tsx +200 -48
  238. package/themes/original/src/utils/index.tsx +77 -0
  239. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -48,22 +48,28 @@ const DriverTipsUI = (props: any) => {
48
48
  }
49
49
  })
50
50
 
51
- const [value, setvalue] = useState(0);
51
+ const [value, setvalue] = useState('');
52
52
 
53
53
  const placeholderCurrency = (configs?.currency_position?.value || 'left') === 'left'
54
54
  ? `${configs?.format_number_currency?.value}0`
55
55
  : `0${configs?.format_number_currency?.value}`
56
56
 
57
57
  const handleChangeDriverTip = (val: any) => {
58
- let tip = parseFloat(val)
59
- tip = isNaN(tip) ? 0 : tip
60
- setvalue(tip)
58
+ const tip = Number(val)
59
+ if ((isNaN(tip) || tip < 0)) {
60
+ setvalue(value)
61
+ return
62
+ }
63
+ setvalue(val)
61
64
  }
62
-
65
+
63
66
  return (
64
67
  <DTContainer>
68
+ <DTLabel>
69
+ {t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
70
+ </DTLabel>
65
71
  <DTWrapperTips>
66
- {driverTipsOptions.map((option: any, i: number) => (
72
+ {!isDriverTipUseCustom && driverTipsOptions.map((option: any, i: number) => (
67
73
  <TouchableOpacity
68
74
  key={i}
69
75
  onPress={() => handlerChangeOption(option)}
@@ -79,7 +85,7 @@ const DriverTipsUI = (props: any) => {
79
85
  </TouchableOpacity>
80
86
  ))}
81
87
  </DTWrapperTips>
82
- {!driverTipsOptions.includes(driverTip) && driverTip > 0 && (
88
+ {(!isDriverTipUseCustom && !driverTipsOptions.includes(driverTip) && driverTip > 0) && (
83
89
  <OText
84
90
  color={theme.colors.error}
85
91
  size={16}
@@ -90,13 +96,12 @@ const DriverTipsUI = (props: any) => {
90
96
  )}
91
97
  {isDriverTipUseCustom && (
92
98
  <DTForm>
93
- <DTLabel>
94
- {t('CUSTOM_DRIVER_TIP_MESSAGE', '100% of these tips go directly to your driver')}
95
- </DTLabel>
96
99
  <DTWrapperInput>
97
100
  <OInput
98
101
  placeholder={placeholderCurrency}
99
102
  style={style.inputStyle}
103
+ value={value}
104
+ type={'numeric'}
100
105
  onChange={handleChangeDriverTip}
101
106
  autoCapitalize='none'
102
107
  autoCorrect={false}
@@ -108,10 +113,10 @@ const DriverTipsUI = (props: any) => {
108
113
  textStyle={{ color: 'white', fontSize: 14 }}
109
114
  imgRightSrc={null}
110
115
  style={{ borderRadius: 5, height: 44 }}
111
- isDisabled={!(value > 0 && value !== driverTip) || !value}
116
+ isDisabled={parseFloat(value || '0') < 0 || parseFloat(value || '0') === driverTip || value === ''}
112
117
  onClick={() => {
113
118
  handlerChangeOption(value)
114
- setvalue(0)
119
+ setvalue('')
115
120
  }}
116
121
  />
117
122
  </DTWrapperInput>
@@ -0,0 +1,92 @@
1
+ import React, { useState } from 'react'
2
+ import { useLanguage, useOrder } from 'ordering-components/native'
3
+ import { useTheme } from 'styled-components/native'
4
+ import { FavoriteList } from '../FavoriteList'
5
+ import NavBar from '../NavBar'
6
+ import { OText } from '../shared'
7
+
8
+ import {
9
+ TabContainer,
10
+ Tab,
11
+ Container
12
+ } from './styles'
13
+
14
+ export const Favorite = (props: any) => {
15
+ const {
16
+ navigation
17
+ } = props
18
+ const [, t] = useLanguage()
19
+ const theme = useTheme()
20
+ const [orderState] = useOrder()
21
+ const [tabSelected, setTabSelected] = useState('businesses')
22
+
23
+ const tabList = [
24
+ { key: 'businesses', name: t('BUSINESSES', 'Businesses') },
25
+ { key: 'products', name: t('PRODUCTS', 'Products') },
26
+ { key: 'orders', name: t('ORDERS', 'Orders') }
27
+ ]
28
+
29
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
30
+
31
+ const onRedirect = (route: string, params?: any) => {
32
+ navigation.navigate(route, params)
33
+ }
34
+
35
+ return (
36
+ <Container>
37
+ <NavBar
38
+ title={t('FAVORITE', 'Favorite')}
39
+ titleAlign={'center'}
40
+ onActionLeft={goToBack}
41
+ showCall={false}
42
+ paddingTop={10}
43
+ btnStyle={{ paddingLeft: 0 }}
44
+ />
45
+ <TabContainer>
46
+ {tabList.map((menu, i) => (
47
+ <Tab
48
+ key={i}
49
+ active={menu.key === tabSelected}
50
+ onPress={() => setTabSelected(menu.key)}
51
+ >
52
+ <OText
53
+ color={menu.key === tabSelected ? theme.colors.textNormal : theme.colors.disabled}
54
+ size={14}
55
+ weight={menu.key === tabSelected ? '500' : '400'}
56
+ style={{ marginBottom: 12 }}
57
+ >
58
+ {menu.name}
59
+ </OText>
60
+ </Tab>
61
+ ))}
62
+ </TabContainer>
63
+ {tabSelected === 'businesses' && (
64
+ <FavoriteList
65
+ navigation={navigation}
66
+ onNavigationRedirect={onRedirect}
67
+ isBusiness
68
+ favoriteURL='favorite_businesses'
69
+ originalURL='business'
70
+ location={`${orderState.options?.address?.location?.lat},${orderState.options?.address?.location?.lng}`}
71
+ propsToFetch={['id', 'name', 'header', 'logo', 'location', 'address', 'ribbon', 'timezone', 'schedule', 'open', 'delivery_price', 'distance', 'delivery_time', 'pickup_time', 'reviews', 'featured', 'offers', 'food', 'laundry', 'alcohol', 'groceries', 'slug']}
72
+ />
73
+ )}
74
+ {tabSelected === 'products' && (
75
+ <FavoriteList
76
+ favoriteURL='favorite_products'
77
+ originalURL='products'
78
+ onNavigationRedirect={onRedirect}
79
+ isProduct
80
+ />
81
+ )}
82
+ {tabSelected === 'orders' && (
83
+ <FavoriteList
84
+ onNavigationRedirect={onRedirect}
85
+ favoriteURL='favorite_orders'
86
+ originalURL='orders'
87
+ isOrder
88
+ />
89
+ )}
90
+ </Container>
91
+ )
92
+ }
@@ -0,0 +1,22 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const TabContainer = styled.View`
4
+ flex-direction: row;
5
+ border-bottom-color: ${(props: any) => props.theme.colors.border};
6
+ border-bottom-width: 1px;
7
+ margin-bottom: 25px;
8
+ `
9
+
10
+ export const Tab = styled.TouchableOpacity`
11
+ margin-right: 32px;
12
+ ${(props: any) => props.active && css`
13
+ border-bottom-color: ${(props: any) => props.theme.colors.textNormal};
14
+ border-bottom-width: 1px;
15
+ `}
16
+ `
17
+
18
+ export const Container = styled.View`
19
+ padding-horizontal: 40px;
20
+ padding-bottom: 20px;
21
+ padding-top: 30px;
22
+ `
@@ -0,0 +1,298 @@
1
+ import React, { useEffect } from 'react';
2
+ import { View } from 'react-native';
3
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
4
+ import { FavoriteParams } from '../../types';
5
+ import { SingleOrderCard } from '../SingleOrderCard';
6
+ import {
7
+ FavoriteList as FavoriteListController,
8
+ useOrder,
9
+ useLanguage
10
+ } from 'ordering-components/native';
11
+ import { useTheme } from 'styled-components/native';
12
+ import { _setStoreData } from '../../providers/StoreUtil';
13
+ import { Container, WrappButton } from './styles'
14
+ import { OButton } from '../shared';
15
+ import { BusinessController } from '../BusinessController';
16
+ import { SingleProductCard } from '../SingleProductCard';
17
+ import moment from 'moment';
18
+
19
+
20
+ const FavoriteListUI = (props: FavoriteParams) => {
21
+ const {
22
+ favoriteList,
23
+ handleUpdateFavoriteList,
24
+ pagination,
25
+ getFavoriteList,
26
+ navigation,
27
+ onNavigationRedirect,
28
+ reorderState,
29
+ handleReorder,
30
+ isBusiness,
31
+ isOrder,
32
+ isProduct
33
+ } = props
34
+
35
+ const theme = useTheme();
36
+ const [, t] = useLanguage()
37
+ const [orderState] = useOrder();
38
+ const [{ carts }] = useOrder()
39
+
40
+ const pastOrders = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
41
+
42
+ const getOrderStatus = (s: any) => {
43
+ const status = parseInt(s)
44
+ const orderStatus = [
45
+ { key: 0, value: t('PENDING', theme?.defaultLanguages?.PENDING || 'Pending') },
46
+ { key: 1, value: t('COMPLETED', theme?.defaultLanguages?.COMPLETED || 'Completed') },
47
+ { key: 2, value: t('REJECTED', theme?.defaultLanguages?.REJECTED || 'Rejected') },
48
+ { key: 3, value: t('DRIVER_IN_BUSINESS', theme?.defaultLanguages?.DRIVER_IN_BUSINESS || 'Driver in business') },
49
+ { key: 4, value: t('PREPARATION_COMPLETED', theme?.defaultLanguages?.PREPARATION_COMPLETED || 'Preparation Completed') },
50
+ { key: 5, value: t('REJECTED_BY_BUSINESS', theme?.defaultLanguages?.REJECTED_BY_BUSINESS || 'Rejected by business') },
51
+ { key: 6, value: t('REJECTED_BY_DRIVER', theme?.defaultLanguages?.REJECTED_BY_DRIVER || 'Rejected by Driver') },
52
+ { key: 7, value: t('ACCEPTED_BY_BUSINESS', theme?.defaultLanguages?.ACCEPTED_BY_BUSINESS || 'Accepted by business') },
53
+ { key: 8, value: t('ACCEPTED_BY_DRIVER', theme?.defaultLanguages?.ACCEPTED_BY_DRIVER || 'Accepted by driver') },
54
+ { key: 9, value: t('PICK_UP_COMPLETED_BY_DRIVER', theme?.defaultLanguages?.PICK_UP_COMPLETED_BY_DRIVER || 'Pick up completed by driver') },
55
+ { key: 10, value: t('PICK_UP_FAILED_BY_DRIVER', theme?.defaultLanguages?.PICK_UP_FAILED_BY_DRIVER || 'Pick up Failed by driver') },
56
+ { key: 11, value: t('DELIVERY_COMPLETED_BY_DRIVER', theme?.defaultLanguages?.DELIVERY_COMPLETED_BY_DRIVER || 'Delivery completed by driver') },
57
+ { key: 12, value: t('DELIVERY_FAILED_BY_DRIVER', theme?.defaultLanguages?.DELIVERY_FAILED_BY_DRIVER || 'Delivery Failed by driver') },
58
+ { key: 13, value: t('PREORDER', theme?.defaultLanguages?.PREORDER || 'PreOrder') },
59
+ { key: 14, value: t('ORDER_NOT_READY', theme?.defaultLanguages?.ORDER_NOT_READY || 'Order not ready') },
60
+ { key: 15, value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER || 'Order picked up completed by customer') },
61
+ { key: 16, value: t('ORDER_STATUS_CANCELLED_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_STATUS_CANCELLED_BY_CUSTOMER || 'Order cancelled by customer') },
62
+ { key: 17, value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_NOT_PICKEDUP_BY_CUSTOMER || 'Order not picked up by customer') },
63
+ { key: 18, value: t('ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS || 'Driver almost arrived to business') },
64
+ { key: 19, value: t('ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER', theme?.defaultLanguages?.ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER || 'Driver almost arrived to customer') },
65
+ { key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS || 'Customer almost arrived to business') },
66
+ { key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ARRIVED_BUSINESS || 'Customer arrived to business') },
67
+ { key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', theme?.defaultLanguages?.ORDER_LOOKING_FOR_DRIVER || 'Looking for driver') },
68
+ { key: 23, value: t('ORDER_DRIVER_ON_WAY', theme?.defaultLanguages?.ORDER_DRIVER_ON_WAY || 'Driver on way') }
69
+ ]
70
+
71
+ const objectStatus = orderStatus.find((o) => o.key === status)
72
+
73
+ return objectStatus && objectStatus
74
+ }
75
+
76
+ const onProductClick = (product: any) => {
77
+ const categoryId = product?.category?.id
78
+ const businessId = product?.category?.business?.id
79
+ if (!categoryId || !businessId) return
80
+ onNavigationRedirect && onNavigationRedirect('ProductDetails', {
81
+ productId: product?.id,
82
+ categoryId: categoryId,
83
+ businessId: businessId
84
+ })
85
+ }
86
+
87
+ useEffect(() => {
88
+ const _businessId = 'businessId:' + reorderState?.result?.business_id
89
+ if (reorderState?.error) {
90
+ if (reorderState?.result?.business_id) {
91
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
92
+ onNavigationRedirect && onNavigationRedirect('Business', { store: reorderState?.result?.business?.slug })
93
+ }
94
+ }
95
+ if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
96
+ const cartProducts = carts?.[_businessId]?.products
97
+ const available = cartProducts.every((product: any) => product.valid === true)
98
+ const orderProducts = favoriteList?.favorites.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
99
+
100
+ if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
101
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
102
+ } else {
103
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
104
+ cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
105
+ onNavigationRedirect && onNavigationRedirect('Business', { store: reorderState?.result?.business?.slug })
106
+ }
107
+ }
108
+ }, [reorderState])
109
+
110
+ const handleBusinessClick = (business: any) => {
111
+ onNavigationRedirect && onNavigationRedirect('Business', {
112
+ store: business.slug,
113
+ header: business.header,
114
+ logo: business.logo,
115
+ });
116
+ }
117
+
118
+ const BusinessSkeleton = () => {
119
+ return (
120
+ <Placeholder
121
+ Animation={Fade}
122
+ style={{ marginBottom: 20 }}>
123
+ <View style={{ width: '100%' }}>
124
+ <PlaceholderLine
125
+ height={200}
126
+ style={{ marginBottom: 20, borderRadius: 25 }}
127
+ />
128
+ <View style={{ paddingHorizontal: 10 }}>
129
+ <View
130
+ style={{
131
+ flexDirection: 'row',
132
+ justifyContent: 'space-between',
133
+ }}>
134
+ <PlaceholderLine
135
+ height={25}
136
+ width={40}
137
+ style={{ marginBottom: 10 }}
138
+ />
139
+ <PlaceholderLine
140
+ height={25}
141
+ width={20}
142
+ style={{ marginBottom: 10 }}
143
+ />
144
+ </View>
145
+ <PlaceholderLine
146
+ height={20}
147
+ width={30}
148
+ style={{ marginBottom: 10 }}
149
+ />
150
+ <PlaceholderLine
151
+ height={20}
152
+ width={80}
153
+ style={{ marginBottom: 10 }}
154
+ />
155
+ </View>
156
+ </View>
157
+ </Placeholder>
158
+ )
159
+ }
160
+
161
+ const ProductSkeleton = () => {
162
+ return (
163
+ <Placeholder style={{ padding: 5 }} Animation={Fade}>
164
+ <View style={{ flexDirection: 'row' }}>
165
+ <PlaceholderLine
166
+ width={24}
167
+ height={70}
168
+ style={{ marginRight: 10, marginBottom: 10 }}
169
+ />
170
+ <Placeholder style={{ paddingVertical: 10 }}>
171
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
172
+ <PlaceholderLine width={20} />
173
+ </Placeholder>
174
+ </View>
175
+ </Placeholder>
176
+ )
177
+ }
178
+
179
+ const OrderSkeleton = () => {
180
+ return (
181
+ <Placeholder style={{ padding: 5 }} Animation={Fade}>
182
+ <View style={{ flexDirection: 'row' }}>
183
+ <PlaceholderLine
184
+ width={24}
185
+ height={70}
186
+ style={{ marginRight: 10, marginBottom: 10 }}
187
+ />
188
+ <Placeholder style={{ paddingVertical: 10 }}>
189
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
190
+ <PlaceholderLine width={20} />
191
+ </Placeholder>
192
+ </View>
193
+ </Placeholder>
194
+ )
195
+ }
196
+
197
+ return (
198
+ <Container>
199
+ {isBusiness && (
200
+ <>
201
+ {favoriteList?.favorites?.length > 0 && (
202
+ favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((business: any, i:number) => (
203
+ <BusinessController
204
+ key={`${business.id}_` + i}
205
+ business={business}
206
+ isBusinessOpen={business.open}
207
+ handleCustomClick={handleBusinessClick}
208
+ orderType={orderState?.options?.type}
209
+ navigation={navigation}
210
+ businessHeader={business?.header}
211
+ businessFeatured={business?.featured}
212
+ businessLogo={business?.logo}
213
+ businessReviews={business?.reviews}
214
+ businessDeliveryPrice={business?.delivery_price}
215
+ businessDeliveryTime={business?.delivery_time}
216
+ businessPickupTime={business?.pickup_time}
217
+ businessDistance={business?.distance}
218
+ handleUpdateBusinessList={handleUpdateFavoriteList}
219
+ />
220
+ ))
221
+ )}
222
+ {favoriteList?.loading && (
223
+ [...Array(5).keys()].map(i => (
224
+ <BusinessSkeleton key={i} />
225
+ ))
226
+ )}
227
+ </>
228
+ )}
229
+
230
+ {isOrder && (
231
+ <>
232
+ {favoriteList?.favorites?.length > 0 && (
233
+ favoriteList.favorites?.sort((a: any, b:any) => moment(a?.delivery_datetime_utc).valueOf() - moment(b?.delivery_datetime_utc).valueOf())
234
+ .map((order: any, i: number) => (
235
+ <SingleOrderCard
236
+ key={`${order?.id}_${i}`}
237
+ order={order}
238
+ getOrderStatus={getOrderStatus}
239
+ onNavigationRedirect={onNavigationRedirect}
240
+ pastOrders={pastOrders.includes(order?.status)}
241
+ handleUpdateOrderList={handleUpdateFavoriteList}
242
+ handleUpdateFavoriteList={handleUpdateFavoriteList}
243
+ handleReorder={handleReorder}
244
+ reorderLoading={reorderState?.loading}
245
+ />
246
+ ))
247
+ )}
248
+ {favoriteList?.loading && (
249
+ [...Array(5).keys()].map(i => (
250
+ <OrderSkeleton key={i} />
251
+ ))
252
+ )}
253
+ </>
254
+ )}
255
+
256
+ {isProduct && (
257
+ <>
258
+ {favoriteList?.favorites?.length > 0 && (
259
+ favoriteList.favorites?.sort((a: any, b: any) => a?.name?.toLowerCase() > b?.name?.toLowerCase()).map((product: any, i: number) => (
260
+ <SingleProductCard
261
+ key={`${product?.id}_${i}`}
262
+ isSoldOut={product?.inventoried && !product?.quantity}
263
+ product={product}
264
+ onProductClick={onProductClick}
265
+ handleUpdateProducts={handleUpdateFavoriteList}
266
+ />
267
+ ))
268
+ )}
269
+ {favoriteList?.loading && (
270
+ [...Array(5).keys()].map(i => (
271
+ <ProductSkeleton key={i} />
272
+ ))
273
+ )}
274
+ </>
275
+ )}
276
+
277
+ {!favoriteList?.loading && pagination.totalPages && pagination.currentPage < pagination.totalPages && (
278
+ <WrappButton>
279
+ <OButton
280
+ onClick={() => getFavoriteList(pagination?.currentPage + 1)}
281
+ text={t('LOAD_MORE_ITEMS', 'Load more items')}
282
+ imgRightSrc={null}
283
+ textStyle={{ color: theme.colors.white }}
284
+ style={{ borderRadius: 7.6, shadowOpacity: 0, marginTop: 20 }}
285
+ />
286
+ </WrappButton>
287
+ )}
288
+ </Container>
289
+ )
290
+ }
291
+
292
+ export const FavoriteList = (props: any) => {
293
+ const favoriteBusinessesProps = {
294
+ ...props,
295
+ UIComponent: FavoriteListUI
296
+ }
297
+ return <FavoriteListController {...favoriteBusinessesProps} />
298
+ }
@@ -0,0 +1,5 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View``
4
+
5
+ export const WrappButton = styled.View``
@@ -1,16 +1,16 @@
1
1
  import React, { useEffect, useState } from 'react'
2
- import Geolocation from '@react-native-community/geolocation'
3
2
  import Geocoder from 'react-native-geocoding'
4
- import { GpsButtonStyle } from './styles'
5
- import { View } from 'react-native'
6
- import { OText } from '../shared'
7
3
  import { ActivityIndicator } from 'react-native-paper'
4
+ import Geolocation from '@react-native-community/geolocation'
5
+ import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
6
+
7
+ import { OText } from '../shared'
8
+ import { GpsButtonStyle } from './styles'
8
9
 
9
10
  export const GPSButton = (props: any) => {
10
11
  const {
11
12
  handleGPS,
12
13
  apiKey,
13
- googleReady,
14
14
  IconButton,
15
15
  IconLoadingButton
16
16
  } = props
@@ -55,19 +55,27 @@ export const GPSButton = (props: any) => {
55
55
  })
56
56
  }
57
57
 
58
- const getCurrentPosition = () => {
59
- setLoading(true);
60
- Geolocation.getCurrentPosition((pos) => {
61
- geoCodePosition(pos.coords);
62
- }, (err) => {
63
- setLoading(false);
64
- console.log(err);
65
- });
66
- }
58
+ const getCurrentPosition = async () => {
59
+ let trackingStatus = await getTrackingStatus()
60
+ if (trackingStatus === 'not-determined') {
61
+ trackingStatus = await requestTrackingPermission()
62
+ }
63
+ if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
64
+ setLoading(true)
65
+ Geolocation.getCurrentPosition((pos) => {
66
+ geoCodePosition(pos.coords)
67
+ }, (err) => {
68
+ setLoading(false);
69
+ console.log(`ERROR(${err.code}): ${err.message}`)
70
+ }, {
71
+ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
72
+ })
73
+ }
74
+ }
67
75
 
68
- useEffect(() => {
69
- Geocoder.init(apiKey);
70
- }, [])
76
+ useEffect(() => {
77
+ Geocoder.init(apiKey);
78
+ }, [])
71
79
 
72
80
  return (
73
81
  <GpsButtonStyle
@@ -32,6 +32,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
32
32
  latitudeDelta: 0.0010,
33
33
  longitudeDelta: 0.0010 * ASPECT_RATIO
34
34
  })
35
+ const [MARKERS, SETMARKERS] = useState(locations)
35
36
  let mapRef = useRef<any>(null)
36
37
  const googleMapsApiKey = configState?.configs?.google_maps_api_key?.value
37
38
 
@@ -41,12 +42,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
41
42
  ERROR_NOT_FOUND_ADDRESS: 'Sorry, we couldn\'t find an address',
42
43
  ERROR_MAX_LIMIT_LOCATION: `Sorry, You can only set the position to ${maxLimitLocation}m`
43
44
  }
44
- const MARKERS = locations && locations.map((location: { lat: number, lng: number }) => {
45
- return {
46
- latitude: location.lat,
47
- longitude: location.lng
48
- }
49
- })
45
+
50
46
  const geocodePosition = (pos: { latitude: number, longitude: number }) => {
51
47
  Geocoder.from({
52
48
  latitude: pos.latitude,
@@ -93,7 +89,9 @@ export const GoogleMap = (props: GoogleMapsParams) => {
93
89
  return
94
90
  }
95
91
 
96
- if (distance <= maxLimitLocation) {
92
+ const _maxLimitLocation = typeof maxLimitLocation === 'string' ? parseInt(maxLimitLocation, 10) : maxLimitLocation
93
+
94
+ if (distance <= _maxLimitLocation) {
97
95
  setMarkerPosition(curPos)
98
96
  setRegion({ ...region, longitude: curPos.longitude, latitude: curPos.latitude })
99
97
  } else {
@@ -147,7 +145,7 @@ export const GoogleMap = (props: GoogleMapsParams) => {
147
145
  }
148
146
 
149
147
  const fitAllMarkers = () => {
150
- mapRef.current.fitToCoordinates(MARKERS, {
148
+ mapRef.current.fitToCoordinates(MARKERS?.map(location => ({ latitude: location.lat, longitude: location.lng })), {
151
149
  edgePadding: { top: 80, right: 80, bottom: 80, left: 80 },
152
150
  animated: true,
153
151
  });
@@ -157,6 +155,13 @@ export const GoogleMap = (props: GoogleMapsParams) => {
157
155
  Geocoder.init(googleMapsApiKey)
158
156
  }, [])
159
157
 
158
+ useEffect(() => {
159
+ mapRef.current.animateToRegion({
160
+ ...region,
161
+ latitude: location?.lat,
162
+ longitude: location?.lng,
163
+ })
164
+ }, [location])
160
165
 
161
166
  useEffect(() => {
162
167
  if (saveLocation) {
@@ -170,6 +175,9 @@ export const GoogleMap = (props: GoogleMapsParams) => {
170
175
  fitAllMarkers()
171
176
  }
172
177
  }, 1000)
178
+ if (locations) {
179
+ SETMARKERS(locations)
180
+ }
173
181
  return () => clearInterval(interval)
174
182
  }, [locations])
175
183
 
@@ -189,15 +197,16 @@ export const GoogleMap = (props: GoogleMapsParams) => {
189
197
  >
190
198
  {locations ? (
191
199
  <>
192
- {MARKERS && MARKERS.map((location: { latitude: number, longitude: number }, i: number) => (
200
+ {MARKERS && MARKERS.map((location: { lat: number, lng: number }, i: number) => (
193
201
  <React.Fragment key={i}>
194
202
  {
195
203
  <Marker
196
- coordinate={location}
197
- title={locations[i]?.title}
204
+ zIndex={i}
205
+ coordinate={{ latitude: location.lat ?? 0, longitude: location.lng ?? 0 }}
206
+ title={MARKERS[i]?.title}
198
207
  >
199
208
  <View>
200
- <OIcon url={locations[i].icon} width={50} height={50} />
209
+ <OIcon url={MARKERS[i].icon} width={50} height={50} />
201
210
  </View>
202
211
  </Marker>
203
212
  }