ordering-ui-react-native 0.16.8 → 0.16.11

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 (24) hide show
  1. package/package.json +1 -1
  2. package/src/components/StripeMethodForm/index.tsx +1 -2
  3. package/themes/original/index.tsx +6 -0
  4. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  5. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  6. package/themes/original/src/components/BusinessController/index.tsx +29 -11
  7. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  8. package/themes/original/src/components/BusinessProductsList/index.tsx +7 -3
  9. package/themes/original/src/components/BusinessProductsListing/index.tsx +3 -0
  10. package/themes/original/src/components/BusinessesListing/index.tsx +25 -3
  11. package/themes/original/src/components/Favorite/index.tsx +91 -0
  12. package/themes/original/src/components/Favorite/styles.tsx +21 -0
  13. package/themes/original/src/components/FavoriteList/index.tsx +268 -0
  14. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  15. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  16. package/themes/original/src/components/LoginForm/index.tsx +6 -2
  17. package/themes/original/src/components/OrdersOption/index.tsx +5 -1
  18. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  19. package/themes/original/src/components/SignupForm/index.tsx +6 -2
  20. package/themes/original/src/components/SingleOrderCard/index.tsx +280 -0
  21. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  22. package/themes/original/src/components/SingleProductCard/index.tsx +43 -11
  23. package/themes/original/src/components/UserProfile/index.tsx +4 -0
  24. package/themes/original/src/types/index.tsx +47 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.16.8",
3
+ "version": "0.16.11",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -102,7 +102,7 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
102
102
  shippingMethods: [
103
103
  {
104
104
  amount: cart?.balance?.toString() ?? cart?.total?.toString?.(),
105
- identifier: 'DPS',
105
+ identifier: 'standard',
106
106
  label: 'Courier',
107
107
  detail: 'Delivery',
108
108
  type: 'final',
@@ -125,7 +125,6 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
125
125
  last4: paymentMethod.Card.last4
126
126
  }
127
127
  })
128
- onCancel()
129
128
  }
130
129
  }
131
130
 
@@ -15,6 +15,8 @@ import { BusinessProductsListing } from './src/components/BusinessProductsListin
15
15
  import { CartContent } from './src/components/CartContent';
16
16
  import { BusinessCart } from './src/components/BusinessCart';
17
17
  import { Checkout } from './src/components/Checkout';
18
+ import { Favorite } from './src/components/Favorite';
19
+ import { FavoriteList } from './src/components/FavoriteList';
18
20
  import { FloatingButton } from './src/components/FloatingButton';
19
21
  import { ForgotPasswordForm } from './src/components/ForgotPasswordForm';
20
22
  import { MomentOption } from './src/components/MomentOption';
@@ -58,6 +60,7 @@ import { CartStoresListing } from './src/components/CartStoresListing';
58
60
  import { PaymentOptionsWebView } from '../../src/components/PaymentOptionsWebView';
59
61
  import { GoogleMap } from './src/components/GoogleMap';
60
62
  import { SingleProductCard } from './src/components/SingleProductCard';
63
+ import { SingleOrderCard } from './src/components/SingleOrderCard';
61
64
  import { UpsellingRedirect } from './src/components/BusinessProductsListing/UpsellingRedirect';
62
65
  import { ProductItemAccordion } from './src/components/ProductItemAccordion';
63
66
  import { BusinessItemAccordion } from './src/components/BusinessItemAccordion';
@@ -164,6 +167,8 @@ export {
164
167
  CartContent,
165
168
  BusinessCart,
166
169
  Checkout,
170
+ Favorite,
171
+ FavoriteList,
167
172
  ForgotPasswordForm,
168
173
  MomentOption,
169
174
  OrdersOption,
@@ -209,6 +214,7 @@ export {
209
214
  PaymentOptionsWebView,
210
215
  GoogleMap,
211
216
  SingleProductCard,
217
+ SingleOrderCard,
212
218
  UpsellingRedirect,
213
219
  ProductItemAccordion,
214
220
  BusinessItemAccordion,
@@ -1,23 +1,13 @@
1
1
  import React from 'react';
2
- import { useLanguage, useUtils, useConfig } from 'ordering-components/native';
3
- import { OButton, OIcon, OText } from '../shared';
2
+ import { useConfig } from 'ordering-components/native';
4
3
  import {
5
- ActiveOrdersContainer,
6
- Card,
7
- Map,
8
- Information,
9
- Logo,
10
- OrderInformation,
11
- BusinessInformation,
12
- Price,
13
- UnreadMessageCounter,
14
- LoadMore
4
+ ActiveOrdersContainer
15
5
  } from './styles';
16
- import { View, StyleSheet } from 'react-native';
6
+ import { View } from 'react-native';
17
7
 
18
8
  import { ActiveOrdersParams } from '../../types';
19
- import moment from 'moment';
20
9
  import { useTheme } from 'styled-components/native';
10
+ import { SingleOrderCard } from '../SingleOrderCard';
21
11
 
22
12
  export const ActiveOrders = (props: ActiveOrdersParams) => {
23
13
  const {
@@ -27,111 +17,27 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
27
17
  loadMoreOrders,
28
18
  getOrderStatus,
29
19
  isMessageView,
30
- handleClickOrder
20
+ handleClickOrder,
21
+ handleUpdateOrderList
31
22
  } = props;
32
23
 
33
24
  const theme = useTheme();
34
25
  const [{ configs }] = useConfig();
35
- const [, t] = useLanguage();
36
- const [{ parseDate, parsePrice, optimizeImage }] = useUtils();
37
-
38
- const formatDate = (date: string, option?: any) => {
39
- return option?.utc ? moment.utc(date).format('DD/MM/YY \u2022 h:m a') : moment(date).format('DD/MM/YY \u2022 h:m a');
40
- };
41
-
42
- const handleClickCard = (uuid: string) => {
43
- if (isMessageView) {
44
- handleClickOrder(uuid)
45
- return
46
- }
47
- onNavigationRedirect &&
48
- onNavigationRedirect('OrderDetails', { orderId: uuid });
49
- };
50
-
51
- const Order = ({ order, index }: { order: any; index: number }) => (
52
- <React.Fragment>
53
- <Card
54
- isMiniCard={configs?.google_maps_api_key?.value}
55
- onPress={() => handleClickCard(order?.uuid)}
56
- activeOpacity={0.7}>
57
- {/* {!!(configs?.google_maps_api_key?.value) && (
58
- <Map>
59
- <OIcon
60
- url={getGoogleMapImage(order?.business?.location, configs?.google_maps_api_key?.value)}
61
- height={100}
62
- width={320}
63
- style={{resizeMode: 'cover', borderTopRightRadius: 24, borderTopLeftRadius: 24}}
64
- />
65
- </Map>
66
- )} */}
67
- <Information>
68
- {!!order.business?.logo && (
69
- <Logo>
70
- <OIcon
71
- url={optimizeImage(order.business?.logo, 'h_300,c_limit')}
72
- style={styles.logo}
73
- />
74
- </Logo>
75
- )}
76
- <OrderInformation>
77
- <BusinessInformation>
78
- <OText size={12} lineHeight={18} weight={600} numberOfLines={1} ellipsizeMode={'tail'}>
79
- {order.business?.name}
80
- </OText>
81
- <View style={styles.orderNumber}>
82
- <OText size={10} space color={theme.colors.textSecondary}>
83
- {t('ORDER_NO', 'Order No') + '.'}
84
- </OText>
85
- <OText size={10} color={theme.colors.textSecondary}>
86
- {order.id + ` \u2022 `}
87
- </OText>
88
- <OText size={10} color={theme.colors.textSecondary}>
89
- {order?.delivery_datetime_utc
90
- ? formatDate(order?.delivery_datetime_utc)
91
- : formatDate(order?.delivery_datetime, { utc: false })}
92
- </OText>
93
- </View>
94
- {/* {order?.status !== 0 && ( */}
95
- <OText
96
- color={theme.colors.primary}
97
- size={10}
98
- lineHeight={15}
99
- weight={400}
100
- numberOfLines={2}>
101
- {getOrderStatus(order.status)?.value}
102
- </OText>
103
- {/* )} */}
104
- </BusinessInformation>
105
- {isMessageView ? (
106
- <>
107
- {order?.unread_count > 0 && (
108
- <UnreadMessageCounter>
109
- <OText size={12} color={theme.colors.primary} lineHeight={18} >
110
- {order?.unread_count}
111
- </OText>
112
- </UnreadMessageCounter>
113
- )}
114
- </>
115
- ) : (
116
- <Price>
117
- <OText size={12} lineHeight={18}>
118
- {parsePrice(order?.summary?.total || order?.total)}
119
- </OText>
120
- </Price>
121
- )}
122
-
123
- </OrderInformation>
124
- </Information>
125
- </Card >
126
- </React.Fragment >
127
- );
128
26
 
129
27
  return (
130
28
  <>
131
29
  <ActiveOrdersContainer isMiniCards={configs?.google_maps_api_key?.value}>
132
30
  {orders.length > 0 &&
133
31
  orders.map((order: any, index: any) => (
134
- <Order key={index} order={order} index={index} />
32
+ <SingleOrderCard
33
+ key={index}
34
+ order={order}
35
+ handleClickOrder={handleClickOrder}
36
+ isMessageView={isMessageView}
37
+ getOrderStatus={getOrderStatus}
38
+ onNavigationRedirect={onNavigationRedirect}
39
+ handleUpdateOrderList={handleUpdateOrderList}
40
+ />
135
41
  ))}
136
42
  </ActiveOrdersContainer>
137
43
  <View
@@ -144,26 +50,3 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
144
50
  </>
145
51
  );
146
52
  };
147
-
148
- const styles = StyleSheet.create({
149
- logo: {
150
- borderRadius: 7.6,
151
- width: 64,
152
- height: 64,
153
- },
154
- orderNumber: {
155
- flexDirection: 'row',
156
- marginVertical: 3,
157
- },
158
- loadOrders: {
159
- justifyContent: 'center',
160
- alignItems: 'center',
161
- minWidth: 230,
162
- },
163
- loadMoreButton: {
164
- width: '100%',
165
- marginLeft: 'auto',
166
- marginRight: 'auto',
167
- borderRadius: 7.6
168
- },
169
- });
@@ -3,57 +3,3 @@ import styled from 'styled-components/native'
3
3
  export const ActiveOrdersContainer = styled.View`
4
4
  margin-bottom: 20px;
5
5
  `
6
-
7
- export const Card = styled.TouchableOpacity`
8
- `
9
-
10
- export const Map = styled.View`
11
- flex: 1;
12
- height: 125px;
13
- margin-bottom: 10px;
14
- `
15
-
16
- export const Information = styled.View`
17
- flex-direction: row;
18
- height: 100px;
19
- align-items: center;
20
- padding-vertical: 5px;
21
- `
22
-
23
- export const Logo = styled.View`
24
- border-radius: 7.6px;
25
- box-shadow: 0 1px 2px #0000001A;
26
- `
27
-
28
- export const OrderInformation = styled.View`
29
- flex-direction: row;
30
- justify-content: space-between;
31
- flex: 1;
32
- padding-left: 14px;
33
- `
34
-
35
- export const BusinessInformation = styled.View`
36
- flex-basis: 65%;
37
- `
38
-
39
- export const Price = styled.View`
40
- justify-content: space-between;
41
- align-items: flex-end;
42
- margin-left: 10px;
43
- width: 30%;
44
- `
45
-
46
- export const UnreadMessageCounter = styled.View`
47
- justify-content: center;
48
- align-items: center;
49
- margin-left: 10px;
50
- width: 24px;
51
- height: 24px;
52
- border-radius: 7.6px;
53
- background-color: ${(props: any) => props.theme.colors.primaryContrast};
54
- `
55
- export const LoadMore = styled.View`
56
- flex-direction: row;
57
- justify-content: center;
58
- margin-top: 10px;
59
- `
@@ -7,7 +7,7 @@ import {
7
7
  useConfig
8
8
  } from 'ordering-components/native';
9
9
  import { OIcon, OText } from '../shared';
10
- import { StyleSheet, View } from 'react-native';
10
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
11
11
  import { BusinessControllerParams } from '../../types';
12
12
  import { convertHoursToMinutes, shape } from '../../utils';
13
13
  import {
@@ -20,10 +20,12 @@ import {
20
20
  BusinessState,
21
21
  BusinessLogo,
22
22
  Reviews,
23
- RibbonBox
23
+ RibbonBox,
24
+ ReviewAndFavorite
24
25
  } from './styles';
25
26
  import { useTheme } from 'styled-components/native';
26
27
  import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome5';
28
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
27
29
  import FastImage from 'react-native-fast-image'
28
30
 
29
31
  export const BusinessControllerUI = (props: BusinessControllerParams) => {
@@ -40,7 +42,8 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
40
42
  businessDeliveryPrice,
41
43
  businessDeliveryTime,
42
44
  businessPickupTime,
43
- businessDistance
45
+ businessDistance,
46
+ handleFavoriteBusiness
44
47
  } = props;
45
48
  const [{ parsePrice, parseDistance, parseNumber, optimizeImage }] = useUtils();
46
49
  const [orderState] = useOrder();
@@ -120,6 +123,10 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
120
123
  }
121
124
  }
122
125
 
126
+ const handleChangeFavorite = () => {
127
+ handleFavoriteBusiness && handleFavoriteBusiness(!business?.favorite)
128
+ }
129
+
123
130
  return (
124
131
  <Card activeOpacity={1} onPress={() => handleBusinessClick(business)} style={style}>
125
132
  {business?.ribbon?.enabled && (
@@ -179,14 +186,25 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
179
186
  resizeMode={FastImage.resizeMode.cover}
180
187
  />
181
188
  </BusinessLogo>
182
- {(businessReviews?.reviews?.total > 0 ?? business?.reviews?.total > 0) && (
183
- <Reviews>
184
- <OIcon src={theme.images.general.star} width={12} style={styles.starIcon} />
185
- <OText size={10} style={{ lineHeight: 15 }}>
186
- {parseNumber(businessReviews?.reviews?.total ?? business?.reviews?.total, { separator: '.' })}
187
- </OText>
188
- </Reviews>
189
- )}
189
+ <ReviewAndFavorite>
190
+ {(businessReviews?.reviews?.total > 0 ?? business?.reviews?.total > 0) && (
191
+ <Reviews>
192
+ <OIcon src={theme.images.general.star} width={12} style={styles.starIcon} />
193
+ <OText size={10} style={{ lineHeight: 15 }}>
194
+ {parseNumber(businessReviews?.reviews?.total ?? business?.reviews?.total, { separator: '.' })}
195
+ </OText>
196
+ </Reviews>
197
+ )}
198
+ <TouchableOpacity
199
+ onPress={handleChangeFavorite}
200
+ >
201
+ <IconAntDesign
202
+ name={business?.favorite ? 'heart' : 'hearto'}
203
+ color={theme.colors.danger5}
204
+ size={18}
205
+ />
206
+ </TouchableOpacity>
207
+ </ReviewAndFavorite>
190
208
  </BusinessInfo>
191
209
  <OText
192
210
  size={12}
@@ -49,6 +49,11 @@ export const BusinessLogo = styled.View`
49
49
 
50
50
  `
51
51
 
52
+ export const ReviewAndFavorite = styled.View`
53
+ flex-direction: row;
54
+ align-items: center;
55
+ `
56
+
52
57
  export const Reviews = styled.View`
53
58
  flex-direction: row;
54
59
  align-items: center;
@@ -33,7 +33,8 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
33
33
  subcategoriesSelected,
34
34
  onClickCategory,
35
35
  lazyLoadProductsRecommended,
36
- isFiltMode
36
+ isFiltMode,
37
+ handleUpdateProducts
37
38
  } = props;
38
39
 
39
40
  const [, t] = useLanguage();
@@ -125,6 +126,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
125
126
  businessId={businessId}
126
127
  onProductClick={() => onProductClick(product)}
127
128
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
129
+ handleUpdateProducts={handleUpdateProducts}
128
130
  />
129
131
  ))
130
132
  }
@@ -147,6 +149,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
147
149
  product={product}
148
150
  businessId={businessId}
149
151
  onProductClick={onProductClick}
152
+ handleUpdateProducts={handleUpdateProducts}
150
153
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
151
154
  />
152
155
  ),
@@ -212,7 +215,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
212
215
  {category?.description?.length > 80 && (
213
216
  <OButton
214
217
  style={{ height: 15, paddingRight: 0, paddingLeft: 0, borderWidth: 0 }}
215
- text={t('SEE_MORE', 'See more')}
218
+ text={t('VIEW_MORE', 'View more')}
216
219
  parentStyle={{ padding: 0 }}
217
220
  onClick={() => setOpenDescription(category)}
218
221
  bgColor='transparent'
@@ -238,6 +241,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
238
241
  businessId={businessId}
239
242
  product={product}
240
243
  onProductClick={onProductClick}
244
+ handleUpdateProducts={handleUpdateProducts}
241
245
  productAddedToCartLength={currentCart?.products?.reduce((productsLength: number, Cproduct: any) => { return productsLength + (Cproduct?.id === product?.id ? Cproduct?.quantity : 0) }, 0)}
242
246
  />
243
247
  ))}
@@ -327,7 +331,7 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
327
331
  style={{ borderRadius: 7.6 }}
328
332
  />
329
333
  )}
330
- <OText mBottom={40}>{openDescription?.description}</OText>
334
+ <OText mBottom={60}>{openDescription?.description}</OText>
331
335
  </ScrollView>
332
336
  </OModal>
333
337
  </ProductsContainer>
@@ -53,6 +53,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
53
53
  setAlertState,
54
54
  multiRemoveProducts,
55
55
  getNextProducts,
56
+ handleUpdateProducts
56
57
  } = props
57
58
 
58
59
  const theme = useTheme();
@@ -353,6 +354,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
353
354
  currentCart={currentCart}
354
355
  setSubcategoriesSelected={setSubcategoriesSelected}
355
356
  onClickCategory={handleChangeCategory}
357
+ handleUpdateProducts={handleUpdateProducts}
356
358
  />
357
359
  </WrapContent>
358
360
  </>
@@ -374,6 +376,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
374
376
  categoryState={categoryState}
375
377
  isBusinessLoading={loading}
376
378
  errorQuantityProducts={errorQuantityProducts}
379
+ handleUpdateProducts={handleUpdateProducts}
377
380
  />
378
381
  </WrapContent>
379
382
  </>
@@ -60,7 +60,8 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
60
60
  paginationProps,
61
61
  handleChangeSearch,
62
62
  businessId,
63
- isGuestUser
63
+ isGuestUser,
64
+ handleUpdateBusinessList
64
65
  } = props;
65
66
  const theme = useTheme();
66
67
  const isFocused = useIsFocused();
@@ -122,6 +123,8 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
122
123
  Number(configs?.max_days_preorder?.value) > 0
123
124
  const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
124
125
  const timerId = useRef<any>(false)
126
+ const [favoriteIds, setFavoriteIds] = useState<any>([])
127
+
125
128
  // const panResponder = useRef(
126
129
  // PanResponder.create({
127
130
  // onMoveShouldSetPanResponder: (e, gestureState) => {
@@ -217,6 +220,17 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
217
220
  }, [navigation])
218
221
  )
219
222
 
223
+ useEffect(() => {
224
+ if (!businessesList?.businesses?.length) return
225
+ const ids = [...favoriteIds]
226
+ businessesList.businesses.forEach((business: any) => {
227
+ if (business?.favorite) {
228
+ ids.push(business?.id)
229
+ }
230
+ })
231
+ setFavoriteIds([...new Set(ids)])
232
+ }, [businessesList?.businesses?.length])
233
+
220
234
  return (
221
235
  <ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
222
236
  refreshControl={
@@ -227,7 +241,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
227
241
  }
228
242
  >
229
243
  <HeaderWrapper
230
- source={theme.images.backgrounds.business_list_header}
244
+ source={theme.images.general.homeHero}
231
245
  style={{ paddingTop: top + 20 }}>
232
246
  {!auth && (
233
247
  <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
@@ -355,7 +369,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
355
369
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
356
370
  {
357
371
  !businessId && !props.franchiseId && (
358
- <HighestRatedBusinesses onBusinessClick={handleBusinessClick} navigation={navigation} />
372
+ <HighestRatedBusinesses
373
+ onBusinessClick={handleBusinessClick}
374
+ navigation={navigation}
375
+ favoriteIds={favoriteIds}
376
+ setFavoriteIds={setFavoriteIds}
377
+ />
359
378
  )
360
379
  }
361
380
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
@@ -394,6 +413,9 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
394
413
  businessDeliveryTime={business?.delivery_time}
395
414
  businessPickupTime={business?.pickup_time}
396
415
  businessDistance={business?.distance}
416
+ handleUpdateBusinessList={handleUpdateBusinessList}
417
+ favoriteIds={favoriteIds}
418
+ setFavoriteIds={setFavoriteIds}
397
419
  />
398
420
  )
399
421
  )}
@@ -0,0 +1,91 @@
1
+ import React, { useState } from 'react'
2
+ import { useLanguage, useOrder } from 'ordering-components/native'
3
+ import { useTheme } from 'styled-components/native'
4
+ import { FavoriteList } from '../FavoriteList'
5
+ import NavBar from '../NavBar'
6
+ import { OText } from '../shared'
7
+
8
+ import {
9
+ TabContainer,
10
+ Tab,
11
+ Container
12
+ } from './styles'
13
+
14
+ export const Favorite = (props: any) => {
15
+ const {
16
+ navigation
17
+ } = props
18
+ const [, t] = useLanguage()
19
+ const theme = useTheme()
20
+ const [orderState] = useOrder()
21
+ const [tabSelected, setTabSelected] = useState('businesses')
22
+
23
+ const tabList = [
24
+ { key: 'businesses', name: t('BUSINESSES', 'Businesses') },
25
+ { key: 'products', name: t('PRODUCTS', 'Products') },
26
+ { key: 'orders', name: t('ORDERS', 'Orders') }
27
+ ]
28
+
29
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
30
+
31
+ const onRedirect = (route: string, params?: any) => {
32
+ navigation.navigate(route, params)
33
+ }
34
+
35
+ return (
36
+ <Container>
37
+ <NavBar
38
+ title={t('FAVORITE', 'Favorite')}
39
+ titleAlign={'center'}
40
+ onActionLeft={goToBack}
41
+ showCall={false}
42
+ paddingTop={10}
43
+ btnStyle={{ paddingLeft: 0 }}
44
+ />
45
+ <TabContainer>
46
+ {tabList.map((menu, i) => (
47
+ <Tab
48
+ key={i}
49
+ active={menu.key === tabSelected}
50
+ onPress={() => setTabSelected(menu.key)}
51
+ >
52
+ <OText
53
+ color={menu.key === tabSelected ? theme.colors.textNormal : theme.colors.disabled}
54
+ size={14}
55
+ weight={menu.key === tabSelected ? '500' : '400'}
56
+ style={{ marginBottom: 12 }}
57
+ >
58
+ {menu.name}
59
+ </OText>
60
+ </Tab>
61
+ ))}
62
+ </TabContainer>
63
+ {tabSelected === 'businesses' && (
64
+ <FavoriteList
65
+ navigation={navigation}
66
+ onNavigationRedirect={onRedirect}
67
+ isBusiness
68
+ favoriteURL='favorite_businesses'
69
+ originalURL='business'
70
+ location={`${orderState.options?.address?.location?.lat},${orderState.options?.address?.location?.lng}`}
71
+ propsToFetch={['id', 'name', 'header', 'logo', 'location', 'address', 'ribbon', 'timezone', 'schedule', 'open', 'delivery_price', 'distance', 'delivery_time', 'pickup_time', 'reviews', 'featured', 'offers', 'food', 'laundry', 'alcohol', 'groceries', 'slug']}
72
+ />
73
+ )}
74
+ {tabSelected === 'products' && (
75
+ <FavoriteList
76
+ favoriteURL='favorite_products'
77
+ originalURL='products'
78
+ isProduct
79
+ />
80
+ )}
81
+ {tabSelected === 'orders' && (
82
+ <FavoriteList
83
+ onNavigationRedirect={onRedirect}
84
+ favoriteURL='favorite_orders'
85
+ originalURL='orders'
86
+ isOrder
87
+ />
88
+ )}
89
+ </Container>
90
+ )
91
+ }
@@ -0,0 +1,21 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const TabContainer = styled.View`
4
+ flex-direction: row;
5
+ border-bottom-color: ${(props: any) => props.theme.colors.border};
6
+ border-bottom-width: 1px;
7
+ margin-bottom: 25px;
8
+ `
9
+
10
+ export const Tab = styled.TouchableOpacity`
11
+ margin-right: 32px;
12
+ ${(props: any) => props.active && css`
13
+ border-bottom-color: ${(props: any) => props.theme.colors.textNormal};
14
+ border-bottom-width: 1px;
15
+ `}
16
+ `
17
+
18
+ export const Container = styled.View`
19
+ padding-horizontal: 40px;
20
+ padding-bottom: 20px;
21
+ `