ordering-ui-react-native 0.8.3 → 0.8.7

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 (47) hide show
  1. package/package.json +2 -1
  2. package/src/components/OrdersOption/index.tsx +1 -12
  3. package/src/navigators/HomeNavigator.tsx +27 -2
  4. package/src/pages/Checkout.tsx +3 -3
  5. package/src/types/react-native-background-timer/index.d.ts +1 -0
  6. package/themes/business/index.tsx +6 -0
  7. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +167 -240
  8. package/themes/business/src/components/Chat/index.tsx +68 -54
  9. package/themes/business/src/components/DriverMap/index.tsx +86 -116
  10. package/themes/business/src/components/GoogleMap/index.tsx +43 -39
  11. package/themes/business/src/components/MessagesOption/index.tsx +73 -59
  12. package/themes/business/src/components/MessagesOption/styles.tsx +1 -1
  13. package/themes/business/src/components/OrderDetails/index.tsx +104 -92
  14. package/themes/business/src/components/OrderDetails/styles.tsx +6 -2
  15. package/themes/business/src/components/OrderDetailsDelivery/index.tsx +816 -0
  16. package/themes/business/src/components/OrderDetailsDelivery/styles.tsx +144 -0
  17. package/themes/business/src/components/OrderMessage/index.tsx +122 -23
  18. package/themes/business/src/components/OrdersOption/index.tsx +52 -66
  19. package/themes/business/src/components/PreviousMessages/index.tsx +2 -2
  20. package/themes/business/src/components/PreviousOrders/index.tsx +5 -5
  21. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -1
  22. package/themes/business/src/components/StoresList/index.tsx +51 -49
  23. package/themes/business/src/components/UserFormDetails/index.tsx +2 -1
  24. package/themes/business/src/components/UserProfileForm/index.tsx +18 -30
  25. package/themes/business/src/components/UserProfileForm/styles.tsx +0 -2
  26. package/themes/business/src/components/shared/OInput.tsx +3 -2
  27. package/themes/business/src/hooks/useLocation.tsx +7 -3
  28. package/themes/business/src/layouts/SafeAreaContainer.tsx +43 -0
  29. package/themes/business/src/types/index.tsx +8 -0
  30. package/themes/doordash/index.tsx +4 -4
  31. package/themes/doordash/src/components/LoginForm/index.tsx +2 -5
  32. package/themes/doordash/src/components/SingleProductCard/index.tsx +1 -1
  33. package/themes/doordash/src/components/SocialShare/index.tsx +34 -5
  34. package/themes/doordash/src/components/shared/OModal.tsx +1 -6
  35. package/themes/instacart/src/components/AddressForm/index.tsx +2 -60
  36. package/themes/instacart/src/components/AddressList/index.tsx +6 -3
  37. package/themes/instacart/src/components/Home/index.tsx +39 -14
  38. package/themes/instacart/src/components/Home/styles.tsx +7 -0
  39. package/themes/instacart/src/components/LoginForm/index.tsx +3 -3
  40. package/themes/instacart/src/components/LoginForm/styles.tsx +1 -3
  41. package/themes/instacart/src/components/LogoutButton/index.tsx +7 -6
  42. package/themes/instacart/src/components/SocialShare/index.tsx +56 -19
  43. package/themes/instacart/src/components/SocialShare/styles.ts +0 -8
  44. package/themes/instacart/src/components/UserProfileForm/index.tsx +1 -1
  45. package/themes/instacart/src/components/shared/OIcon.tsx +2 -1
  46. package/themes/instacart/src/layouts/Container.tsx +1 -1
  47. package/themes/instacart/src/types/index.tsx +12 -12
@@ -0,0 +1,144 @@
1
+ import styled from 'styled-components/native';
2
+
3
+ export const OrderDetailsContainer = styled.ScrollView`
4
+ flex: 1;
5
+ padding-horizontal: 20px;
6
+ margin-bottom: 50px;
7
+ `;
8
+
9
+ export const Pickup = styled.View`
10
+ padding-vertical: 10px;
11
+ margin-bottom: 20px;
12
+ `;
13
+
14
+ export const NavBack = styled.TouchableOpacity``;
15
+
16
+ export const Header = styled.View`
17
+ flex-direction: row;
18
+ justify-content: space-between;
19
+ padding-top: 10px;
20
+ padding-horizontal: 20px;
21
+ `;
22
+
23
+ export const DriverItem = styled.View`
24
+ padding: 15px;
25
+ justify-content: space-between;
26
+ align-items: center;
27
+ flex-direction: row;
28
+ justify-content: ${(props: any) =>
29
+ props?.justifyContent ? props?.justifyContent : 'flex-start'};
30
+ `;
31
+
32
+ export const Actions = styled.View`
33
+ flex-direction: row;
34
+ justify-content: flex-end;
35
+ `;
36
+
37
+ export const Logo = styled.View`
38
+ margin-right: 20px;
39
+ `;
40
+
41
+ export const OrderContent = styled.View`
42
+ flex: 1;
43
+ `;
44
+
45
+ export const OrderHeader = styled.View`
46
+ padding-vertical: 10px;
47
+ border-bottom-width: 10px;
48
+ border-bottom-color: ${(props: any) => props.theme.colors.inputChat};
49
+ padding-horizontal: 20px;
50
+ `;
51
+
52
+ export const OrderBusiness = styled.View`
53
+ position: relative;
54
+ bottom: 10px;
55
+ padding-vertical: 10px;
56
+ flex-direction: column;
57
+ align-items: flex-start;
58
+ `;
59
+ export const Icons = styled.View`
60
+ margin-top: 10px;
61
+ display: flex;
62
+ flex-direction: row;
63
+ align-items: center;
64
+ `;
65
+
66
+ export const OrderInfo = styled.View`
67
+ padding: 20px;
68
+ flex: 1;
69
+ `;
70
+
71
+ export const OrderData = styled.View`
72
+ flex: 1;
73
+ `;
74
+
75
+ export const OrderStatus = styled.View`
76
+ padding: 20px;
77
+ align-items: center;
78
+ width: 35%;
79
+ flex-wrap: wrap;
80
+ `;
81
+
82
+ export const StaturBar = styled.View``;
83
+
84
+ export const StatusImage = styled.View``;
85
+
86
+ export const SectionTitle = styled.View``;
87
+
88
+ export const OrderCustomer = styled.View`
89
+ padding-vertical: 10px;
90
+ border-bottom-width: 10px;
91
+ border-bottom-color: ${(props: any) => props.theme.colors.inputChat};
92
+ `;
93
+
94
+ export const OrderDriver = styled(OrderCustomer)``;
95
+
96
+ export const Customer = styled.View`
97
+ flex-direction: row;
98
+ align-items: center;
99
+ `;
100
+
101
+ export const CustomerPhoto = styled.View`
102
+ margin-right: 20px;
103
+ `;
104
+
105
+ export const InfoBlock = styled.View`
106
+ width: 70%;
107
+ `;
108
+
109
+ export const HeaderInfo = styled.View`
110
+ flex: 1;
111
+ width: 80%;
112
+ `;
113
+
114
+ export const OrderProducts = styled(OrderCustomer)``;
115
+
116
+ export const Table = styled.View`
117
+ flex-direction: row;
118
+ justify-content: space-between;
119
+ flex: 1;
120
+ align-items: center;
121
+ `;
122
+
123
+ export const OrderBill = styled.View`
124
+ padding-vertical: 10px;
125
+ flex: 1;
126
+ `;
127
+
128
+ export const Total = styled.View`
129
+ border-top-width: 1px;
130
+ border-top-color: ${(props: any) => props.theme.colors.borderTops};
131
+ padding-vertical: 10px;
132
+ `;
133
+
134
+ export const Map = styled.View`
135
+ width: 100%;
136
+ height: 90%;
137
+ margin-top: 20px;
138
+ border-radius: 20px;
139
+ `;
140
+
141
+ export const AssignDriver = styled.View`
142
+ padding-vertical: 10px;
143
+ margin-bottom: 10px;
144
+ `;
@@ -1,14 +1,14 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
3
3
  import { Chat } from '../Chat';
4
- import { View } from 'react-native';
4
+ import { StyleSheet, View } from 'react-native';
5
5
  import {
6
6
  useLanguage,
7
7
  OrderDetails as OrderDetailsController,
8
8
  } from 'ordering-components/native';
9
- import { OrderMessageContainer } from './styles';
9
+ import { useUtils } from 'ordering-components/native';
10
10
 
11
- import { OModal } from '../shared';
11
+ import { OIcon, OIconButton, OText } from '../shared';
12
12
  import { OrderDetailsParams } from '../../types';
13
13
  import { USER_TYPE } from '../../config/constants';
14
14
  import { useTheme } from 'styled-components/native';
@@ -23,6 +23,7 @@ export const OrderMessageUI = (props: OrderDetailsParams) => {
23
23
  setOrders,
24
24
  } = props;
25
25
 
26
+ const [{ optimizeImage }] = useUtils();
26
27
  const theme = useTheme();
27
28
  const [, t] = useLanguage();
28
29
  const [openModalForBusiness, setOpenModalForBusiness] = useState(true);
@@ -32,9 +33,7 @@ export const OrderMessageUI = (props: OrderDetailsParams) => {
32
33
  });
33
34
  const { order, loading } = props.order;
34
35
 
35
- const handleCloseModal = () => {
36
- setOpenModalForBusiness(false);
37
-
36
+ const handleArrowBack = () => {
38
37
  if (order?.unread_count !== undefined) {
39
38
  setOrders &&
40
39
  setOrders((prevOrders: any) => {
@@ -72,6 +71,60 @@ export const OrderMessageUI = (props: OrderDetailsParams) => {
72
71
  }
73
72
  }, [messagesReadList]);
74
73
 
74
+ const styles = StyleSheet.create({
75
+ titleSection: {
76
+ flexDirection: 'row',
77
+ justifyContent: 'space-between',
78
+ alignItems: 'center',
79
+ paddingHorizontal: 20,
80
+ height: 45,
81
+ borderBottomWidth: 2,
82
+ borderBottomColor: '#e6e6e6',
83
+ },
84
+ titleGroups: {
85
+ flexDirection: 'row',
86
+ },
87
+ titleIcons: {
88
+ height: 33,
89
+ width: 33,
90
+ borderRadius: 7.6,
91
+ resizeMode: 'stretch',
92
+ },
93
+ shadow: {
94
+ height: 34,
95
+ width: 34,
96
+ alignItems: 'center',
97
+ justifyContent: 'center',
98
+ marginLeft: 15,
99
+ backgroundColor: theme.colors.clear,
100
+ paddingHorizontal: 3,
101
+ borderRadius: 7.6,
102
+ shadowColor: '#000',
103
+ shadowOffset: {
104
+ width: 0,
105
+ height: 2,
106
+ },
107
+ shadowOpacity: 0.25,
108
+ shadowRadius: 3.84,
109
+ elevation: 3,
110
+ },
111
+ cancelBtn: {
112
+ marginRight: 5,
113
+ zIndex: 10000,
114
+ height: 30,
115
+ width: 20,
116
+ justifyContent: 'flex-end',
117
+ },
118
+ modalText: {
119
+ fontFamily: 'Poppins',
120
+ fontStyle: 'normal',
121
+ fontWeight: '600',
122
+ color: theme.colors.textGray,
123
+ textAlign: 'center',
124
+ zIndex: 10,
125
+ },
126
+ });
127
+
75
128
  return (
76
129
  <>
77
130
  {(!order || Object.keys(order).length === 0 || loading) && (
@@ -166,24 +219,70 @@ export const OrderMessageUI = (props: OrderDetailsParams) => {
166
219
  )}
167
220
 
168
221
  {order && Object.keys(order).length > 0 && !loading && (
169
- <OrderMessageContainer keyboardShouldPersistTaps="handled">
170
- <OModal
171
- open={openModalForBusiness}
222
+ <>
223
+ <View style={styles.titleSection}>
224
+ <View style={styles.titleGroups}>
225
+ <OIconButton
226
+ icon={theme.images.general.arrow_left}
227
+ iconStyle={{ width: 23, height: 23 }}
228
+ borderColor={theme.colors.clear}
229
+ style={styles.cancelBtn}
230
+ onClick={handleArrowBack}
231
+ />
232
+
233
+ <OText size={16} style={styles.modalText} adjustsFontSizeToFit>
234
+ {`${t('INVOICE_ORDER_NO', 'Order No.')} ${order?.id}`}
235
+ </OText>
236
+ </View>
237
+
238
+ <View style={styles.titleGroups}>
239
+ <View style={styles.shadow}>
240
+ {order?.business?.logo ? (
241
+ <OIcon
242
+ url={optimizeImage(order?.business?.logo, 'h_300,c_limit')}
243
+ style={styles.titleIcons}
244
+ />
245
+ ) : (
246
+ <OIcon
247
+ src={theme.images.dummies.businessLogo}
248
+ style={styles.titleIcons}
249
+ />
250
+ )}
251
+ </View>
252
+
253
+ <View style={styles.shadow}>
254
+ <OIcon
255
+ url={optimizeImage(
256
+ order?.customer?.photo ||
257
+ theme?.images?.dummies?.customerPhoto,
258
+ 'h_300,c_limit',
259
+ )}
260
+ style={styles.titleIcons}
261
+ />
262
+ </View>
263
+
264
+ {order?.driver && (
265
+ <View style={styles.shadow}>
266
+ <OIcon
267
+ url={
268
+ optimizeImage(order?.driver?.photo, 'h_300,c_limit') ||
269
+ theme?.images?.dummies?.driverPhoto
270
+ }
271
+ style={styles.titleIcons}
272
+ />
273
+ </View>
274
+ )}
275
+ </View>
276
+ </View>
277
+
278
+ <Chat
279
+ type={openModalForBusiness ? USER_TYPE.BUSINESS : USER_TYPE.DRIVER}
280
+ orderId={order?.id}
281
+ messages={messages}
172
282
  order={order}
173
- title={`${t('INVOICE_ORDER_NO', 'Order No.')} ${order.id}`}
174
- entireModal
175
- onClose={() => handleCloseModal()}>
176
- <Chat
177
- type={
178
- openModalForBusiness ? USER_TYPE.BUSINESS : USER_TYPE.DRIVER
179
- }
180
- orderId={order?.id}
181
- messages={messages}
182
- order={order}
183
- setMessages={setMessages}
184
- />
185
- </OModal>
186
- </OrderMessageContainer>
283
+ setMessages={setMessages}
284
+ />
285
+ </>
187
286
  )}
188
287
  </>
189
288
  );
@@ -12,7 +12,6 @@ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
12
12
  import { OText, OIconButton, OButton } from '../shared';
13
13
  import { PreviousOrders } from '../PreviousOrders';
14
14
  import { NotFoundSource } from '../NotFoundSource';
15
- import { useFocusEffect } from '@react-navigation/native';
16
15
  import { FiltersTab, TabsContainer, Tag } from './styles';
17
16
  import { OrdersOptionParams } from '../../types';
18
17
 
@@ -131,7 +130,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
131
130
  const [tabsFilter, setTabsFilter] = useState(tabs[0].tags);
132
131
  const [tagsFilter, setTagsFilter] = useState(tabs[0].tags);
133
132
  const [loadingTag, setLoadingTag] = useState(false);
134
- const [isLoadingFirstRender, setIsLoadingFirstRender] = useState(false);
135
133
  const [reload, setReload] = useState(false);
136
134
  const [orientation, setOrientation] = useState(
137
135
  Dimensions.get('window').width < Dimensions.get('window').height
@@ -142,16 +140,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
142
140
  parseInt(parseFloat(String(Dimensions.get('window').width)).toFixed(0)),
143
141
  );
144
142
 
145
- useFocusEffect(
146
- React.useCallback(() => {
147
- loadOrders && loadOrders(true, rememberOrderStatus);
148
- setIsLoadingFirstRender(false);
149
- return () => {
150
- setIsLoadingFirstRender(true);
151
- };
152
- }, [navigation, rememberOrderStatus]),
153
- );
154
-
155
143
  const handleChangeTab = (tags: number[]) => {
156
144
  setTabsFilter(tags);
157
145
  setRememberOrderStatus(tags);
@@ -276,7 +264,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
276
264
  paddingRight: 8,
277
265
  },
278
266
  tagsContainer: {
279
- marginBottom: 25,
267
+ marginBottom: 10,
280
268
  },
281
269
  tag: {
282
270
  fontFamily: 'Poppins',
@@ -292,7 +280,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
292
280
  loadButton: {
293
281
  borderRadius: 7.6,
294
282
  height: 44,
295
- marginBottom: 40,
283
+ marginRight: 10,
284
+ marginBottom: 10,
296
285
  marginTop: 5,
297
286
  },
298
287
  loadButtonText: {
@@ -408,11 +397,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
408
397
  />
409
398
  )}
410
399
 
411
- {!reload &&
412
- !error &&
413
- orders.length > 0 &&
414
- !loadingTag &&
415
- !isLoadingFirstRender && (
400
+ <ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1 }}>
401
+ {!reload && !error && orders.length > 0 && !loadingTag && (
416
402
  <PreviousOrders
417
403
  orders={ordersToShow}
418
404
  onNavigationRedirect={onNavigationRedirect}
@@ -420,54 +406,54 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
420
406
  />
421
407
  )}
422
408
 
423
- {(loading || isLoadingFirstRender) && (
424
- <>
425
- <View>
426
- {[...Array(5)].map((item, i) => (
427
- <Placeholder key={i} Animation={Fade}>
428
- <View
429
- style={{
430
- width: '100%',
431
- flexDirection: 'row',
432
- marginBottom: 10,
433
- }}>
434
- <PlaceholderLine
435
- width={orientation === 'Portrait' ? 22 : 11}
436
- height={74}
409
+ {loading && (
410
+ <>
411
+ <View>
412
+ {[...Array(5)].map((item, i) => (
413
+ <Placeholder key={i} Animation={Fade}>
414
+ <View
437
415
  style={{
438
- marginRight: 20,
439
- marginBottom: 20,
440
- borderRadius: 7.6,
441
- }}
442
- />
443
- <Placeholder>
444
- <PlaceholderLine width={30} style={{ marginTop: 5 }} />
445
- <PlaceholderLine width={50} />
446
- <PlaceholderLine width={20} />
447
- </Placeholder>
448
- </View>
449
- </Placeholder>
450
- ))}
451
- </View>
452
- </>
453
- )}
454
-
455
- {!!tagsFilter.length &&
456
- pagination.totalPages &&
457
- !loading &&
458
- !!orders.length &&
459
- !isLoadingFirstRender &&
460
- pagination.currentPage < pagination.totalPages && (
461
- <OButton
462
- onClick={handleLoadMore}
463
- text={t('LOAD_MORE_ORDERS', 'Load more orders')}
464
- imgRightSrc={null}
465
- textStyle={styles.loadButtonText}
466
- style={styles.loadButton}
467
- bgColor={theme.colors.primary}
468
- borderColor={theme.colors.primary}
469
- />
416
+ width: '100%',
417
+ flexDirection: 'row',
418
+ marginBottom: 10,
419
+ }}>
420
+ <PlaceholderLine
421
+ width={orientation === 'Portrait' ? 22 : 11}
422
+ height={74}
423
+ style={{
424
+ marginRight: 20,
425
+ marginBottom: 20,
426
+ borderRadius: 7.6,
427
+ }}
428
+ />
429
+ <Placeholder>
430
+ <PlaceholderLine width={30} style={{ marginTop: 5 }} />
431
+ <PlaceholderLine width={50} />
432
+ <PlaceholderLine width={20} />
433
+ </Placeholder>
434
+ </View>
435
+ </Placeholder>
436
+ ))}
437
+ </View>
438
+ </>
470
439
  )}
440
+
441
+ {!!tagsFilter.length &&
442
+ pagination.totalPages &&
443
+ !loading &&
444
+ !!orders.length &&
445
+ pagination.currentPage < pagination.totalPages && (
446
+ <OButton
447
+ onClick={handleLoadMore}
448
+ text={t('LOAD_MORE_ORDERS', 'Load more orders')}
449
+ imgRightSrc={null}
450
+ textStyle={styles.loadButtonText}
451
+ style={styles.loadButton}
452
+ bgColor={theme.colors.primary}
453
+ borderColor={theme.colors.primary}
454
+ />
455
+ )}
456
+ </ScrollView>
471
457
  </>
472
458
  );
473
459
  };
@@ -483,7 +469,7 @@ export const OrdersOption = (props: OrdersOptionParams) => {
483
469
  useDefualtSessionManager: true,
484
470
  paginationSettings: {
485
471
  initialPage: 1,
486
- pageSize: 6,
472
+ pageSize: 45,
487
473
  controlType: 'infinity',
488
474
  },
489
475
 
@@ -236,7 +236,7 @@ export const PreviousMessages = (props: PreviousMessagesParams) => {
236
236
  });
237
237
 
238
238
  return (
239
- <ScrollView style={{ height: '80%' }}>
239
+ <>
240
240
  {orders?.length > 0 &&
241
241
  orders?.map((order: any) => (
242
242
  <TouchableOpacity
@@ -292,6 +292,6 @@ export const PreviousMessages = (props: PreviousMessagesParams) => {
292
292
  </Card>
293
293
  </TouchableOpacity>
294
294
  ))}
295
- </ScrollView>
295
+ </>
296
296
  );
297
297
  };
@@ -13,9 +13,9 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
13
13
  const [{ parseDate, optimizeImage }] = useUtils();
14
14
  const theme = useTheme();
15
15
 
16
- const handlePressOrder = (uuid: string) => {
16
+ const handlePressOrder = (order: any) => {
17
17
  onNavigationRedirect &&
18
- onNavigationRedirect('OrderDetails', { orderId: uuid });
18
+ onNavigationRedirect('OrderDetails', { order: order });
19
19
  };
20
20
 
21
21
  const styles = StyleSheet.create({
@@ -64,12 +64,12 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
64
64
  });
65
65
 
66
66
  return (
67
- <ScrollView style={{ height: '80%' }}>
67
+ <>
68
68
  {orders?.length > 0 &&
69
69
  orders?.map((order: any) => (
70
70
  <TouchableOpacity
71
71
  key={order.id}
72
- onPress={() => handlePressOrder(order.id)}
72
+ onPress={() => handlePressOrder(order)}
73
73
  style={styles.cardButton}
74
74
  activeOpacity={1}>
75
75
  <Card key={order.id}>
@@ -121,6 +121,6 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
121
121
  </Card>
122
122
  </TouchableOpacity>
123
123
  ))}
124
- </ScrollView>
124
+ </>
125
125
  );
126
126
  };
@@ -129,7 +129,11 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
129
129
  }}>
130
130
  <View style={{ flexDirection: 'row' }}>
131
131
  <OText size={12} color={theme.colors.textGray}>
132
- {parsePrice(product.total || product.price)}
132
+ {parsePrice(
133
+ typeof product.total === 'number'
134
+ ? product.total
135
+ : product.price,
136
+ )}
133
137
  </OText>
134
138
 
135
139
  {(productInfo().ingredients.length > 0 ||