ordering-ui-react-native 0.16.12 → 0.16.15

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 (34) hide show
  1. package/package.json +2 -1
  2. package/src/navigators/CheckoutNavigator.tsx +6 -0
  3. package/src/navigators/HomeNavigator.tsx +6 -0
  4. package/src/pages/MultiCheckout.tsx +31 -0
  5. package/src/pages/MultiOrdersDetails.tsx +27 -0
  6. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  7. package/themes/original/index.tsx +6 -0
  8. package/themes/original/src/components/BusinessItemAccordion/index.tsx +3 -2
  9. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +0 -2
  10. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  11. package/themes/original/src/components/BusinessProductsList/index.tsx +9 -26
  12. package/themes/original/src/components/BusinessProductsListing/index.tsx +14 -7
  13. package/themes/original/src/components/BusinessesListing/index.tsx +21 -10
  14. package/themes/original/src/components/Cart/index.tsx +17 -8
  15. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  16. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  17. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  18. package/themes/original/src/components/MultiCheckout/index.tsx +291 -0
  19. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  20. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +370 -0
  21. package/themes/original/src/components/MultiOrdersDetails/index.tsx +250 -0
  22. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  23. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  24. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  25. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +150 -0
  26. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  27. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +51 -0
  28. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  29. package/themes/original/src/components/OrdersOption/index.tsx +102 -28
  30. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  31. package/themes/original/src/components/StripeElementsForm/index.tsx +10 -2
  32. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  33. package/themes/original/src/components/UserDetails/index.tsx +1 -1
  34. package/themes/original/src/types/index.tsx +43 -19
@@ -1,56 +1,144 @@
1
1
  import React, { useState, useEffect } from 'react'
2
2
  import { useLanguage } from 'ordering-components/native';
3
- import { View, StyleSheet, Platform, I18nManager } from 'react-native';
3
+ import { View, StyleSheet, RefreshControl } from 'react-native';
4
4
 
5
5
  import { OrdersOption } from '../OrdersOption'
6
- import { OText } from '../shared'
6
+ import { HeaderTitle, OText } from '../shared'
7
7
  import { ScrollView } from 'react-native-gesture-handler';
8
-
9
- const PIXELS_TO_SCROLL = 1000;
8
+ import { Tab } from './styles'
9
+ import { useTheme } from 'styled-components/native';
10
+ import { Container } from '../../layouts/Container';
10
11
 
11
12
  export const MyOrders = (props: any) => {
12
- const [, t] = useLanguage();
13
- const [loadMore, setLoadMore] = useState(false)
14
-
13
+ const {
14
+ hideOrders,
15
+ businessesSearchList
16
+ } = props
17
+ const [, t] = useLanguage()
18
+ const theme = useTheme()
19
+ const [refreshing] = useState(false);
20
+ const [refreshOrders, setRefreshOrders] = useState(false)
21
+ const [isEmptyBusinesses, setIsEmptyBusinesses] = useState(false)
22
+ const [businessOrderIds, setBusinessOrderIds] = useState([])
15
23
  const [ordersLength, setOrdersLength] = useState({
16
24
  activeOrdersLength: 0,
17
25
  previousOrdersLength: 0,
18
26
  });
27
+ const [selectedOption, setSelectedOption] = useState(!hideOrders ? 'orders' : 'business')
28
+
29
+ const notOrderOptions = ['business', 'products']
30
+ const allEmpty = (ordersLength?.activeOrdersLength === 0 && ordersLength?.previousOrdersLength === 0) || ((isEmptyBusinesses || businessOrderIds?.length === 0) && hideOrders)
31
+ const MyOrdersMenu = [
32
+ { key: 'orders', value: t('ORDERS', 'Orders') },
33
+ { key: 'business', value: t('BUSINESS', 'Business') },
34
+ { key: 'products', value: t('PRODUCTS', 'Products') }
35
+ ]
19
36
 
20
- const handleScroll = ({ nativeEvent }: any) => {
21
- const y = nativeEvent.contentOffset.y
22
- const height = nativeEvent.contentSize.height
37
+ const handleOnRefresh = () => {
38
+ setRefreshOrders(true);
39
+ }
23
40
 
24
- if (y + PIXELS_TO_SCROLL > height ) {
25
- setLoadMore(true)
41
+ const styles = StyleSheet.create({
42
+ container: {
43
+ paddingVertical: 5,
44
+ borderColor: theme.colors.clear,
45
+ backgroundColor: '#FFF'
46
+ },
47
+ featuredStyle: {
48
+ display: 'none',
49
+ },
50
+ tabStyle: {
51
+ marginTop: 10,
52
+ height: 4,
53
+ borderTopStartRadius: 4,
54
+ borderTopEndRadius: 4,
55
+ backgroundColor: theme.colors.textPrimary,
56
+ },
57
+ tabDeactived: {
58
+ marginTop: 10,
59
+ height: 4
26
60
  }
27
- }
61
+ });
28
62
 
29
63
  return (
30
- <ScrollView onScroll={(e: any) => handleScroll(e)}>
31
- <OText
32
- size={20}
33
- mBottom={15}
34
- style={{ marginTop: 25, paddingHorizontal: 40 }}>
35
- {t('MY_ORDERS', 'My Orders')}
36
- </OText>
37
- <View style={{ paddingLeft: 40, paddingRight: 40 }}>
64
+ <Container noPadding refreshControl={
65
+ <RefreshControl
66
+ refreshing={refreshing}
67
+ onRefresh={() => handleOnRefresh()}
68
+ />
69
+ }>
70
+ {!hideOrders && (
71
+ <HeaderTitle text={t('MY_ORDERS', 'My Orders')} />
72
+ )}
73
+ {!allEmpty && (
74
+ <ScrollView
75
+ horizontal
76
+ style={{ ...styles.container, borderBottomWidth: 1 }}
77
+ contentContainerStyle={{ paddingHorizontal: !!businessesSearchList ? 0 : 40 }}
78
+ showsHorizontalScrollIndicator={false}
79
+ scrollEventThrottle={16}
80
+ >
81
+ {MyOrdersMenu.filter(option => !hideOrders || option.key !== 'orders').map(option => (
82
+ <Tab
83
+ key={option.key}
84
+ onPress={() => setSelectedOption(option.key)}
85
+ style={
86
+ {
87
+ borderBottomColor:
88
+ selectedOption === option.key
89
+ ? theme.colors.textNormal
90
+ : theme.colors.border,
91
+ }
92
+ }
93
+ >
94
+ <OText>{option?.value}</OText>
95
+ </Tab>
96
+ ))}
97
+ </ScrollView>
98
+ )}
99
+ {selectedOption === 'orders' && (
100
+ <>
101
+ <View style={{ paddingLeft: 40, paddingRight: 40 }}>
102
+ <OrdersOption
103
+ {...props}
104
+ activeOrders
105
+ ordersLength={ordersLength}
106
+ setOrdersLength={setOrdersLength}
107
+ setRefreshOrders={setRefreshOrders}
108
+ refreshOrders={refreshOrders}
109
+ />
110
+ </View>
111
+ <View style={{ paddingLeft: 40, paddingRight: 40 }}>
112
+ <OrdersOption
113
+ {...props}
114
+ ordersLength={ordersLength}
115
+ setOrdersLength={setOrdersLength}
116
+ setRefreshOrders={setRefreshOrders}
117
+ refreshOrders={refreshOrders}
118
+ />
119
+ </View>
120
+ </>
121
+ )}
122
+ {notOrderOptions.includes(selectedOption) && (
38
123
  <OrdersOption
39
124
  {...props}
125
+ titleContent={t('PREVIOUSLY_ORDERED', 'Previously ordered')}
126
+ hideOrders
127
+ horizontal
128
+ isBusiness={selectedOption === 'business'}
129
+ isProducts={selectedOption === 'products'}
40
130
  activeOrders
41
- ordersLength={ordersLength}
42
- setOrdersLength={setOrdersLength}
43
- loadMoreStatus={loadMore}
44
- setLoadMoreStatus={setLoadMore}
45
- />
46
- </View>
47
- <View style={{ paddingLeft: 40, paddingRight: 40 }}>
48
- <OrdersOption
49
- {...props}
131
+ pastOrders
132
+ preOrders
133
+ businessesSearchList={businessesSearchList}
134
+ setIsEmptyBusinesses={setIsEmptyBusinesses}
135
+ businessOrderIds={businessOrderIds}
136
+ setBusinessOrderIds={setBusinessOrderIds}
50
137
  ordersLength={ordersLength}
51
138
  setOrdersLength={setOrdersLength}
52
139
  />
53
- </View>
54
- </ScrollView>
140
+ )}
141
+ </Container>
142
+
55
143
  )
56
144
  }
@@ -3,4 +3,11 @@ import styled, { css } from 'styled-components/native'
3
3
  export const Wrapper = styled.View`
4
4
  flex: 1;
5
5
  background-color: ${(props: any) => props.theme.colors.white};
6
- `
6
+ `
7
+
8
+ export const Tab = styled.TouchableOpacity`
9
+ padding-horizontal: 10px;
10
+ padding-vertical: 10px;
11
+ justify-content: center;
12
+ border-bottom-width: 1px;
13
+ `
@@ -0,0 +1,150 @@
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
+ } from 'react-native';
12
+ import { PreviousBusinessOrderedParams } from '../../../types';
13
+
14
+ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams) => {
15
+ const {
16
+ navigation,
17
+ businessesList,
18
+ setBusinessLoading,
19
+ businessId,
20
+ onNavigationRedirect,
21
+ isBusinessesSearchList,
22
+ businessLoading
23
+ } = props
24
+
25
+ const [orderState] = useOrder()
26
+ const onBusinessClick = (business: any) => {
27
+ onNavigationRedirect('Business', { store: business.slug })
28
+ }
29
+ useEffect(() => {
30
+ if (businessesList?.loading && businessesList?.businesses?.length === 0) {
31
+ setBusinessLoading(true)
32
+ } else {
33
+ setBusinessLoading(false)
34
+ }
35
+ }, [businessesList?.loading])
36
+
37
+ const styles = StyleSheet.create({
38
+ container: {
39
+ marginBottom: 0,
40
+ },
41
+ });
42
+
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
+ return (
118
+ <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
119
+ {isBusinessesSearchList ? (
120
+ <>
121
+ {!businessLoading && (
122
+ <BusinessControllerList
123
+ style={{ width: 320, marginRight: 20 }}
124
+ />
125
+ )}
126
+ </>
127
+ ) : (
128
+ <ListWrapper>
129
+ <BusinessControllerList />
130
+ {businessesList.loading && (
131
+ <BusinessSkeletons />
132
+ )}
133
+ </ListWrapper>
134
+ )}
135
+
136
+ </ScrollView>
137
+ )
138
+ }
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
+ }
@@ -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,51 @@
1
+ import React from 'react'
2
+ import { ScrollView, StyleSheet } 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 styles = StyleSheet.create({
18
+ container: {
19
+ marginBottom: 0,
20
+ },
21
+ });
22
+
23
+ const ProductList = ({ style }: any) => {
24
+ return (
25
+ <>
26
+ {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
+ />
36
+ ))}
37
+ </>
38
+ )
39
+ }
40
+ return (
41
+ <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
42
+ {isBusinessesSearchList ? (
43
+ <ProductList style={{ width: 320, marginRight: 20 }} />
44
+ ) : (
45
+ <ListWrapper isBusinessesSearchList={isBusinessesSearchList}>
46
+ <ProductList />
47
+ </ListWrapper>
48
+ )}
49
+ </ScrollView>
50
+ )
51
+ }
@@ -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,7 +6,8 @@ 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';
@@ -38,15 +39,23 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
38
39
  setRefreshOrders,
39
40
  reorderState,
40
41
  handleReorder,
41
- handleUpdateOrderList
42
+ handleUpdateOrderList,
43
+ isBusiness,
44
+ isProducts,
45
+ businessOrderIds,
46
+ products,
47
+ businessesSearchList,
48
+ hideOrders,
49
+ BusinessControllerSkeletons,
42
50
  } = props
43
51
 
44
52
  const theme = useTheme();
45
53
 
46
54
  const [, t] = useLanguage()
47
55
  const [{ carts }] = useOrder()
48
- const { showToast } = useToast()
56
+ const [, { showToast }] = useToast()
49
57
  const { loading, error, orders: values } = orderList
58
+ const [businessLoading, setBusinessLoading] = useState(true)
50
59
 
51
60
  const imageFails = activeOrders
52
61
  ? theme.images.general.emptyActiveOrders
@@ -88,28 +97,40 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
88
97
  return objectStatus && objectStatus
89
98
  }
90
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
+
91
112
  useEffect(() => {
92
113
  const _businessId = 'businessId:' + reorderState?.result?.business_id
93
114
  if (reorderState?.error) {
94
- if (reorderState?.result?.business_id) {
95
- _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
96
- navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
97
- }
115
+ if (reorderState?.result?.business_id) {
116
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
117
+ navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
118
+ }
98
119
  }
99
120
  if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
100
- const cartProducts = carts?.[_businessId]?.products
101
- const available = cartProducts.every((product: any) => product.valid === true)
102
- const orderProducts = orders.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
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
103
124
 
104
- if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
105
- onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
106
- } else {
107
- _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
108
- cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
109
- navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
110
- }
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
+ }
111
132
  }
112
- }, [reorderState])
133
+ }, [reorderState])
113
134
 
114
135
  useFocusEffect(
115
136
  React.useCallback(() => {
@@ -134,10 +155,10 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
134
155
  } else if (!preOrders) {
135
156
  setOrdersLength && setOrdersLength({ ...ordersLength, previousOrdersLength: updateOrders?.length })
136
157
  }
137
- }, [orders, activeOrders])
158
+ }, [orders, activeOrders, preOrders])
138
159
 
139
160
  useEffect(() => {
140
- if(refreshOrders){
161
+ if (refreshOrders) {
141
162
  loadOrders(false, false, false, true)
142
163
  setRefreshOrders && setRefreshOrders(false)
143
164
  }
@@ -159,9 +180,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
159
180
 
160
181
  </NoOrdersWrapper>
161
182
  )}
162
- {(ordersLength.activeOrdersLength > 0 || ordersLength.previousOrdersLength > 0) && (
183
+ {(ordersLength?.activeOrdersLength > 0 || ordersLength?.previousOrdersLength > 0) && (
163
184
  <>
164
- <OptionTitle>
185
+ <OptionTitle titleContent={!!titleContent} isBusinessesSearchList={!!businessesSearchList}>
165
186
  <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={10} >
166
187
  {titleContent || (activeOrders
167
188
  ? t('ACTIVE', 'Active')
@@ -170,7 +191,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
170
191
  : t('PAST', 'Past'))}
171
192
  </OText>
172
193
  </OptionTitle>
173
- {!(ordersLength.activeOrdersLength === 0 && ordersLength.previousOrdersLength === 0) &&
194
+ {!(ordersLength?.activeOrdersLength === 0 && ordersLength?.previousOrdersLength === 0) &&
174
195
  !loading &&
175
196
  orders.filter((order: any) => orderStatus.includes(order.status)).length === 0 &&
176
197
  (
@@ -182,7 +203,51 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
182
203
  )}
183
204
  </>
184
205
  )}
185
- {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 && (
186
251
  <>
187
252
  {!activeOrders ? (
188
253
  <Placeholder style={{ marginTop: 30 }} Animation={Fade}>
@@ -213,7 +278,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
213
278
  )}
214
279
  </>
215
280
  )}
216
- {!loading && !error && orders.length > 0 && (
281
+ {!loading && !error && orders.length > 0 && !hideOrders && (
217
282
  preOrders ? (
218
283
  <ActiveOrders
219
284
  orders={orders.filter((order: any) => orderStatus.includes(order.status))}
@@ -253,13 +318,22 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
253
318
  }
254
319
 
255
320
  export const OrdersOption = (props: OrdersOptionParams) => {
321
+ const getAllOrders = props.activeOrders && props.pastOrders && props.preOrders
322
+
256
323
  const MyOrdersProps = {
257
324
  ...props,
258
325
  UIComponent: OrdersOptionUI,
259
- orderStatus: props.preOrders ? [13] : props.activeOrders
260
- ? [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23]
261
- : [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],
262
331
  useDefualtSessionManager: true,
332
+ paginationSettings: {
333
+ initialPage: 1,
334
+ pageSize: getAllOrders ? 30 : 10,
335
+ controlType: 'infinity'
336
+ }
263
337
  }
264
338
 
265
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`
@@ -27,7 +27,8 @@ const StripeElementsFormUI = (props: any) => {
27
27
  paymethod,
28
28
  onCancel,
29
29
  cart,
30
- merchantId
30
+ merchantId,
31
+ businessIds
31
32
  } = props;
32
33
 
33
34
  const theme = useTheme();
@@ -108,7 +109,14 @@ const StripeElementsFormUI = (props: any) => {
108
109
  const { setupIntent, error } = await confirmSetupIntent(requirements, params);
109
110
 
110
111
  if (setupIntent?.status === 'Succeeded') {
111
- stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
112
+ if (businessIds) {
113
+ businessIds.forEach((_businessId: any, index: any) => {
114
+ const _isNewCard = index === 0
115
+ stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId, _isNewCard);
116
+ })
117
+ } else {
118
+ stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
119
+ }
112
120
  }
113
121
 
114
122
  if (error) {
@@ -40,7 +40,7 @@ export const StripeElementsForm = (props: any) => {
40
40
  }
41
41
  }
42
42
 
43
- const stripeTokenHandler = async (tokenId: string, user: any, businessId: string) => {
43
+ const stripeTokenHandler = async (tokenId: string, user: any, businessId: string, isNewCard: any = true) => {
44
44
  try {
45
45
  setState({
46
46
  ...state,
@@ -60,7 +60,7 @@ export const StripeElementsForm = (props: any) => {
60
60
  })
61
61
  })
62
62
  const response = await result.json();
63
- props.onSelectCard && props.onSelectCard(response.result);
63
+ isNewCard && props.onSelectCard && props.onSelectCard(response.result);
64
64
  setState({
65
65
  ...state,
66
66
  loadingAdd: false