ordering-ui-react-native 0.16.7 → 0.16.10

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/themes/original/index.tsx +6 -0
  3. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  4. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  5. package/themes/original/src/components/BusinessController/index.tsx +29 -11
  6. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  7. package/themes/original/src/components/BusinessProductsList/index.tsx +7 -3
  8. package/themes/original/src/components/BusinessProductsListing/index.tsx +3 -0
  9. package/themes/original/src/components/BusinessesListing/index.tsx +25 -3
  10. package/themes/original/src/components/Favorite/index.tsx +91 -0
  11. package/themes/original/src/components/Favorite/styles.tsx +21 -0
  12. package/themes/original/src/components/FavoriteList/index.tsx +268 -0
  13. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  14. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  15. package/themes/original/src/components/LoginForm/index.tsx +6 -2
  16. package/themes/original/src/components/OrdersOption/index.tsx +5 -1
  17. package/themes/original/src/components/PaymentOptionWallet/index.tsx +15 -23
  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
@@ -0,0 +1,280 @@
1
+ import React, { useState } from 'react';
2
+ import moment from 'moment';
3
+ import {
4
+ SingleOrderCard as SingleOrderCardController,
5
+ useUtils,
6
+ useLanguage
7
+ } from 'ordering-components/native';
8
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
9
+ import { useTheme } from 'styled-components/native';
10
+ import { OIcon, OText, OButton } from '../shared';
11
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
12
+ import { SingleOrderCardParams } from '../../types';
13
+
14
+ import {
15
+ Container,
16
+ InnerContainer,
17
+ Logo,
18
+ CardInfoWrapper,
19
+ ContentHeader,
20
+ ButtonWrapper,
21
+ ContentFooter,
22
+ UnreadMessageCounter,
23
+ Price
24
+ } from './styles';
25
+
26
+ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
27
+ const {
28
+ order,
29
+ reorderLoading,
30
+ handleReorder,
31
+ getOrderStatus,
32
+ handleFavoriteOrder,
33
+ onNavigationRedirect,
34
+ pastOrders,
35
+ isMessageView,
36
+ handleClickOrder
37
+ } = props;
38
+
39
+ const [{ parsePrice, optimizeImage }] = useUtils();
40
+ const [, t] = useLanguage();
41
+ const theme = useTheme();
42
+
43
+ const [reorderSelected, setReorderSelected] = useState<number | null>(null);
44
+
45
+ const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12];
46
+
47
+ const styles = StyleSheet.create({
48
+ logo: {
49
+ borderRadius: 8,
50
+ width: 64,
51
+ height: 64
52
+ },
53
+ logoWrapper: {
54
+ overflow: 'hidden',
55
+ backgroundColor: 'white',
56
+ borderRadius: 8,
57
+ shadowColor: '#000000',
58
+ shadowOffset: { width: 1, height: 1 },
59
+ shadowOpacity: 0.1,
60
+ shadowRadius: 1,
61
+ elevation: 3
62
+ },
63
+ buttonText: {
64
+ color: theme.colors.primary,
65
+ fontSize: 10,
66
+ marginLeft: 2,
67
+ marginRight: 2,
68
+ },
69
+ reorderLoading: {
70
+ width: 80,
71
+ height: 40,
72
+ borderRadius: 10,
73
+ },
74
+ reorderbutton: {
75
+ height: 23,
76
+ paddingLeft: 10,
77
+ paddingRight: 10,
78
+ borderRadius: 23,
79
+ shadowOpacity: 0,
80
+ backgroundColor: theme.colors.primaryContrast,
81
+ borderWidth: 0,
82
+ },
83
+ reviewButton: {
84
+ height: 23,
85
+ maxHeight: 23,
86
+ backgroundColor: theme.colors.white,
87
+ alignItems: 'center',
88
+ justifyContent: 'center',
89
+ paddingHorizontal: 10,
90
+ borderRadius: 23,
91
+ borderWidth: 1,
92
+ borderColor: theme.colors.primaryContrast,
93
+ marginRight: 2
94
+ },
95
+ infoText: {
96
+ flexDirection: 'row',
97
+ alignItems: 'center'
98
+ }
99
+ });
100
+
101
+ const handleReorderClick = (id: number) => {
102
+ setReorderSelected(id);
103
+ handleReorder && handleReorder(id);
104
+ };
105
+
106
+ const handleClickOrderReview = (order: any) => {
107
+ if (pastOrders) {
108
+ onNavigationRedirect &&
109
+ onNavigationRedirect('ReviewOrder', {
110
+ order: {
111
+ id: order?.id,
112
+ business_id: order?.business_id,
113
+ logo: order?.business?.logo,
114
+ driver: order?.driver,
115
+ products: order?.products,
116
+ review: order?.review,
117
+ user_review: order?.user_review
118
+ },
119
+ });
120
+ return
121
+ }
122
+ if (isMessageView) {
123
+ handleClickOrder(order?.uuid)
124
+ return
125
+ }
126
+ onNavigationRedirect &&
127
+ onNavigationRedirect('OrderDetails', { orderId: order?.uuid });
128
+ };
129
+
130
+ const handleClickViewOrder = (uuid: string) => {
131
+ onNavigationRedirect &&
132
+ onNavigationRedirect('OrderDetails', { orderId: uuid });
133
+ };
134
+
135
+ const formatDate = (date: string, option?: any) => {
136
+ return option?.utc ? moment.utc(date).format('DD/MM/YY \u2022 h:m a') : moment(date).format('DD/MM/YY \u2022 h:m a');
137
+ };
138
+
139
+ const handleChangeFavorite = () => {
140
+ handleFavoriteOrder && handleFavoriteOrder(!order?.favorite)
141
+ };
142
+
143
+ return (
144
+ <Container
145
+ onPress={() => handleClickViewOrder(order?.uuid)}
146
+ activeOpacity={0.7}
147
+ >
148
+ <InnerContainer>
149
+ {!!order.business?.logo && (
150
+ <Logo style={styles.logoWrapper}>
151
+ <OIcon
152
+ url={optimizeImage(order.business?.logo, 'h_300,c_limit')}
153
+ style={styles.logo}
154
+ />
155
+ </Logo>
156
+ )}
157
+ <CardInfoWrapper>
158
+ <ContentHeader>
159
+ <OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
160
+ {order.business?.name}
161
+ </OText>
162
+ {!!!pastOrders && (
163
+ <>
164
+ {isMessageView ? (
165
+ <>
166
+ {order?.unread_count > 0 && (
167
+ <UnreadMessageCounter>
168
+ <OText size={12} color={theme.colors.primary} lineHeight={18} >
169
+ {order?.unread_count}
170
+ </OText>
171
+ </UnreadMessageCounter>
172
+ )}
173
+ </>
174
+ ) : (
175
+ <Price>
176
+ <OText size={12} lineHeight={18}>
177
+ {parsePrice(order?.summary?.total || order?.total)}
178
+ </OText>
179
+ </Price>
180
+ )}
181
+ </>
182
+ )}
183
+ {!!pastOrders && (
184
+ <ButtonWrapper>
185
+ {allowedOrderStatus.includes(parseInt(order?.status)) &&
186
+ !order.review && (
187
+ <TouchableOpacity
188
+ onPress={() => handleClickOrderReview(order)}
189
+ style={styles.reviewButton}>
190
+ <OText size={10} color={theme.colors.primary} numberOfLines={1}>
191
+ {t('REVIEW', 'Review')}
192
+ </OText>
193
+ </TouchableOpacity>
194
+ )}
195
+ {order.cart && (
196
+ <OButton
197
+ text={t('REORDER', 'Reorder')}
198
+ imgRightSrc={''}
199
+ textStyle={styles.buttonText}
200
+ style={
201
+ reorderLoading && order.id === reorderSelected
202
+ ? styles.reorderLoading
203
+ : styles.reorderbutton
204
+ }
205
+ onClick={() => handleReorderClick(order.id)}
206
+ isLoading={reorderLoading && order.id === reorderSelected}
207
+ />
208
+ )}
209
+ </ButtonWrapper>
210
+ )}
211
+ </ContentHeader>
212
+ <ContentFooter>
213
+ <View style={{ flex: 1 }}>
214
+ <View style={styles.infoText}>
215
+ {!!!pastOrders && (
216
+ <>
217
+ <OText
218
+ size={10}
219
+ space
220
+ color={theme.colors.textSecondary}
221
+ style={{ marginVertical: 3 }}
222
+ lineHeight={15}
223
+ numberOfLines={1}
224
+ >
225
+ {t('ORDER_NO', 'Order No') + '.'}
226
+ </OText>
227
+ <OText
228
+ size={10}
229
+ color={theme.colors.textSecondary}
230
+ style={{ marginVertical: 3 }}
231
+ lineHeight={15}
232
+ numberOfLines={1}
233
+ >
234
+ {order.id + ` \u2022 `}
235
+ </OText>
236
+ </>
237
+ )}
238
+ <OText
239
+ size={10}
240
+ lineHeight={15}
241
+ color={theme.colors.textSecondary}
242
+ style={{ marginVertical: 3 }}
243
+ numberOfLines={1}>
244
+ {order?.delivery_datetime_utc
245
+ ? formatDate(order?.delivery_datetime_utc)
246
+ : formatDate(order?.delivery_datetime, { utc: false })}
247
+ </OText>
248
+ </View>
249
+ <OText
250
+ color={theme.colors.primary}
251
+ size={10}
252
+ lineHeight={15}
253
+ numberOfLines={1}>
254
+ {getOrderStatus(order.status)?.value}
255
+ </OText>
256
+ </View>
257
+ <TouchableOpacity
258
+ onPress={handleChangeFavorite}
259
+ style={{ marginTop: 5 }}
260
+ >
261
+ <IconAntDesign
262
+ name={order?.favorite ? 'heart' : 'hearto'}
263
+ color={theme.colors.danger5}
264
+ size={16}
265
+ />
266
+ </TouchableOpacity>
267
+ </ContentFooter>
268
+ </CardInfoWrapper>
269
+ </InnerContainer>
270
+ </Container>
271
+ )
272
+ }
273
+
274
+ export const SingleOrderCard = (props: any) => {
275
+ const singleOrderCardProps = {
276
+ ...props,
277
+ UIComponent: SingleOrderCardUI
278
+ }
279
+ return <SingleOrderCardController {...singleOrderCardProps} />
280
+ }
@@ -0,0 +1,54 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.TouchableOpacity`
4
+ border-radius: 7.6px;
5
+ box-shadow: 0 1px 2px #0000001A;
6
+ margin-bottom: 10px;
7
+ padding-vertical: 5px;
8
+ `
9
+
10
+ export const InnerContainer = styled.View`
11
+ flex-direction: row;
12
+ width: 100%;
13
+ `
14
+
15
+ export const Logo = styled.View`
16
+ border-radius: 7.6px;
17
+ margin-right: 12px;
18
+ `
19
+
20
+ export const CardInfoWrapper = styled.View`
21
+ flex: 1;
22
+ `
23
+
24
+ export const ContentHeader = styled.View`
25
+ flex-direction: row;
26
+ justify-content: space-between;
27
+ `
28
+
29
+ export const ButtonWrapper = styled.View`
30
+ flex-direction: row;
31
+ align-items: center;
32
+ `
33
+
34
+ export const ContentFooter = styled.View`
35
+ flex-direction: row;
36
+ width: 100%;
37
+ `
38
+
39
+ export const UnreadMessageCounter = styled.View`
40
+ justify-content: center;
41
+ align-items: center;
42
+ margin-left: 10px;
43
+ width: 24px;
44
+ height: 24px;
45
+ border-radius: 7.6px;
46
+ background-color: ${(props: any) => props.theme.colors.primaryContrast};
47
+ `
48
+
49
+ export const Price = styled.View`
50
+ justify-content: space-between;
51
+ align-items: flex-end;
52
+ margin-left: 10px;
53
+ width: 30%;
54
+ `
@@ -4,13 +4,15 @@ import {
4
4
  useConfig,
5
5
  useOrder,
6
6
  useUtils,
7
+ SingleProductCard as SingleProductCardController
7
8
  } from 'ordering-components/native';
8
9
  import { useTheme } from 'styled-components/native';
9
10
  import { SingleProductCardParams } from '../../types';
10
11
  import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper } from './styles';
11
- import { StyleSheet } from 'react-native';
12
+ import { StyleSheet, View, TouchableOpacity } from 'react-native';
12
13
  import { OText, OIcon } from '../shared';
13
14
  import FastImage from 'react-native-fast-image'
15
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
14
16
  import { shape } from '../../utils';
15
17
 
16
18
  function SingleProductCardPropsAreEqual(prevProps : any, nextProps : any) {
@@ -19,13 +21,14 @@ function SingleProductCardPropsAreEqual(prevProps : any, nextProps : any) {
19
21
  prevProps.productAddedToCartLength === nextProps.productAddedToCartLength
20
22
  }
21
23
 
22
- export const SingleProductCard = React.memo((props: SingleProductCardParams) => {
24
+ const SinguleProductCardUI = (props: SingleProductCardParams) => {
23
25
  const {
24
26
  product,
25
27
  isSoldOut,
26
28
  onProductClick,
27
29
  productAddedToCartLength,
28
- style
30
+ style,
31
+ handleFavoriteProduct
29
32
  } = props;
30
33
 
31
34
  const theme = useTheme();
@@ -37,6 +40,11 @@ export const SingleProductCard = React.memo((props: SingleProductCardParams) =>
37
40
  borderColor: theme.colors.border,
38
41
  marginBottom: 28,
39
42
  },
43
+ titleWrapper: {
44
+ flexDirection: 'row',
45
+ alignItems: 'center',
46
+ justifyContent: 'space-between'
47
+ },
40
48
  line18: {
41
49
  lineHeight: 18,
42
50
  },
@@ -102,6 +110,11 @@ export const SingleProductCard = React.memo((props: SingleProductCardParams) =>
102
110
  maxCartProductConfig,
103
111
  maxCartProductInventory,
104
112
  );
113
+
114
+ const handleChangeFavorite = () => {
115
+ handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
116
+ }
117
+
105
118
  return (
106
119
  <CardContainer
107
120
  style={[
@@ -118,14 +131,25 @@ export const SingleProductCard = React.memo((props: SingleProductCardParams) =>
118
131
  </QuantityContainer>
119
132
  )}
120
133
  <CardInfo>
121
- <OText
122
- size={12}
123
- weight={'500'}
124
- numberOfLines={1}
125
- ellipsizeMode="tail"
126
- style={styles.line18}>
127
- {product?.name}
128
- </OText>
134
+ <View style={styles.titleWrapper}>
135
+ <OText
136
+ size={12}
137
+ weight={'500'}
138
+ numberOfLines={1}
139
+ ellipsizeMode="tail"
140
+ style={styles.line18}>
141
+ {product?.name}
142
+ </OText>
143
+ <TouchableOpacity
144
+ onPress={handleChangeFavorite}
145
+ >
146
+ <IconAntDesign
147
+ name={product?.favorite ? 'heart' : 'hearto'}
148
+ color={theme.colors.danger5}
149
+ size={18}
150
+ />
151
+ </TouchableOpacity>
152
+ </View>
129
153
  <PricesContainer>
130
154
  <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
131
155
  {product?.offer_price !== null && product?.in_offer && (
@@ -186,4 +210,12 @@ export const SingleProductCard = React.memo((props: SingleProductCardParams) =>
186
210
  )}
187
211
  </CardContainer>
188
212
  );
213
+ }
214
+
215
+ export const SingleProductCard = React.memo((props: SingleProductCardParams) => {
216
+ const singleProductCardProps = {
217
+ ...props,
218
+ UIComponent: SinguleProductCardUI
219
+ }
220
+ return <SingleProductCardController {...singleProductCardProps} />
189
221
  }, SingleProductCardPropsAreEqual);
@@ -219,6 +219,10 @@ const ProfileListUI = (props: ProfileParams) => {
219
219
  <Ionicons name='md-list-outline' style={styles.messageIconStyle} color={theme.colors.textNormal} />
220
220
  <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('SESSIONS', 'Sessions')}</OText>
221
221
  </ListItem>
222
+ <ListItem onPress={() => navigation.navigate('Favorite')} activeOpacity={0.7}>
223
+ <Ionicons name='heart-outline' style={styles.messageIconStyle} color={theme.colors.textNormal} />
224
+ <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('FAVORITES', 'Favorites')}</OText>
225
+ </ListItem>
222
226
  </Actions>
223
227
 
224
228
  <Actions>
@@ -154,13 +154,17 @@ export interface BusinessesListingParams {
154
154
  franchiseId?: any;
155
155
  businessId?: any;
156
156
  isGuestUser?: any;
157
+ handleUpdateBusinessList?: any;
157
158
  }
158
159
  export interface HighestRatedBusinessesParams {
159
160
  businessesList: { businesses: Array<any>, loading: boolean, error: null | string };
160
161
  onBusinessClick?: void;
161
162
  navigation?: any;
162
163
  isLoading?: boolean;
163
- getBusinesses: (newFetch: boolean) => void
164
+ getBusinesses: (newFetch: boolean) => void,
165
+ favoriteIds?: any,
166
+ setFavoriteIds?: any,
167
+ handleUpdateBusinessList?: any
164
168
  }
165
169
  export interface BusinessTypeFilterParams {
166
170
  businessTypes?: Array<any>;
@@ -189,7 +193,11 @@ export interface BusinessControllerParams {
189
193
  businessDeliveryPrice?: number,
190
194
  businessDeliveryTime?: string,
191
195
  businessPickupTime?: string,
192
- businessDistance?: number
196
+ businessDistance?: number,
197
+ favoriteIds?: number[],
198
+ handleFavoriteBusiness?: any,
199
+ setFavoriteIds?: any;
200
+ handleUpdateBusinessList?: any;
193
201
  }
194
202
  export interface BusinessProductsListingParams {
195
203
  navigation?: any;
@@ -212,6 +220,7 @@ export interface BusinessProductsListingParams {
212
220
  handleChangeCategory: (value: any) => {};
213
221
  setProductLogin?: () => {};
214
222
  updateProductModal?: (value: any) => {};
223
+ handleUpdateProducts?: any;
215
224
  }
216
225
  export interface BusinessBasicInformationParams {
217
226
  navigation?: any;
@@ -259,7 +268,8 @@ export interface BusinessProductsListParams {
259
268
  subcategoriesSelected?: any,
260
269
  onClickCategory?: any,
261
270
  lazyLoadProductsRecommended?: boolean,
262
- isFiltMode?: boolean
271
+ isFiltMode?: boolean,
272
+ handleUpdateProducts?: any
263
273
  }
264
274
  export interface SingleProductCardParams {
265
275
  businessId: any,
@@ -267,7 +277,9 @@ export interface SingleProductCardParams {
267
277
  isSoldOut: boolean;
268
278
  onProductClick: any;
269
279
  productAddedToCartLength: number;
270
- style?: ViewStyle
280
+ style?: ViewStyle,
281
+ handleFavoriteProduct?: any,
282
+ handleUpdateProducts?: any
271
283
  }
272
284
  export interface BusinessInformationParams {
273
285
  navigation?: any,
@@ -319,7 +331,8 @@ export interface OrdersOptionParams {
319
331
  setOpenMessges?: any,
320
332
  loadMoreStatus?: boolean,
321
333
  refreshOrders?: boolean,
322
- setRefreshOrders?: (value : boolean) => void
334
+ setRefreshOrders?: (value : boolean) => void,
335
+ handleUpdateOrderList?: (orderId: number, changes: any) => {}
323
336
  }
324
337
  export interface ActiveOrdersParams {
325
338
  orders?: any,
@@ -332,7 +345,8 @@ export interface ActiveOrdersParams {
332
345
  loadMoreOrders?: () => {},
333
346
  onNavigationRedirect?: (route: string, params?: any) => {},
334
347
  isMessageView?: boolean,
335
- handleClickOrder?: any
348
+ handleClickOrder?: any,
349
+ handleUpdateOrderList?: (orderId: number, changes: any) => {}
336
350
  }
337
351
  export interface PreviousOrdersParams {
338
352
  orders?: any,
@@ -343,6 +357,7 @@ export interface PreviousOrdersParams {
343
357
  loadMoreOrders?: () => {},
344
358
  handleReorder?: (orderId: number) => {},
345
359
  onNavigationRedirect?: (route: string, params?: any) => {}
360
+ handleUpdateOrderList?: (orderId: number, changes: any) => {}
346
361
  }
347
362
  export interface OrderDetailsParams {
348
363
  navigation?: any,
@@ -620,3 +635,29 @@ export interface otpParams {
620
635
  handleLoginOtp: (code : string) => void,
621
636
  setAlertState: any
622
637
  }
638
+
639
+ export interface FavoriteParams {
640
+ favoriteList: any,
641
+ handleUpdateFavoriteList: (id: number, changes: any) => {},
642
+ pagination: any,
643
+ getFavoriteList: (value: number) => {},
644
+ navigation?: any,
645
+ onNavigationRedirect?: (route: string, params?: any) => {},
646
+ reorderState?: any,
647
+ handleReorder?: (orderId: number) => {},
648
+ isOrder?: boolean,
649
+ isProduct?: boolean,
650
+ isBusiness?: boolean
651
+ }
652
+
653
+ export interface SingleOrderCardParams {
654
+ order: any,
655
+ reorderLoading: any,
656
+ handleReorder?: (value: any) => {},
657
+ getOrderStatus: any,
658
+ handleFavoriteOrder?: (value: boolean) => {},
659
+ onNavigationRedirect?: (route: string, params?: any) => {},
660
+ pastOrders: any,
661
+ isMessageView?: any,
662
+ handleClickOrder: (value: any) => {}
663
+ }