ordering-ui-react-native 0.15.63 → 0.15.64-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 (213) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  5. package/src/components/BusinessController/index.tsx +16 -8
  6. package/src/components/BusinessInformation/index.tsx +14 -0
  7. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  8. package/src/components/BusinessesListing/index.tsx +1 -1
  9. package/src/components/Checkout/index.tsx +23 -2
  10. package/src/components/DriverTips/index.tsx +11 -6
  11. package/src/components/LanguageSelector/index.tsx +6 -2
  12. package/src/components/LoginForm/index.tsx +120 -30
  13. package/src/components/LoginForm/styles.tsx +6 -0
  14. package/src/components/OrderDetails/index.tsx +7 -21
  15. package/src/components/PaymentOptions/index.tsx +67 -50
  16. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  17. package/src/components/ReviewDriver/index.tsx +1 -1
  18. package/src/components/ReviewOrder/index.tsx +2 -1
  19. package/src/components/ReviewProducts/index.tsx +11 -0
  20. package/src/components/SignupForm/index.tsx +145 -61
  21. package/src/components/SingleProductCard/index.tsx +16 -4
  22. package/src/components/SingleProductReview/index.tsx +1 -1
  23. package/src/components/StripeMethodForm/index.tsx +22 -24
  24. package/src/components/UpsellingProducts/index.tsx +1 -1
  25. package/src/components/UserProfileForm/index.tsx +63 -6
  26. package/src/components/UserProfileForm/styles.tsx +8 -0
  27. package/src/components/VerifyPhone/styles.tsx +1 -2
  28. package/src/components/shared/OModal.tsx +1 -1
  29. package/src/hooks/useCountdownTimer.tsx +26 -0
  30. package/src/navigators/CheckoutNavigator.tsx +6 -0
  31. package/src/navigators/HomeNavigator.tsx +12 -0
  32. package/src/pages/BusinessesListing.tsx +7 -6
  33. package/src/pages/MultiCheckout.tsx +31 -0
  34. package/src/pages/MultiOrdersDetails.tsx +27 -0
  35. package/src/pages/OrderDetails.tsx +1 -1
  36. package/src/pages/ReviewDriver.tsx +2 -2
  37. package/src/pages/ReviewOrder.tsx +2 -2
  38. package/src/pages/Sessions.tsx +22 -0
  39. package/src/theme.json +0 -1
  40. package/src/types/index.tsx +18 -11
  41. package/src/utils/index.tsx +68 -1
  42. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  43. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  44. package/themes/business/src/components/Chat/index.tsx +42 -90
  45. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  46. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  47. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  48. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  49. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  50. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  51. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  52. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +14 -7
  53. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  54. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  55. package/themes/business/src/components/OrdersOption/index.tsx +8 -4
  56. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  57. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  58. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  59. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  60. package/themes/business/src/components/shared/OModal.tsx +1 -1
  61. package/themes/business/src/types/index.tsx +8 -2
  62. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  63. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  64. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  65. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  66. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  67. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  68. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  69. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  70. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  71. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  72. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  73. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  74. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  75. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  76. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  77. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  78. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  79. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  80. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  81. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  82. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  83. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  84. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  85. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  86. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  87. package/themes/kiosk/src/types/index.d.ts +1 -0
  88. package/themes/original/index.tsx +30 -8
  89. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  90. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  91. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  92. package/themes/original/src/components/AddressList/index.tsx +30 -18
  93. package/themes/original/src/components/AppleLogin/index.tsx +6 -8
  94. package/themes/original/src/components/BusinessBasicInformation/index.tsx +305 -159
  95. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  96. package/themes/original/src/components/BusinessController/index.tsx +168 -96
  97. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  98. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  99. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  100. package/themes/original/src/components/BusinessListingSearch/index.tsx +231 -63
  101. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  102. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  103. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  104. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  105. package/themes/original/src/components/BusinessProductsList/index.tsx +51 -52
  106. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  107. package/themes/original/src/components/BusinessProductsListing/index.tsx +317 -155
  108. package/themes/original/src/components/BusinessProductsListing/styles.tsx +32 -0
  109. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  110. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -39
  111. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  112. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +560 -0
  113. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  114. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +679 -0
  115. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  116. package/themes/original/src/components/BusinessesListing/index.tsx +99 -458
  117. package/themes/original/src/components/Cart/index.tsx +61 -42
  118. package/themes/original/src/components/Checkout/index.tsx +90 -39
  119. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  120. package/themes/original/src/components/Favorite/index.tsx +92 -0
  121. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  122. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  123. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  124. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  125. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  126. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  127. package/themes/original/src/components/Help/index.tsx +21 -4
  128. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  129. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  130. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  131. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  132. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  133. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  134. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  135. package/themes/original/src/components/Messages/index.tsx +1 -1
  136. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  137. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  138. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  139. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  140. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  141. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  142. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  143. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  144. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  145. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  146. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  147. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  148. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  149. package/themes/original/src/components/NavBar/index.tsx +4 -4
  150. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  151. package/themes/original/src/components/OrderDetails/index.tsx +150 -64
  152. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  153. package/themes/original/src/components/OrderSummary/index.tsx +6 -6
  154. package/themes/original/src/components/OrderTypeSelector/index.tsx +79 -35
  155. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  156. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  157. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  158. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  159. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  160. package/themes/original/src/components/OrdersOption/index.tsx +137 -38
  161. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  162. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  163. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  164. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  165. package/themes/original/src/components/PaymentOptions/index.tsx +58 -37
  166. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  167. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  168. package/themes/original/src/components/ProductForm/index.tsx +718 -679
  169. package/themes/original/src/components/ProductForm/styles.tsx +6 -2
  170. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  171. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  172. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  173. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  174. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  175. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  176. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  177. package/themes/original/src/components/Promotions/index.tsx +151 -133
  178. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  179. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  180. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  181. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  182. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  183. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  184. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  185. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  186. package/themes/original/src/components/Sessions/index.tsx +160 -0
  187. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  188. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  189. package/themes/original/src/components/SingleOrderCard/index.tsx +275 -0
  190. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  191. package/themes/original/src/components/SingleProductCard/index.tsx +161 -88
  192. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  193. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  194. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  195. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  196. package/themes/original/src/components/UserDetails/index.tsx +15 -81
  197. package/themes/original/src/components/UserFormDetails/index.tsx +98 -66
  198. package/themes/original/src/components/UserProfile/index.tsx +11 -2
  199. package/themes/original/src/components/UserProfileForm/index.tsx +33 -22
  200. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  201. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  202. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  203. package/themes/original/src/components/Wallets/index.tsx +76 -9
  204. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  205. package/themes/original/src/components/shared/OBottomPopup.tsx +44 -13
  206. package/themes/original/src/components/shared/OButton.tsx +2 -0
  207. package/themes/original/src/components/shared/OInput.tsx +3 -2
  208. package/themes/original/src/components/shared/OModal.tsx +4 -2
  209. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  210. package/themes/original/src/types/index.tsx +187 -35
  211. package/themes/original/src/utils/index.tsx +96 -2
  212. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  213. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -0,0 +1,153 @@
1
+ import React, { useEffect } from 'react'
2
+ import { BusinessList as BusinessListController, useOrder } from 'ordering-components/native'
3
+ import { BusinessController } from '../../BusinessController'
4
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
5
+
6
+ import { ListWrapper } from './styles'
7
+ import {
8
+ View,
9
+ StyleSheet,
10
+ ScrollView,
11
+ Dimensions
12
+ } from 'react-native';
13
+ import { PreviousBusinessOrderedParams } from '../../../types';
14
+
15
+ export const PreviousBusinessOrderedUI = (props: PreviousBusinessOrderedParams) => {
16
+ const {
17
+ navigation,
18
+ businessesList,
19
+ setBusinessLoading,
20
+ businessId,
21
+ onNavigationRedirect,
22
+ isBusinessesSearchList,
23
+ businessLoading
24
+ } = props
25
+
26
+ const [orderState] = useOrder()
27
+ const windowWidth = Dimensions.get('window').width;
28
+
29
+ const onBusinessClick = (business: any) => {
30
+ onNavigationRedirect('Business', { store: business.slug })
31
+ }
32
+ useEffect(() => {
33
+ if (businessesList?.loading && businessesList?.businesses?.length === 0) {
34
+ setBusinessLoading(true)
35
+ } else {
36
+ setBusinessLoading(false)
37
+ }
38
+ }, [businessesList?.loading])
39
+
40
+ const styles = StyleSheet.create({
41
+ container: {
42
+ marginBottom: 0,
43
+ },
44
+ });
45
+
46
+ const BusinessControllerList = ({ style }: any) => {
47
+ return (
48
+ <>
49
+ {businessesList.businesses?.filter((business: any) => businessId?.includes(business?.id))?.map((business: any, i: number) => (
50
+ <BusinessController
51
+ key={`${business.id}_` + i}
52
+ business={business}
53
+ isBusinessOpen={business.open}
54
+ handleCustomClick={() => onBusinessClick(business)}
55
+ orderType={orderState?.options?.type}
56
+ navigation={navigation}
57
+ businessHeader={business?.header}
58
+ businessFeatured={business?.featured}
59
+ businessLogo={business?.logo}
60
+ businessReviews={business?.reviews}
61
+ businessDeliveryPrice={business?.delivery_price}
62
+ businessDeliveryTime={business?.delivery_time}
63
+ businessPickupTime={business?.pickup_time}
64
+ businessDistance={business?.distance}
65
+ style={style}
66
+ />
67
+ ))}
68
+ </>
69
+ )
70
+ }
71
+
72
+ const BusinessSkeletons = () => {
73
+ return (
74
+ <>
75
+ {[...Array(4).keys()].map((item, i) => (
76
+ <Placeholder
77
+ Animation={Fade}
78
+ key={i}
79
+ style={{ marginBottom: 20 }}>
80
+ <View style={{ width: '100%' }}>
81
+ <PlaceholderLine
82
+ height={200}
83
+ style={{ marginBottom: 20, borderRadius: 25 }}
84
+ />
85
+ <View style={{ paddingHorizontal: 10 }}>
86
+ <View
87
+ style={{
88
+ flexDirection: 'row',
89
+ justifyContent: 'space-between',
90
+ }}>
91
+ <PlaceholderLine
92
+ height={25}
93
+ width={40}
94
+ style={{ marginBottom: 10 }}
95
+ />
96
+ <PlaceholderLine
97
+ height={25}
98
+ width={20}
99
+ style={{ marginBottom: 10 }}
100
+ />
101
+ </View>
102
+ <PlaceholderLine
103
+ height={20}
104
+ width={30}
105
+ style={{ marginBottom: 10 }}
106
+ />
107
+ <PlaceholderLine
108
+ height={20}
109
+ width={80}
110
+ style={{ marginBottom: 10 }}
111
+ />
112
+ </View>
113
+ </View>
114
+ </Placeholder>
115
+ ))}
116
+ </>
117
+ )
118
+ }
119
+
120
+ return (
121
+ <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
122
+ {isBusinessesSearchList ? (
123
+ <>
124
+ {!businessLoading && (
125
+ <BusinessControllerList
126
+ style={{ width: windowWidth - 80, marginRight: 20 }}
127
+ />
128
+ )}
129
+ </>
130
+ ) : (
131
+ <ListWrapper>
132
+ <BusinessControllerList />
133
+ {businessesList.loading && (
134
+ <BusinessSkeletons />
135
+ )}
136
+ </ListWrapper>
137
+ )}
138
+
139
+ </ScrollView>
140
+ )
141
+ }
142
+
143
+ export const PreviousBusinessOrdered = (props: PreviousBusinessOrderedParams) => {
144
+ const previousBusinessOrderedController = {
145
+ ...props,
146
+ UIComponent: PreviousBusinessOrderedUI,
147
+ paginationSettings: { initialPage: 1, pageSize: 50, controlType: 'infinity' }
148
+ }
149
+
150
+ return (
151
+ <BusinessListController {...previousBusinessOrderedController} />
152
+ )
153
+ }
@@ -0,0 +1,6 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const ListWrapper = styled.View`
4
+ background-color: ${(props: any) => props.theme.colors.backgroundLight};
5
+ padding-horizontal: ${(props : any) => props.isBusinessesSearchList ? '0' : '40px'};
6
+ `;
@@ -0,0 +1,53 @@
1
+ import React from 'react'
2
+ import { ScrollView, StyleSheet, Dimensions } from 'react-native'
3
+ import {
4
+ ListWrapper
5
+ } from './styles'
6
+
7
+ import { SingleProductCard } from '../../SingleProductCard'
8
+ import { PreviousProductsOrderedParams } from '../../../types'
9
+
10
+ export const PreviousProductsOrdered = (props: PreviousProductsOrderedParams) => {
11
+ const {
12
+ products,
13
+ onProductClick,
14
+ isBusinessesSearchList
15
+ } = props
16
+
17
+ const windowWidth = Dimensions.get('window').width;
18
+
19
+ const styles = StyleSheet.create({
20
+ container: {
21
+ marginBottom: 0,
22
+ },
23
+ });
24
+
25
+ const ProductList = ({ style }: any) => {
26
+ return (
27
+ <>
28
+ {products?.map((product: any) => (
29
+ <SingleProductCard
30
+ key={product?.id}
31
+ isSoldOut={(product.inventoried && !product.quantity)}
32
+ product={product}
33
+ businessId={product?.business?.id}
34
+ onProductClick={onProductClick}
35
+ style={style}
36
+ productAddedToCartLength={0}
37
+ />
38
+ ))}
39
+ </>
40
+ )
41
+ }
42
+ return (
43
+ <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
44
+ {isBusinessesSearchList ? (
45
+ <ProductList style={{ width: windowWidth - 80, marginRight: 20 }} />
46
+ ) : (
47
+ <ListWrapper isBusinessesSearchList={isBusinessesSearchList}>
48
+ <ProductList />
49
+ </ListWrapper>
50
+ )}
51
+ </ScrollView>
52
+ )
53
+ }
@@ -0,0 +1,6 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const ListWrapper = styled.View`
4
+ background-color: ${(props: any) => props.theme.colors.backgroundLight};
5
+ padding-horizontal: ${(props : any) => props.isBusinessesSearchList ? '0' : '40px'};
6
+ `;
@@ -6,10 +6,11 @@ import { OText, OButton } from '../shared'
6
6
  import { NotFoundSource } from '../NotFoundSource'
7
7
  import { ActiveOrders } from '../ActiveOrders'
8
8
  import { PreviousOrders } from '../PreviousOrders'
9
-
9
+ import { PreviousBusinessOrdered } from './PreviousBusinessOrdered'
10
+ import { PreviousProductsOrdered } from './PreviousProductsOrdered'
10
11
  import { OptionTitle, NoOrdersWrapper } from './styles'
11
12
  import { OrdersOptionParams } from '../../types'
12
-
13
+ import { _setStoreData } from '../../providers/StoreUtil';
13
14
  import {
14
15
  Placeholder,
15
16
  PlaceholderLine,
@@ -33,15 +34,28 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
33
34
  loadMoreOrders,
34
35
  loadOrders,
35
36
  setOrdersLength,
36
- ordersLength
37
+ ordersLength,
38
+ refreshOrders,
39
+ setRefreshOrders,
40
+ reorderState,
41
+ handleReorder,
42
+ handleUpdateOrderList,
43
+ isBusiness,
44
+ isProducts,
45
+ businessOrderIds,
46
+ products,
47
+ businessesSearchList,
48
+ hideOrders,
49
+ BusinessControllerSkeletons,
37
50
  } = props
38
51
 
39
52
  const theme = useTheme();
40
53
 
41
54
  const [, t] = useLanguage()
42
- const [, { reorder }] = useOrder()
43
- const { showToast } = useToast()
55
+ const [{ carts }] = useOrder()
56
+ const [, { showToast }] = useToast()
44
57
  const { loading, error, orders: values } = orderList
58
+ const [businessLoading, setBusinessLoading] = useState(true)
45
59
 
46
60
  const imageFails = activeOrders
47
61
  ? theme.images.general.emptyActiveOrders
@@ -49,26 +63,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
49
63
 
50
64
  const orders = customArray || values || []
51
65
 
52
- const [reorderLoading, setReorderLoading] = useState(false)
53
-
54
-
55
- const handleReorder = async (orderId: number) => {
56
- setReorderLoading(true)
57
- try {
58
- const { error, result } = await reorder(orderId)
59
- if (!error) {
60
- onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: result.uuid })
61
- setReorderLoading(false)
62
- return
63
- }
64
- setReorderLoading(false)
65
-
66
- } catch (err: any) {
67
- showToast(ToastType.Error, t('ERROR', err.message))
68
- setReorderLoading(false)
69
- }
70
- }
71
-
72
66
  const getOrderStatus = (s: string) => {
73
67
  const status = parseInt(s)
74
68
  const orderStatus = [
@@ -103,9 +97,51 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
103
97
  return objectStatus && objectStatus
104
98
  }
105
99
 
100
+ const onProductClick = (product: any) => {
101
+ if (product?.product_id && product?.category_id && product?.businessId &&
102
+ product?.business.slug && product?.business.header && product?.business.logo) {
103
+ onNavigationRedirect('ProductDetails', {
104
+ isRedirect: 'business',
105
+ businessId: product?.businessId,
106
+ categoryId: product?.category_id,
107
+ productId: product?.product_id,
108
+ business: {
109
+ store: product?.business.slug,
110
+ header: product?.business.header,
111
+ logo: product?.business.logo,
112
+ }
113
+ })
114
+ } else {
115
+ showToast(ToastType.Error, t('ERROR_FAILED_REDIRECT_IDS', 'Failed to redirect product for ids'))
116
+ }
117
+ }
118
+
119
+ useEffect(() => {
120
+ const _businessId = 'businessId:' + reorderState?.result?.business_id
121
+ if (reorderState?.error) {
122
+ if (reorderState?.result?.business_id) {
123
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
124
+ navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
125
+ }
126
+ }
127
+ if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
128
+ const cartProducts = carts?.[_businessId]?.products
129
+ const available = cartProducts.every((product: any) => product.valid === true)
130
+ const orderProducts = orders.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
131
+
132
+ if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
133
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
134
+ } else {
135
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
136
+ cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
137
+ navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
138
+ }
139
+ }
140
+ }, [reorderState])
141
+
106
142
  useFocusEffect(
107
143
  React.useCallback(() => {
108
- loadOrders()
144
+ loadOrders(false, false, false, true)
109
145
  }, [navigation])
110
146
  )
111
147
 
@@ -126,7 +162,14 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
126
162
  } else if (!preOrders) {
127
163
  setOrdersLength && setOrdersLength({ ...ordersLength, previousOrdersLength: updateOrders?.length })
128
164
  }
129
- }, [orders, activeOrders])
165
+ }, [orders, activeOrders, preOrders])
166
+
167
+ useEffect(() => {
168
+ if (refreshOrders) {
169
+ loadOrders(false, false, false, true)
170
+ setRefreshOrders && setRefreshOrders(false)
171
+ }
172
+ }, [refreshOrders])
130
173
 
131
174
  return (
132
175
  <>
@@ -144,9 +187,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
144
187
 
145
188
  </NoOrdersWrapper>
146
189
  )}
147
- {(ordersLength.activeOrdersLength > 0 || ordersLength.previousOrdersLength > 0) && (
190
+ {(ordersLength?.activeOrdersLength > 0 || ordersLength?.previousOrdersLength > 0) && (
148
191
  <>
149
- <OptionTitle>
192
+ <OptionTitle titleContent={!!titleContent} isBusinessesSearchList={!!businessesSearchList}>
150
193
  <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={10} >
151
194
  {titleContent || (activeOrders
152
195
  ? t('ACTIVE', 'Active')
@@ -155,7 +198,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
155
198
  : t('PAST', 'Past'))}
156
199
  </OText>
157
200
  </OptionTitle>
158
- {!(ordersLength.activeOrdersLength === 0 && ordersLength.previousOrdersLength === 0) &&
201
+ {!(ordersLength?.activeOrdersLength === 0 && ordersLength?.previousOrdersLength === 0) &&
159
202
  !loading &&
160
203
  orders.filter((order: any) => orderStatus.includes(order.status)).length === 0 &&
161
204
  (
@@ -167,7 +210,51 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
167
210
  )}
168
211
  </>
169
212
  )}
170
- {loading && (
213
+ {isBusiness && !!businessesSearchList && businessLoading && (
214
+ <ScrollView horizontal>
215
+ <BusinessControllerSkeletons />
216
+ </ScrollView>
217
+ )}
218
+ {isBusiness && businessOrderIds?.length > 0 && (
219
+ <PreviousBusinessOrdered
220
+ businessId={businessOrderIds}
221
+ businessLoading={businessLoading}
222
+ setBusinessLoading={setBusinessLoading}
223
+ onNavigationRedirect={onNavigationRedirect}
224
+ isLoadingOrders={loading}
225
+ isBusinessesSearchList={!!businessesSearchList}
226
+ />
227
+ )}
228
+
229
+ {isProducts && (
230
+ <PreviousProductsOrdered
231
+ products={products}
232
+ onProductClick={onProductClick}
233
+ isBusinessesSearchList={!!businessesSearchList}
234
+ />
235
+ )}
236
+ {(loading && isProducts) && (
237
+ <>
238
+ {[...Array(4).keys()].map(
239
+ (item, i) => (
240
+ <Placeholder key={i} style={{ padding: 5, paddingLeft: 40 }} Animation={Fade}>
241
+ <View style={{ flexDirection: 'row' }}>
242
+ <PlaceholderLine
243
+ width={24}
244
+ height={70}
245
+ style={{ marginRight: 10, marginBottom: 10 }}
246
+ />
247
+ <Placeholder style={{ paddingVertical: 10 }}>
248
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
249
+ <PlaceholderLine width={20} />
250
+ </Placeholder>
251
+ </View>
252
+ </Placeholder>
253
+ ),
254
+ )}
255
+ </>
256
+ )}
257
+ {loading && !hideOrders && (
171
258
  <>
172
259
  {!activeOrders ? (
173
260
  <Placeholder style={{ marginTop: 30 }} Animation={Fade}>
@@ -198,35 +285,38 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
198
285
  )}
199
286
  </>
200
287
  )}
201
- {!loading && !error && orders.length > 0 && (
288
+ {!loading && !error && orders.length > 0 && !hideOrders && (
202
289
  preOrders ? (
203
290
  <ActiveOrders
204
291
  orders={orders.filter((order: any) => orderStatus.includes(order.status))}
205
292
  pagination={pagination}
206
293
  loadMoreOrders={loadMoreOrders}
207
- reorderLoading={reorderLoading}
294
+ reorderLoading={reorderState?.loading}
208
295
  customArray={customArray}
209
296
  getOrderStatus={getOrderStatus}
210
297
  onNavigationRedirect={onNavigationRedirect}
298
+ handleUpdateOrderList={handleUpdateOrderList}
211
299
  />
212
300
  ) : activeOrders ? (
213
301
  <ActiveOrders
214
302
  orders={orders.filter((order: any) => orderStatus.includes(order.status))}
215
303
  pagination={pagination}
216
- reorderLoading={reorderLoading}
304
+ reorderLoading={reorderState?.loading}
217
305
  customArray={customArray}
218
306
  getOrderStatus={getOrderStatus}
219
307
  onNavigationRedirect={onNavigationRedirect}
308
+ handleUpdateOrderList={handleUpdateOrderList}
220
309
  />
221
310
  ) : (
222
311
  <PreviousOrders
223
- reorderLoading={reorderLoading}
312
+ reorderLoading={reorderState?.loading}
224
313
  orders={orders.filter((order: any) => orderStatus.includes(order.status)).sort((a: any, b: any) => a?.id < b?.id)}
225
314
  pagination={pagination}
226
315
  loadMoreOrders={loadMoreOrders}
227
316
  getOrderStatus={getOrderStatus}
228
317
  onNavigationRedirect={onNavigationRedirect}
229
318
  handleReorder={handleReorder}
319
+ handleUpdateOrderList={handleUpdateOrderList}
230
320
  />
231
321
  )
232
322
  )}
@@ -235,13 +325,22 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
235
325
  }
236
326
 
237
327
  export const OrdersOption = (props: OrdersOptionParams) => {
328
+ const getAllOrders = props.activeOrders && props.pastOrders && props.preOrders
329
+
238
330
  const MyOrdersProps = {
239
331
  ...props,
240
332
  UIComponent: OrdersOptionUI,
241
- orderStatus: props.preOrders ? [13] : props.activeOrders
242
- ? [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23]
243
- : [1, 2, 5, 6, 10, 11, 12, 15, 16, 17],
333
+ orderStatus: getAllOrders
334
+ ? [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
335
+ : props.preOrders ? [13] : props.activeOrders
336
+ ? [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23]
337
+ : [1, 2, 5, 6, 10, 11, 12, 15, 16, 17],
244
338
  useDefualtSessionManager: true,
339
+ paginationSettings: {
340
+ initialPage: 1,
341
+ pageSize: getAllOrders ? 30 : 10,
342
+ controlType: 'infinity'
343
+ }
245
344
  }
246
345
 
247
346
  return <OrderList {...MyOrdersProps} />
@@ -1,7 +1,10 @@
1
- import styled from 'styled-components/native'
1
+ import styled, { css } from 'styled-components/native'
2
2
 
3
3
  export const OptionTitle = styled.View`
4
4
  margin-top: 24px;
5
+ ${(props : any) => props.titleContent && css`
6
+ margin-left: ${() => props.isBusinessesSearchList ? '0' : '40px'};
7
+ `}
5
8
  `
6
9
 
7
10
  export const NoOrdersWrapper = styled.View`
@@ -23,8 +23,8 @@ export const PaymentOptionCash = (props: any) => {
23
23
  borderRadius: 7.6,
24
24
  marginTop: 10,
25
25
  width: '100%',
26
- height: 44,
27
- maxHeight: 44
26
+ height: 50,
27
+ maxHeight: 50
28
28
  },
29
29
  errorMsg: {
30
30
  marginTop: 10,
@@ -1,8 +1,8 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import { Platform, StyleSheet, View } from 'react-native'
2
+ import { View } from 'react-native'
3
3
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
4
4
  import { useTheme } from 'styled-components/native'
5
- import CheckBox from '@react-native-community/checkbox';
5
+ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
6
6
  import {
7
7
  PaymentOptionWallet as PaymentOptionWalletController,
8
8
  useLanguage,
@@ -41,13 +41,6 @@ const PaymentOptionWalletUI = (props: any) => {
41
41
  const isBusinessWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
42
42
  const isBusinessWalletPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
43
43
 
44
- const styles = StyleSheet.create({
45
- checkBoxStyle: {
46
- width: 25,
47
- height: 25,
48
- }
49
- });
50
-
51
44
  const [checkedState, setCheckedState] = useState(
52
45
  new Array(walletsState.result?.length).fill(false)
53
46
  );
@@ -100,22 +93,23 @@ const PaymentOptionWalletUI = (props: any) => {
100
93
  <Container
101
94
  key={wallet.id}
102
95
  isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
+ onPress={() => handleOnChange(idx, wallet)}
97
+ disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
103
98
  >
104
99
  <SectionLeft>
105
- <CheckBox
106
- value={checkedState[idx]}
107
- onValueChange={() => handleOnChange(idx, wallet)}
108
- disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0 }
109
- boxType={'square'}
110
- tintColors={{
111
- true: theme.colors.primary,
112
- false: theme.colors.disabled
113
- }}
114
- tintColor={theme.colors.disabled}
115
- onCheckColor={theme.colors.primary}
116
- onTintColor={theme.colors.primary}
117
- style={Platform.OS === 'ios' && styles.checkBoxStyle}
118
- />
100
+ {checkedState[idx] ? (
101
+ <MaterialCommunityIcons
102
+ name="checkbox-marked"
103
+ size={25}
104
+ color={theme.colors.primary}
105
+ />
106
+ ) : (
107
+ <MaterialCommunityIcons
108
+ name="checkbox-blank-outline"
109
+ size={25}
110
+ color={theme.colors.disabled}
111
+ />
112
+ )}
119
113
  <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
120
114
  <View>
121
115
  <OText
@@ -1,6 +1,6 @@
1
1
  import styled, { css } from 'styled-components/native'
2
2
 
3
- export const Container = styled.View`
3
+ export const Container = styled.TouchableOpacity`
4
4
  width: 100%;
5
5
  display: flex;
6
6
  padding: 20px 0;