ordering-ui-react-native 0.15.51 → 0.15.53-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 (189) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessController/index.tsx +16 -8
  5. package/src/components/BusinessTypeFilter/index.tsx +3 -1
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/Checkout/index.tsx +23 -2
  8. package/src/components/DriverTips/index.tsx +11 -6
  9. package/src/components/LanguageSelector/index.tsx +7 -2
  10. package/src/components/LoginForm/index.tsx +120 -30
  11. package/src/components/LoginForm/styles.tsx +6 -0
  12. package/src/components/OrderDetails/index.tsx +9 -23
  13. package/src/components/PaymentOptions/index.tsx +67 -50
  14. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  15. package/src/components/SignupForm/index.tsx +145 -61
  16. package/src/components/SingleProductCard/index.tsx +16 -4
  17. package/src/components/StripeMethodForm/index.tsx +1 -2
  18. package/src/components/UpsellingProducts/index.tsx +1 -1
  19. package/src/components/UserProfileForm/index.tsx +63 -6
  20. package/src/components/UserProfileForm/styles.tsx +8 -0
  21. package/src/components/VerifyPhone/styles.tsx +1 -2
  22. package/src/components/shared/OModal.tsx +1 -1
  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/BusinessesListing.tsx +1 -1
  27. package/src/pages/MultiCheckout.tsx +31 -0
  28. package/src/pages/MultiOrdersDetails.tsx +27 -0
  29. package/src/pages/Sessions.tsx +22 -0
  30. package/src/theme.json +0 -1
  31. package/src/types/index.tsx +18 -11
  32. package/src/utils/index.tsx +68 -1
  33. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  34. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  35. package/themes/business/src/components/Chat/index.tsx +42 -90
  36. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  37. package/themes/business/src/components/Home/index.tsx +128 -55
  38. package/themes/business/src/components/Home/styles.tsx +8 -1
  39. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  40. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  41. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  42. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  43. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  44. package/themes/business/src/components/OrderDetails/Delivery.tsx +35 -18
  45. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +159 -91
  46. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  47. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  48. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  49. package/themes/business/src/components/OrdersOption/index.tsx +5 -2
  50. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  51. package/themes/business/src/components/shared/OModal.tsx +1 -1
  52. package/themes/business/src/types/index.tsx +5 -1
  53. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  55. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  57. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  58. package/themes/kiosk/src/components/Cart/index.tsx +99 -26
  59. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  60. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  61. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  62. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  63. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  64. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  65. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  66. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  67. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  68. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  69. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  70. package/themes/kiosk/src/components/OrderDetails/index.tsx +165 -65
  71. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  72. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  73. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  74. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  75. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  76. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  77. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  78. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  79. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  80. package/themes/kiosk/src/types/index.d.ts +3 -0
  81. package/themes/original/index.tsx +169 -4
  82. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  83. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  84. package/themes/original/src/components/AddressForm/index.tsx +1 -1
  85. package/themes/original/src/components/AddressList/index.tsx +30 -18
  86. package/themes/original/src/components/AppleLogin/index.tsx +54 -21
  87. package/themes/original/src/components/BusinessBasicInformation/index.tsx +136 -45
  88. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  89. package/themes/original/src/components/BusinessController/index.tsx +48 -11
  90. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  91. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  92. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  93. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  94. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  95. package/themes/original/src/components/BusinessListingSearch/index.tsx +196 -58
  96. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  97. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  98. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  99. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  100. package/themes/original/src/components/BusinessProductsList/index.tsx +119 -35
  101. package/themes/original/src/components/BusinessProductsList/styles.tsx +12 -4
  102. package/themes/original/src/components/BusinessProductsListing/index.tsx +109 -21
  103. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  104. package/themes/original/src/components/BusinessReviews/index.tsx +10 -26
  105. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  106. package/themes/original/src/components/BusinessesListing/index.tsx +127 -66
  107. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  108. package/themes/original/src/components/Cart/index.tsx +60 -41
  109. package/themes/original/src/components/Checkout/index.tsx +48 -32
  110. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  111. package/themes/original/src/components/Favorite/index.tsx +92 -0
  112. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  113. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  114. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  115. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  116. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  117. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  118. package/themes/original/src/components/Help/index.tsx +21 -4
  119. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  120. package/themes/original/src/components/Home/index.tsx +1 -1
  121. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  122. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  123. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  124. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  125. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  126. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  127. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  128. package/themes/original/src/components/Messages/index.tsx +1 -1
  129. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  130. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  131. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  132. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  133. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  134. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  135. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  136. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  137. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  138. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  139. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  140. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  141. package/themes/original/src/components/OrderDetails/index.tsx +117 -46
  142. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  143. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  144. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  145. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  146. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  147. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  148. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  149. package/themes/original/src/components/OrdersOption/index.tsx +130 -38
  150. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  151. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  152. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  153. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  154. package/themes/original/src/components/PaymentOptions/index.tsx +57 -36
  155. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  156. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  157. package/themes/original/src/components/ProductForm/index.tsx +70 -62
  158. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  159. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  160. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  161. package/themes/original/src/components/Promotions/index.tsx +151 -133
  162. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  163. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  164. package/themes/original/src/components/Sessions/index.tsx +160 -0
  165. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  166. package/themes/original/src/components/SignupForm/index.tsx +333 -128
  167. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  168. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  169. package/themes/original/src/components/SingleProductCard/index.tsx +59 -17
  170. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  171. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  172. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  173. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  174. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  175. package/themes/original/src/components/UserProfile/index.tsx +53 -6
  176. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  177. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  178. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  179. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  180. package/themes/original/src/components/Wallets/index.tsx +76 -9
  181. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  182. package/themes/original/src/components/shared/OModal.tsx +4 -2
  183. package/themes/original/src/config/constants.tsx +6 -6
  184. package/themes/original/src/types/index.tsx +139 -15
  185. package/themes/original/src/utils/index.tsx +85 -2
  186. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  187. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  188. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  189. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -71,7 +71,7 @@ const OrderSummaryUI = (props: any) => {
71
71
  }
72
72
 
73
73
  const getIncludedTaxes = () => {
74
- if (cart?.taxes === null) {
74
+ if (cart?.taxes === null || !cart?.taxes) {
75
75
  return cart.business.tax_type === 1 ? cart?.tax : 0
76
76
  } else {
77
77
  return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
@@ -112,7 +112,7 @@ const OrderSummaryUI = (props: any) => {
112
112
  {cart?.products?.length > 0 && (
113
113
  <>
114
114
  <OSProductList>
115
- {cart?.products.map((product: any) => (
115
+ {cart?.products?.map((product: any) => (
116
116
  <ProductItemAccordion
117
117
  key={product.code}
118
118
  product={product}
@@ -202,7 +202,7 @@ const OrderSummaryUI = (props: any) => {
202
202
  <OSRow>
203
203
  <OText size={12} numberOfLines={1}>
204
204
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
205
- ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%)
205
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)}${fee.percentage > 0 ? ' + ' : ''}`}{fee.percentage > 0 && `${fee.percentage}%`}){' '}
206
206
  </OText>
207
207
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
208
208
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
@@ -19,7 +19,8 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
19
19
  typeSelected,
20
20
  defaultValue,
21
21
  configTypes,
22
- orderTypes
22
+ orderTypes,
23
+ setOrderTypeValue
23
24
  } = props
24
25
 
25
26
  const theme = useTheme();
@@ -39,6 +40,7 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
39
40
 
40
41
  const handleChangeOrderTypeCallback = (orderType: number) => {
41
42
  if (!orderState.loading) {
43
+ setOrderTypeValue && setOrderTypeValue(orderType)
42
44
  handleChangeOrderType(orderType)
43
45
  goToBack();
44
46
  }
@@ -51,7 +53,7 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
51
53
  btnStyle={{ paddingLeft: 0 }}
52
54
  paddingTop={0}
53
55
  style={{ paddingBottom: 0 }}
54
- title={t('HOW_WILL_YOUR_ORDER_TYPE', 'How will your order type?')}
56
+ title={t('HOW_WILL_YOU_DELIVERY_TYPE', 'How will your order type?')}
55
57
  titleAlign={'center'}
56
58
  titleStyle={{ fontSize: 14 }}
57
59
  />
@@ -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,44 @@ 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
+ onNavigationRedirect('ProductDetails', {
103
+ productId: product?.product_id,
104
+ categoryId: product?.category_id,
105
+ businessId: product?.businessId,
106
+ })
107
+ } else {
108
+ showToast(ToastType.Error, t('ERROR_FAILED_REDIRECT_IDS', 'Failed to redirect product for ids'))
109
+ }
110
+ }
111
+
112
+ useEffect(() => {
113
+ const _businessId = 'businessId:' + reorderState?.result?.business_id
114
+ if (reorderState?.error) {
115
+ if (reorderState?.result?.business_id) {
116
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
117
+ navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
118
+ }
119
+ }
120
+ if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
121
+ const cartProducts = carts?.[_businessId]?.products
122
+ const available = cartProducts.every((product: any) => product.valid === true)
123
+ const orderProducts = orders.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
124
+
125
+ if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
126
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
127
+ } else {
128
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
129
+ cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
130
+ navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
131
+ }
132
+ }
133
+ }, [reorderState])
134
+
106
135
  useFocusEffect(
107
136
  React.useCallback(() => {
108
- loadOrders()
137
+ loadOrders(false, false, false, true)
109
138
  }, [navigation])
110
139
  )
111
140
 
@@ -126,7 +155,14 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
126
155
  } else if (!preOrders) {
127
156
  setOrdersLength && setOrdersLength({ ...ordersLength, previousOrdersLength: updateOrders?.length })
128
157
  }
129
- }, [orders, activeOrders])
158
+ }, [orders, activeOrders, preOrders])
159
+
160
+ useEffect(() => {
161
+ if (refreshOrders) {
162
+ loadOrders(false, false, false, true)
163
+ setRefreshOrders && setRefreshOrders(false)
164
+ }
165
+ }, [refreshOrders])
130
166
 
131
167
  return (
132
168
  <>
@@ -144,9 +180,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
144
180
 
145
181
  </NoOrdersWrapper>
146
182
  )}
147
- {(ordersLength.activeOrdersLength > 0 || ordersLength.previousOrdersLength > 0) && (
183
+ {(ordersLength?.activeOrdersLength > 0 || ordersLength?.previousOrdersLength > 0) && (
148
184
  <>
149
- <OptionTitle>
185
+ <OptionTitle titleContent={!!titleContent} isBusinessesSearchList={!!businessesSearchList}>
150
186
  <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={10} >
151
187
  {titleContent || (activeOrders
152
188
  ? t('ACTIVE', 'Active')
@@ -155,7 +191,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
155
191
  : t('PAST', 'Past'))}
156
192
  </OText>
157
193
  </OptionTitle>
158
- {!(ordersLength.activeOrdersLength === 0 && ordersLength.previousOrdersLength === 0) &&
194
+ {!(ordersLength?.activeOrdersLength === 0 && ordersLength?.previousOrdersLength === 0) &&
159
195
  !loading &&
160
196
  orders.filter((order: any) => orderStatus.includes(order.status)).length === 0 &&
161
197
  (
@@ -167,7 +203,51 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
167
203
  )}
168
204
  </>
169
205
  )}
170
- {loading && (
206
+ {isBusiness && !!businessesSearchList && businessLoading && (
207
+ <ScrollView horizontal>
208
+ <BusinessControllerSkeletons />
209
+ </ScrollView>
210
+ )}
211
+ {isBusiness && businessOrderIds?.length > 0 && (
212
+ <PreviousBusinessOrdered
213
+ businessId={businessOrderIds}
214
+ businessLoading={businessLoading}
215
+ setBusinessLoading={setBusinessLoading}
216
+ onNavigationRedirect={onNavigationRedirect}
217
+ isLoadingOrders={loading}
218
+ isBusinessesSearchList={!!businessesSearchList}
219
+ />
220
+ )}
221
+
222
+ {isProducts && (
223
+ <PreviousProductsOrdered
224
+ products={products}
225
+ onProductClick={onProductClick}
226
+ isBusinessesSearchList={!!businessesSearchList}
227
+ />
228
+ )}
229
+ {(loading && isProducts) && (
230
+ <>
231
+ {[...Array(4).keys()].map(
232
+ (item, i) => (
233
+ <Placeholder key={i} style={{ padding: 5, paddingLeft: 40 }} Animation={Fade}>
234
+ <View style={{ flexDirection: 'row' }}>
235
+ <PlaceholderLine
236
+ width={24}
237
+ height={70}
238
+ style={{ marginRight: 10, marginBottom: 10 }}
239
+ />
240
+ <Placeholder style={{ paddingVertical: 10 }}>
241
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
242
+ <PlaceholderLine width={20} />
243
+ </Placeholder>
244
+ </View>
245
+ </Placeholder>
246
+ ),
247
+ )}
248
+ </>
249
+ )}
250
+ {loading && !hideOrders && (
171
251
  <>
172
252
  {!activeOrders ? (
173
253
  <Placeholder style={{ marginTop: 30 }} Animation={Fade}>
@@ -198,35 +278,38 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
198
278
  )}
199
279
  </>
200
280
  )}
201
- {!loading && !error && orders.length > 0 && (
281
+ {!loading && !error && orders.length > 0 && !hideOrders && (
202
282
  preOrders ? (
203
283
  <ActiveOrders
204
284
  orders={orders.filter((order: any) => orderStatus.includes(order.status))}
205
285
  pagination={pagination}
206
286
  loadMoreOrders={loadMoreOrders}
207
- reorderLoading={reorderLoading}
287
+ reorderLoading={reorderState?.loading}
208
288
  customArray={customArray}
209
289
  getOrderStatus={getOrderStatus}
210
290
  onNavigationRedirect={onNavigationRedirect}
291
+ handleUpdateOrderList={handleUpdateOrderList}
211
292
  />
212
293
  ) : activeOrders ? (
213
294
  <ActiveOrders
214
295
  orders={orders.filter((order: any) => orderStatus.includes(order.status))}
215
296
  pagination={pagination}
216
- reorderLoading={reorderLoading}
297
+ reorderLoading={reorderState?.loading}
217
298
  customArray={customArray}
218
299
  getOrderStatus={getOrderStatus}
219
300
  onNavigationRedirect={onNavigationRedirect}
301
+ handleUpdateOrderList={handleUpdateOrderList}
220
302
  />
221
303
  ) : (
222
304
  <PreviousOrders
223
- reorderLoading={reorderLoading}
305
+ reorderLoading={reorderState?.loading}
224
306
  orders={orders.filter((order: any) => orderStatus.includes(order.status)).sort((a: any, b: any) => a?.id < b?.id)}
225
307
  pagination={pagination}
226
308
  loadMoreOrders={loadMoreOrders}
227
309
  getOrderStatus={getOrderStatus}
228
310
  onNavigationRedirect={onNavigationRedirect}
229
311
  handleReorder={handleReorder}
312
+ handleUpdateOrderList={handleUpdateOrderList}
230
313
  />
231
314
  )
232
315
  )}
@@ -235,13 +318,22 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
235
318
  }
236
319
 
237
320
  export const OrdersOption = (props: OrdersOptionParams) => {
321
+ const getAllOrders = props.activeOrders && props.pastOrders && props.preOrders
322
+
238
323
  const MyOrdersProps = {
239
324
  ...props,
240
325
  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],
326
+ orderStatus: getAllOrders
327
+ ? [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
328
+ : props.preOrders ? [13] : props.activeOrders
329
+ ? [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23]
330
+ : [1, 2, 5, 6, 10, 11, 12, 15, 16, 17],
244
331
  useDefualtSessionManager: true,
332
+ paginationSettings: {
333
+ initialPage: 1,
334
+ pageSize: getAllOrders ? 30 : 10,
335
+ controlType: 'infinity'
336
+ }
245
337
  }
246
338
 
247
339
  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;