ordering-ui-react-native 0.16.16 → 0.16.17-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 (205) hide show
  1. package/package.json +7 -4
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  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 +10 -8
  8. package/src/components/BusinessInformation/index.tsx +33 -4
  9. package/src/components/BusinessInformation/styles.tsx +2 -2
  10. package/src/components/BusinessProductsList/index.tsx +10 -10
  11. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  12. package/src/components/BusinessesListing/index.tsx +1 -1
  13. package/src/components/Checkout/index.tsx +2 -1
  14. package/src/components/LanguageSelector/index.tsx +21 -16
  15. package/src/components/LoginForm/index.tsx +118 -30
  16. package/src/components/LoginForm/styles.tsx +6 -0
  17. package/src/components/Messages/index.tsx +2 -2
  18. package/src/components/NotificationSetting/index.tsx +85 -0
  19. package/src/components/OrderDetails/index.tsx +2 -20
  20. package/src/components/OrdersOption/index.tsx +54 -56
  21. package/src/components/PaymentOptions/index.tsx +335 -365
  22. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  23. package/src/components/ReviewDriver/index.tsx +1 -1
  24. package/src/components/ReviewOrder/index.tsx +2 -1
  25. package/src/components/ReviewProducts/index.tsx +11 -0
  26. package/src/components/SignupForm/index.tsx +143 -61
  27. package/src/components/SingleProductReview/index.tsx +8 -5
  28. package/src/components/StripeElementsForm/index.tsx +25 -16
  29. package/src/components/VerifyPhone/styles.tsx +1 -2
  30. package/src/components/shared/OBottomPopup.tsx +6 -2
  31. package/src/index.tsx +2 -0
  32. package/src/pages/BusinessesListing.tsx +7 -6
  33. package/src/pages/OrderDetails.tsx +1 -1
  34. package/src/pages/ReviewDriver.tsx +2 -2
  35. package/src/pages/ReviewOrder.tsx +2 -2
  36. package/src/theme.json +0 -1
  37. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  38. package/src/types/index.tsx +13 -9
  39. package/src/utils/index.tsx +0 -1
  40. package/themes/business/index.tsx +4 -0
  41. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  42. package/themes/business/src/components/Chat/index.tsx +42 -34
  43. package/themes/business/src/components/DriverMap/index.tsx +7 -5
  44. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  45. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  46. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  47. package/themes/business/src/components/MapView/index.tsx +12 -1
  48. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  49. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  50. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -3
  51. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +25 -19
  52. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  53. package/themes/business/src/components/OrdersOption/index.tsx +65 -21
  54. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  55. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  56. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  57. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  58. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  59. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  60. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  61. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  62. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  63. package/themes/business/src/components/PreviousOrders/index.tsx +21 -23
  64. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  65. package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
  66. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  67. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  68. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  69. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  70. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  71. package/themes/business/src/components/shared/OModal.tsx +40 -37
  72. package/themes/business/src/types/index.tsx +15 -9
  73. package/themes/business/src/utils/index.tsx +10 -0
  74. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  75. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  76. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  77. package/themes/kiosk/src/components/BusinessMenu/index.tsx +2 -1
  78. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  79. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +1 -0
  80. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  81. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  82. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  83. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  84. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  85. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  86. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  87. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  88. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  89. package/themes/kiosk/src/types/index.d.ts +2 -0
  90. package/themes/original/index.tsx +12 -0
  91. package/themes/original/src/components/AddressForm/index.tsx +136 -133
  92. package/themes/original/src/components/AddressList/index.tsx +1 -1
  93. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  94. package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
  95. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  96. package/themes/original/src/components/BusinessController/index.tsx +173 -108
  97. package/themes/original/src/components/BusinessItemAccordion/index.tsx +9 -7
  98. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +4 -0
  99. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  100. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  101. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  102. package/themes/original/src/components/BusinessListingSearch/index.tsx +106 -126
  103. package/themes/original/src/components/BusinessListingSearch/styles.tsx +18 -13
  104. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  105. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  106. package/themes/original/src/components/BusinessProductsList/index.tsx +49 -52
  107. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  108. package/themes/original/src/components/BusinessProductsListing/index.tsx +278 -175
  109. package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -4
  110. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  111. package/themes/original/src/components/BusinessTypeFilter/index.tsx +109 -40
  112. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  113. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
  114. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  115. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +676 -0
  116. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  117. package/themes/original/src/components/BusinessesListing/index.tsx +103 -495
  118. package/themes/original/src/components/Cart/index.tsx +70 -34
  119. package/themes/original/src/components/Cart/styles.tsx +4 -0
  120. package/themes/original/src/components/CartContent/index.tsx +22 -16
  121. package/themes/original/src/components/Checkout/index.tsx +106 -66
  122. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  123. package/themes/original/src/components/DriverTips/index.tsx +4 -4
  124. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  125. package/themes/original/src/components/Favorite/index.tsx +1 -0
  126. package/themes/original/src/components/Favorite/styles.tsx +1 -0
  127. package/themes/original/src/components/FavoriteList/index.tsx +142 -93
  128. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  129. package/themes/original/src/components/GoogleMap/index.tsx +20 -12
  130. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
  131. package/themes/original/src/components/HelpGuide/index.tsx +8 -3
  132. package/themes/original/src/components/HelpOrder/index.tsx +8 -3
  133. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  134. package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -2
  135. package/themes/original/src/components/LoginForm/index.tsx +79 -42
  136. package/themes/original/src/components/Messages/index.tsx +17 -17
  137. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  138. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  139. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +2 -2
  140. package/themes/original/src/components/MultiCheckout/index.tsx +14 -1
  141. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +13 -11
  142. package/themes/original/src/components/MultiOrdersDetails/index.tsx +31 -19
  143. package/themes/original/src/components/MyOrders/index.tsx +68 -6
  144. package/themes/original/src/components/NavBar/index.tsx +11 -5
  145. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  146. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  147. package/themes/original/src/components/Notifications/index.tsx +148 -0
  148. package/themes/original/src/components/Notifications/styles.tsx +17 -0
  149. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  150. package/themes/original/src/components/OrderDetails/index.tsx +200 -42
  151. package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
  152. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  153. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  154. package/themes/original/src/components/OrderProgress/index.tsx +8 -2
  155. package/themes/original/src/components/OrderSummary/index.tsx +1 -34
  156. package/themes/original/src/components/OrderTypeSelector/index.tsx +84 -36
  157. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  158. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +100 -106
  159. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +17 -12
  160. package/themes/original/src/components/OrdersOption/index.tsx +38 -23
  161. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  162. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  163. package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
  164. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  165. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  166. package/themes/original/src/components/ProductForm/index.tsx +712 -655
  167. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  168. package/themes/original/src/components/ProductItemAccordion/index.tsx +170 -128
  169. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  170. package/themes/original/src/components/ProfessionalFilter/index.tsx +129 -0
  171. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  172. package/themes/original/src/components/ProfessionalProfile/index.tsx +309 -0
  173. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  174. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  175. package/themes/original/src/components/ReviewOrder/index.tsx +18 -3
  176. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  177. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  178. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  179. package/themes/original/src/components/SearchBar/index.tsx +10 -5
  180. package/themes/original/src/components/ServiceForm/index.tsx +631 -0
  181. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  182. package/themes/original/src/components/SignupForm/index.tsx +301 -158
  183. package/themes/original/src/components/SingleOrderCard/index.tsx +213 -179
  184. package/themes/original/src/components/SingleProductCard/index.tsx +194 -108
  185. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  186. package/themes/original/src/components/SingleProductReview/index.tsx +30 -3
  187. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  188. package/themes/original/src/components/StripeElementsForm/index.tsx +15 -7
  189. package/themes/original/src/components/UpsellingProducts/index.tsx +14 -4
  190. package/themes/original/src/components/UserDetails/index.tsx +31 -17
  191. package/themes/original/src/components/UserFormDetails/index.tsx +74 -81
  192. package/themes/original/src/components/UserProfile/index.tsx +57 -29
  193. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  194. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  195. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  196. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  197. package/themes/original/src/components/Wallets/index.tsx +174 -162
  198. package/themes/original/src/components/Wallets/styles.tsx +10 -8
  199. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  200. package/themes/original/src/components/shared/OButton.tsx +10 -3
  201. package/themes/original/src/components/shared/OInput.tsx +3 -2
  202. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  203. package/themes/original/src/types/index.tsx +123 -30
  204. package/themes/original/src/utils/index.tsx +77 -0
  205. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useEffect } from 'react'
2
2
  import {
3
3
  OrderTypeControl,
4
4
  useLanguage,
@@ -6,28 +6,32 @@ import {
6
6
  } from 'ordering-components/native'
7
7
  import { useTheme } from 'styled-components/native';
8
8
  import { Platform, View } from 'react-native'
9
- import { BgImage, ListWrapper, MaskCont, OrderTypeWrapper, Wrapper } from './styles'
9
+ import { BgImage, ListWrapper, MaskCont, OrderTypeWrapper, OTab, OTabs, TabBtn, Wrapper } from './styles'
10
10
  import { OrderTypeSelectParams } from '../../types'
11
11
  import { OIcon, OText } from '../shared'
12
12
  import NavBar from '../NavBar';
13
13
  import { ORDER_TYPES } from '../../config/constants';
14
+ import AntDesignIcon from 'react-native-vector-icons/AntDesign'
14
15
 
15
16
  const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
16
17
  const {
17
18
  navigation,
18
19
  handleChangeOrderType,
20
+ handleChangeType,
19
21
  typeSelected,
20
22
  defaultValue,
21
23
  configTypes,
22
24
  orderTypes,
23
- setOrderTypeValue
25
+ setOrderTypeValue,
26
+ isChewLayout,
27
+ chewOrderTypes
24
28
  } = props
25
29
 
26
30
  const theme = useTheme();
27
31
  const [orderState] = useOrder();
28
32
  const [, t] = useLanguage();
29
33
  const _orderTypes = orderTypes.filter((type: any) => configTypes?.includes(type.value));
30
-
34
+
31
35
  const items = _orderTypes.map((type) => {
32
36
  return {
33
37
  value: type.value,
@@ -42,43 +46,87 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
42
46
  if (!orderState.loading) {
43
47
  setOrderTypeValue && setOrderTypeValue(orderType)
44
48
  handleChangeOrderType(orderType)
45
- goToBack();
49
+ if (!isChewLayout) {
50
+ goToBack();
51
+ }
46
52
  }
47
53
  }
48
54
 
55
+ useEffect(() => {
56
+ handleChangeType && handleChangeType(typeSelected)
57
+ }, [typeSelected])
58
+
49
59
  return (
50
60
  <Wrapper>
51
- <NavBar
52
- onActionLeft={() => goToBack()}
53
- btnStyle={{ paddingLeft: 0 }}
54
- paddingTop={0}
55
- style={{ paddingBottom: 0 }}
56
- title={t('HOW_WILL_YOU_DELIVERY_TYPE', 'How will your order type?')}
57
- titleAlign={'center'}
58
- titleStyle={{ fontSize: 14 }}
59
- />
60
- {
61
- items.length > 0 && (
62
- <ListWrapper>
63
- {
64
- items && items.map((item: any, idx: number) =>
65
- <OrderTypeWrapper activeOpacity={0.8} key={idx} disabled={orderState.loading} onPress={() => handleChangeOrderTypeCallback(item.value)}>
66
- <BgImage source={theme.images.orderTypes[`type${item?.value || 1}`]} resizeMode={'cover'} style={{opacity: item?.value == typeSelected || typeSelected === undefined ? 1 : 0.4}}>
67
- <MaskCont>
68
- <OText size={12} lineHeight={18} color={theme.colors.white} weight={Platform.OS === 'android' ? 'bold' : '600'}>{item?.label}</OText>
69
- <OText size={10} lineHeight={15} color={theme.colors.white}>{item?.description}</OText>
70
- <View style={{flexDirection: 'row', alignItems: 'center'}}>
71
- <OText size={10} lineHeight={15} color={theme.colors.white}>{t('START_MY_ORDER', 'Start my order')}</OText>
72
- <OIcon src={theme.images.general.arrow_left} width={16} color={theme.colors.white} style={{transform: [{ rotate: '180deg' }], marginStart: 4}} />
73
- </View>
74
- </MaskCont>
75
- </BgImage>
76
- </OrderTypeWrapper>
77
- )
78
- }
79
- </ListWrapper>
80
- )
81
- }
61
+ {isChewLayout ? (
62
+ <View>
63
+ <OTabs
64
+ horizontal
65
+ showsHorizontalScrollIndicator={false}
66
+ >
67
+ {chewOrderTypes?.map((type: any) => (
68
+ <TabBtn
69
+ key={type.value}
70
+ onPress={() => handleChangeOrderTypeCallback(type.value)}
71
+ >
72
+ <OTab
73
+ style={{
74
+ borderBottomColor:
75
+ type.value === typeSelected
76
+ ? theme.colors.textNormal
77
+ : theme.colors.border,
78
+ }}>
79
+ <OText
80
+ size={14}
81
+ color={
82
+ type.value === typeSelected
83
+ ? theme.colors.textNormal
84
+ : theme.colors.disabled
85
+ }
86
+ weight={type.value === typeSelected ? 'bold' : 'normal'}>
87
+ {type.name}
88
+ </OText>
89
+ </OTab>
90
+ </TabBtn>
91
+ ))}
92
+ </OTabs>
93
+ </View>
94
+ ) : (
95
+ <>
96
+ <NavBar
97
+ onActionLeft={() => goToBack()}
98
+ btnStyle={{ paddingLeft: 0 }}
99
+ paddingTop={0}
100
+ style={{ paddingBottom: 0 }}
101
+ title={t('HOW_WILL_YOU_DELIVERY_TYPE', 'How will your order type?')}
102
+ titleAlign={'center'}
103
+ titleStyle={{ fontSize: 14 }}
104
+ />
105
+ {
106
+ items.length > 0 && (
107
+ <ListWrapper>
108
+ {
109
+ items && items.map((item: any, idx: number) =>
110
+ <OrderTypeWrapper activeOpacity={0.8} key={idx} disabled={orderState.loading} onPress={() => handleChangeOrderTypeCallback(item.value)}>
111
+ <BgImage source={theme.images.orderTypes[`type${item?.value || 1}`]} resizeMode={'cover'} style={{ opacity: item?.value == typeSelected || typeSelected === undefined ? 1 : 0.4 }}>
112
+ <MaskCont>
113
+ <OText size={12} lineHeight={18} color={theme.colors.white} weight={Platform.OS === 'android' ? 'bold' : '600'}>{item?.label}</OText>
114
+ <OText size={10} lineHeight={15} color={theme.colors.white}>{item?.description}</OText>
115
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
116
+ <OText size={10} lineHeight={15} color={theme.colors.white}>{t('START_MY_ORDER', 'Start my order')}</OText>
117
+ <AntDesignIcon name='arrowleft' size={26} color={theme.colors.white} style={{ transform: [{ rotate: '180deg' }], marginStart: 4 }} />
118
+ </View>
119
+ </MaskCont>
120
+ </BgImage>
121
+ </OrderTypeWrapper>
122
+ )
123
+ }
124
+ </ListWrapper>
125
+ )
126
+ }
127
+ </>
128
+ )}
129
+
82
130
  </Wrapper>
83
131
  )
84
132
  }
@@ -24,4 +24,22 @@ export const MaskCont = styled.View`
24
24
  padding: 16px 39px;
25
25
  background-color: #0000004D;
26
26
  height: 100%;
27
- `;
27
+ `;
28
+
29
+ export const OTabs = styled.View`
30
+ flex-direction: row;
31
+ width: 100%;
32
+ margin-bottom: -1px;
33
+ justify-content: space-between;
34
+ `;
35
+
36
+ export const OTab = styled.View`
37
+ padding-bottom: 10px;
38
+ border-bottom-width: 1px;
39
+ padding-horizontal: 10px;
40
+ `;
41
+
42
+ export const TabBtn = styled.TouchableOpacity`
43
+ min-height: 30px;
44
+ height: 30px;
45
+ `;
@@ -1,5 +1,5 @@
1
- import React, { useEffect } from 'react'
2
- import { BusinessList as BusinessListController, useOrder } from 'ordering-components/native'
1
+ import React from 'react'
2
+ import { useOrder } from 'ordering-components/native'
3
3
  import { BusinessController } from '../../BusinessController'
4
4
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
5
5
 
@@ -7,32 +7,100 @@ import { ListWrapper } from './styles'
7
7
  import {
8
8
  View,
9
9
  StyleSheet,
10
- ScrollView
10
+ ScrollView,
11
+ Dimensions
11
12
  } from 'react-native';
12
13
  import { PreviousBusinessOrderedParams } from '../../../types';
13
14
 
14
- export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams) => {
15
+ const BusinessControllerList = ({ businesses, onBusinessClick, navigation, orderState, handleCustomUpdate, style }: any) => {
16
+ return (
17
+ <>
18
+ {businesses?.result?.map((business: any, i: number) => (
19
+ <BusinessController
20
+ key={`${business.id}_` + i}
21
+ business={business}
22
+ isBusinessOpen={business.open}
23
+ handleCustomClick={() => onBusinessClick(business)}
24
+ orderType={orderState?.options?.type}
25
+ navigation={navigation}
26
+ businessHeader={business?.header}
27
+ businessFeatured={business?.featured}
28
+ businessLogo={business?.logo}
29
+ businessReviews={business?.reviews}
30
+ businessDeliveryPrice={business?.delivery_price}
31
+ businessDeliveryTime={business?.delivery_time}
32
+ businessPickupTime={business?.pickup_time}
33
+ businessDistance={business?.distance}
34
+ handleCustomUpdate={handleCustomUpdate}
35
+ style={style}
36
+ />
37
+ ))}
38
+ </>
39
+ )
40
+ }
41
+
42
+ const BusinessSkeletons = () => {
43
+ return (
44
+ <>
45
+ {[...Array(4).keys()].map((item, i) => (
46
+ <Placeholder
47
+ Animation={Fade}
48
+ key={i}
49
+ style={{ marginBottom: 20 }}>
50
+ <View style={{ width: '100%' }}>
51
+ <PlaceholderLine
52
+ height={200}
53
+ style={{ marginBottom: 20, borderRadius: 25 }}
54
+ />
55
+ <View style={{ paddingHorizontal: 10 }}>
56
+ <View
57
+ style={{
58
+ flexDirection: 'row',
59
+ justifyContent: 'space-between',
60
+ }}>
61
+ <PlaceholderLine
62
+ height={25}
63
+ width={40}
64
+ style={{ marginBottom: 10 }}
65
+ />
66
+ <PlaceholderLine
67
+ height={25}
68
+ width={20}
69
+ style={{ marginBottom: 10 }}
70
+ />
71
+ </View>
72
+ <PlaceholderLine
73
+ height={20}
74
+ width={30}
75
+ style={{ marginBottom: 10 }}
76
+ />
77
+ <PlaceholderLine
78
+ height={20}
79
+ width={80}
80
+ style={{ marginBottom: 10 }}
81
+ />
82
+ </View>
83
+ </View>
84
+ </Placeholder>
85
+ ))}
86
+ </>
87
+ )
88
+ }
89
+
90
+ export const PreviousBusinessOrdered = (props: PreviousBusinessOrderedParams) => {
15
91
  const {
16
92
  navigation,
17
- businessesList,
18
- setBusinessLoading,
19
- businessId,
93
+ businesses,
20
94
  onNavigationRedirect,
21
95
  isBusinessesSearchList,
22
- businessLoading
96
+ handleUpdateBusinesses,
23
97
  } = props
24
98
 
25
99
  const [orderState] = useOrder()
100
+ const windowWidth = Dimensions.get('window').width;
26
101
  const onBusinessClick = (business: any) => {
27
- onNavigationRedirect('Business', { store: business.slug })
102
+ onNavigationRedirect('Business', { store: business.slug, logo: business.logo, header: business.header })
28
103
  }
29
- useEffect(() => {
30
- if (businessesList?.loading && businessesList?.businesses?.length === 0) {
31
- setBusinessLoading(true)
32
- } else {
33
- setBusinessLoading(false)
34
- }
35
- }, [businessesList?.loading])
36
104
 
37
105
  const styles = StyleSheet.create({
38
106
  container: {
@@ -40,95 +108,33 @@ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams)
40
108
  },
41
109
  });
42
110
 
43
- const BusinessControllerList = ({ style }: any) => {
44
- return (
45
- <>
46
- {businessesList.businesses?.filter((business: any) => businessId?.includes(business?.id))?.map((business: any, i: number) => (
47
- <BusinessController
48
- key={`${business.id}_` + i}
49
- business={business}
50
- isBusinessOpen={business.open}
51
- handleCustomClick={() => onBusinessClick(business)}
52
- orderType={orderState?.options?.type}
53
- navigation={navigation}
54
- businessHeader={business?.header}
55
- businessFeatured={business?.featured}
56
- businessLogo={business?.logo}
57
- businessReviews={business?.reviews}
58
- businessDeliveryPrice={business?.delivery_price}
59
- businessDeliveryTime={business?.delivery_time}
60
- businessPickupTime={business?.pickup_time}
61
- businessDistance={business?.distance}
62
- style={style}
63
- />
64
- ))}
65
- </>
66
- )
67
- }
68
-
69
- const BusinessSkeletons = () => {
70
- return (
71
- <>
72
- {[...Array(4).keys()].map((item, i) => (
73
- <Placeholder
74
- Animation={Fade}
75
- key={i}
76
- style={{ marginBottom: 20 }}>
77
- <View style={{ width: '100%' }}>
78
- <PlaceholderLine
79
- height={200}
80
- style={{ marginBottom: 20, borderRadius: 25 }}
81
- />
82
- <View style={{ paddingHorizontal: 10 }}>
83
- <View
84
- style={{
85
- flexDirection: 'row',
86
- justifyContent: 'space-between',
87
- }}>
88
- <PlaceholderLine
89
- height={25}
90
- width={40}
91
- style={{ marginBottom: 10 }}
92
- />
93
- <PlaceholderLine
94
- height={25}
95
- width={20}
96
- style={{ marginBottom: 10 }}
97
- />
98
- </View>
99
- <PlaceholderLine
100
- height={20}
101
- width={30}
102
- style={{ marginBottom: 10 }}
103
- />
104
- <PlaceholderLine
105
- height={20}
106
- width={80}
107
- style={{ marginBottom: 10 }}
108
- />
109
- </View>
110
- </View>
111
- </Placeholder>
112
- ))}
113
- </>
114
- )
115
- }
116
-
117
111
  return (
118
112
  <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
119
113
  {isBusinessesSearchList ? (
120
114
  <>
121
- {!businessLoading && (
115
+ {!businesses?.loading && (
122
116
  <BusinessControllerList
123
- style={{ width: 320, marginRight: 20 }}
117
+ style={{ width: windowWidth - 120, marginRight: 20 }}
118
+ onBusinessClick={onBusinessClick}
119
+ orderState={orderState}
120
+ navigation={navigation}
121
+ businesses={businesses}
122
+ handleCustomUpdate={handleUpdateBusinesses}
124
123
  />
125
124
  )}
126
125
  </>
127
126
  ) : (
128
127
  <ListWrapper>
129
- <BusinessControllerList />
130
- {businessesList.loading && (
128
+ {businesses?.loading ? (
131
129
  <BusinessSkeletons />
130
+ ) : (
131
+ <BusinessControllerList
132
+ onBusinessClick={onBusinessClick}
133
+ orderState={orderState}
134
+ navigation={navigation}
135
+ businesses={businesses}
136
+ handleCustomUpdate={handleUpdateBusinesses}
137
+ />
132
138
  )}
133
139
  </ListWrapper>
134
140
  )}
@@ -136,15 +142,3 @@ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams)
136
142
  </ScrollView>
137
143
  )
138
144
  }
139
-
140
- export const PreviousBusinessOrdered = (props) => {
141
- const previousBusinessOrderedController = {
142
- ...props,
143
- UIComponent: PreviousBusinessOrderedUI,
144
- paginationSettings: { initialPage: 1, pageSize: 50, controlType: 'infinity' }
145
- }
146
-
147
- return (
148
- <BusinessListController {...previousBusinessOrderedController} />
149
- )
150
- }
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { ScrollView, StyleSheet } from 'react-native'
2
+ import { ScrollView, StyleSheet, Dimensions } from 'react-native'
3
3
  import {
4
4
  ListWrapper
5
5
  } from './styles'
@@ -7,13 +7,16 @@ import {
7
7
  import { SingleProductCard } from '../../SingleProductCard'
8
8
  import { PreviousProductsOrderedParams } from '../../../types'
9
9
 
10
- export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) => {
10
+ export const PreviousProductsOrdered = (props: PreviousProductsOrderedParams) => {
11
11
  const {
12
12
  products,
13
13
  onProductClick,
14
+ handleUpdateProducts,
14
15
  isBusinessesSearchList
15
16
  } = props
16
17
 
18
+ const windowWidth = Dimensions.get('window').width;
19
+
17
20
  const styles = StyleSheet.create({
18
21
  container: {
19
22
  marginBottom: 0,
@@ -24,15 +27,17 @@ export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) =
24
27
  return (
25
28
  <>
26
29
  {products?.map((product: any) => (
27
- <SingleProductCard
28
- key={product?.id}
29
- isSoldOut={(product.inventoried && !product.quantity)}
30
- product={product}
31
- businessId={product?.business?.id}
32
- onProductClick={onProductClick}
33
- style={style}
34
- productAddedToCartLength={0}
35
- />
30
+ <SingleProductCard
31
+ key={product?.id}
32
+ isProductId
33
+ isSoldOut={(product.inventoried && !product.quantity)}
34
+ product={product}
35
+ businessId={product?.business?.id}
36
+ onProductClick={onProductClick}
37
+ style={style}
38
+ productAddedToCartLength={0}
39
+ handleUpdateProducts={handleUpdateProducts}
40
+ />
36
41
  ))}
37
42
  </>
38
43
  )
@@ -40,7 +45,7 @@ export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) =
40
45
  return (
41
46
  <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
42
47
  {isBusinessesSearchList ? (
43
- <ProductList style={{ width: 320, marginRight: 20 }} />
48
+ <ProductList style={{ width: windowWidth - 80, marginRight: 20 }} />
44
49
  ) : (
45
50
  <ListWrapper isBusinessesSearchList={isBusinessesSearchList}>
46
51
  <ProductList />
@@ -47,6 +47,10 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
47
47
  businessesSearchList,
48
48
  hideOrders,
49
49
  BusinessControllerSkeletons,
50
+ businesses,
51
+ businessPaginationProps,
52
+ handleUpdateProducts,
53
+ handleUpdateBusinesses
50
54
  } = props
51
55
 
52
56
  const theme = useTheme();
@@ -98,11 +102,18 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
98
102
  }
99
103
 
100
104
  const onProductClick = (product: any) => {
101
- if (product?.product_id && product?.category_id && product?.businessId) {
105
+ if (product?.product_id && product?.category_id && product?.businessId &&
106
+ product?.business.slug && product?.business.header && product?.business.logo) {
102
107
  onNavigationRedirect('ProductDetails', {
103
- productId: product?.product_id,
104
- categoryId: product?.category_id,
108
+ isRedirect: 'business',
105
109
  businessId: product?.businessId,
110
+ categoryId: product?.category_id,
111
+ productId: product?.product_id,
112
+ business: {
113
+ store: product?.business.slug,
114
+ header: product?.business.header,
115
+ logo: product?.business.logo,
116
+ }
106
117
  })
107
118
  } else {
108
119
  showToast(ToastType.Error, t('ERROR_FAILED_REDIRECT_IDS', 'Failed to redirect product for ids'))
@@ -134,7 +145,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
134
145
 
135
146
  useFocusEffect(
136
147
  React.useCallback(() => {
137
- loadOrders(false, false, false, true)
148
+ if (!businessesSearchList) {
149
+ loadOrders(false, false, false, true)
150
+ }
138
151
  }, [navigation])
139
152
  )
140
153
 
@@ -182,15 +195,18 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
182
195
  )}
183
196
  {(ordersLength?.activeOrdersLength > 0 || ordersLength?.previousOrdersLength > 0) && (
184
197
  <>
185
- <OptionTitle titleContent={!!titleContent} isBusinessesSearchList={!!businessesSearchList}>
186
- <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={10} >
187
- {titleContent || (activeOrders
188
- ? t('ACTIVE', 'Active')
189
- : preOrders
190
- ? t('PREORDERS', 'Preorders')
191
- : t('PAST', 'Past'))}
192
- </OText>
193
- </OptionTitle>
198
+ {((titleContent && ((isBusiness && businessOrderIds?.length > 0) || isProducts)) || !titleContent) && (
199
+ <OptionTitle titleContent={!!titleContent} isBusinessesSearchList={!!businessesSearchList}>
200
+ <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={10} >
201
+ {titleContent || (activeOrders
202
+ ? t('ACTIVE', 'Active')
203
+ : preOrders
204
+ ? t('PREORDERS', 'Preorders')
205
+ : t('PAST', 'Past'))}
206
+ </OText>
207
+ </OptionTitle>
208
+ )}
209
+
194
210
  {!(ordersLength?.activeOrdersLength === 0 && ordersLength?.previousOrdersLength === 0) &&
195
211
  !loading &&
196
212
  orders.filter((order: any) => orderStatus.includes(order.status)).length === 0 &&
@@ -203,34 +219,33 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
203
219
  )}
204
220
  </>
205
221
  )}
206
- {isBusiness && !!businessesSearchList && businessLoading && (
222
+ {isBusiness && !!businessesSearchList && businesses?.loading && (
207
223
  <ScrollView horizontal>
208
- <BusinessControllerSkeletons />
224
+ <BusinessControllerSkeletons paginationProps={businessPaginationProps} />
209
225
  </ScrollView>
210
226
  )}
211
- {isBusiness && businessOrderIds?.length > 0 && (
227
+ {isBusiness && (
212
228
  <PreviousBusinessOrdered
213
- businessId={businessOrderIds}
214
- businessLoading={businessLoading}
215
- setBusinessLoading={setBusinessLoading}
216
229
  onNavigationRedirect={onNavigationRedirect}
217
- isLoadingOrders={loading}
218
230
  isBusinessesSearchList={!!businessesSearchList}
231
+ businesses={businesses}
232
+ handleUpdateBusinesses={handleUpdateBusinesses}
219
233
  />
220
234
  )}
221
235
 
222
- {isProducts && (
236
+ {isProducts && !loading && (
223
237
  <PreviousProductsOrdered
224
238
  products={products}
225
239
  onProductClick={onProductClick}
240
+ handleUpdateProducts={handleUpdateProducts}
226
241
  isBusinessesSearchList={!!businessesSearchList}
227
242
  />
228
243
  )}
229
244
  {(loading && isProducts) && (
230
245
  <>
231
- {[...Array(4).keys()].map(
246
+ {[...Array(!!businessesSearchList ? 1 : 4).keys()].map(
232
247
  (item, i) => (
233
- <Placeholder key={i} style={{ padding: 5, paddingLeft: 40 }} Animation={Fade}>
248
+ <Placeholder key={i} style={{ padding: 5, paddingLeft: !!businessesSearchList ? 0 : 40, marginBottom: !!businessesSearchList ? 38 : 0 }} Animation={Fade}>
234
249
  <View style={{ flexDirection: 'row' }}>
235
250
  <PlaceholderLine
236
251
  width={24}