ordering-ui-react-native 0.17.69 → 0.17.70

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.17.69",
3
+ "version": "0.17.70",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -11,19 +11,17 @@ import {
11
11
  } from 'react-native';
12
12
  import { useTheme } from 'styled-components/native';
13
13
  import SelectDropdown from 'react-native-select-dropdown'
14
- import { useLanguage, useSession } from 'ordering-components/native';
15
- import { Content, Timer, TimeField, Header, Action, Comments, CommentsButtonGroup } from './styles';
16
- import { FloatingButton } from '../FloatingButton';
14
+ import { useLanguage } from 'ordering-components/native';
15
+ import { Content, Timer, TimeField, Header, Comments, CommentsButtonGroup, TopActions } from './styles';
17
16
  import { OText, OButton, OTextarea, OIconButton } from '../shared';
18
17
  import { AcceptOrRejectOrderParams } from '../../types';
19
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
20
18
 
21
19
  import { orderCommentList } from '../../../../../src/utils'
22
20
 
23
21
  export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
24
22
  const {
23
+ isPage,
25
24
  customerCellphone,
26
- loading,
27
25
  action,
28
26
  handleUpdateOrder,
29
27
  actions,
@@ -35,7 +33,6 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
35
33
  } = props;
36
34
 
37
35
  const [, t] = useLanguage();
38
- const [{ user }] = useSession();
39
36
  const theme = useTheme();
40
37
  const scrollViewRef = useRef<any>(null);
41
38
  const viewRef = useRef<any>(null);
@@ -46,11 +43,9 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
46
43
  const [time, setTime] = useState('');
47
44
  const [comments, setComments] = useState('');
48
45
  const [rejectReason, setRejectReason] = useState(null);
49
- const [isKeyboardShow, setIsKeyboardShow] = useState(false);
50
- const { top, bottom } = useSafeAreaInsets()
46
+ const [keyboardState, setKeyboardState] = useState({ show: false, height: 0 });
51
47
 
52
48
  const isDriverApp = appTitle?.key === 'DELIVERY_APP'
53
-
54
49
  const orderCommentsList = orderCommentList(action)
55
50
 
56
51
  let codeNumberPhone, numberPhone, numberToShow;
@@ -93,6 +88,28 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
93
88
  alignItems: 'center',
94
89
  paddingHorizontal: 10
95
90
  },
91
+ parent: {
92
+ flex: 1,
93
+ backgroundColor: theme.colors.backgroundPage,
94
+ },
95
+ upper: {
96
+ flex: 1,
97
+ zIndex: 1001,
98
+ paddingTop: isPage ? 30 : 80,
99
+ marginBottom: 10,
100
+ backgroundColor: theme.colors.backgroundPage
101
+ },
102
+ bottomParent: {
103
+ justifyContent: "center",
104
+ paddingHorizontal: 30,
105
+ alignItems: "center",
106
+ width: '100%',
107
+ height: 45,
108
+ },
109
+ bottom: {
110
+ textAlignVertical: "center",
111
+ textAlign: "center",
112
+ }
96
113
  })
97
114
 
98
115
  const handleFocus = () => {
@@ -101,25 +118,6 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
101
118
  });
102
119
  };
103
120
 
104
- useEffect(() => {
105
- const keyboardDidShowListener = Keyboard.addListener(
106
- 'keyboardDidShow',
107
- () => {
108
- setIsKeyboardShow(true);
109
- },
110
- );
111
- const keyboardDidHideListener = Keyboard.addListener(
112
- 'keyboardDidHide',
113
- () => {
114
- setIsKeyboardShow(false);
115
- },
116
- );
117
- return () => {
118
- keyboardDidShowListener.remove();
119
- keyboardDidHideListener.remove();
120
- };
121
- }, []);
122
-
123
121
  if (!notShowCustomerPhone) {
124
122
  if (phoneNumber) {
125
123
  codeNumberPhone = phoneNumber.slice(0, 3);
@@ -172,15 +170,15 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
172
170
  };
173
171
 
174
172
  const openTimerIOnput = () => {
175
- const isFocus = timerRef.current.isFocused();
173
+ const isFocus = timerRef.current?.isFocused();
176
174
  if (isFocus) {
177
- timerRef.current.blur();
175
+ timerRef.current?.blur();
178
176
  }
179
177
 
180
178
  };
181
179
 
182
180
  const openTextTareaOInput = () => {
183
- const isFocus = textTareaRef.current.isFocused();
181
+ const isFocus = textTareaRef.current?.isFocused();
184
182
  if (isFocus && textTareaRef?.current) {
185
183
  textTareaRef.current.blur();
186
184
  }
@@ -281,227 +279,250 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
281
279
  }
282
280
  }, [timerRef?.current])
283
281
 
282
+ useEffect(() => {
283
+ const keyboardDidShowListener =
284
+ Keyboard.addListener('keyboardDidShow', (e) => setKeyboardState({
285
+ show: true,
286
+ height: e.endCoordinates.height > 100
287
+ ? Platform.OS == 'ios' ? e.endCoordinates.height : 0 : 0
288
+ }))
289
+ const keyboardDidHideListener =
290
+ Keyboard.addListener('keyboardDidHide', () => setKeyboardState({ show: false, height: 0 }))
291
+ return () => {
292
+ keyboardDidShowListener.remove()
293
+ keyboardDidHideListener.remove()
294
+ }
295
+ }, [])
296
+
284
297
  return (
285
- <KeyboardAvoidingView
286
- enabled
287
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
288
- style={{ flex: 1, paddingHorizontal: 30, paddingVertical: 30, marginTop: top, marginBottom: bottom, justifyContent: 'space-between' }}>
289
- <View>
290
- <OIconButton
291
- icon={theme.images.general.arrow_left}
292
- borderColor={theme.colors.clear}
293
- iconStyle={{ width: 20, height: 20 }}
294
- style={{
295
- maxWidth: 40,
296
- height: 35,
297
- justifyContent: 'flex-end',
298
- marginBottom: 30,
299
- }}
300
- onClick={() => handleArrowBack()}
301
- />
302
- <OText
303
- size={20}
304
- color={theme.colors.textGray}
305
- style={{
306
- fontFamily: 'Poppins',
307
- fontStyle: 'normal',
308
- }}
309
- weight="600">
310
- {titleOrder}
311
- </OText>
312
- </View>
313
- <Content showsVerticalScrollIndicator={false} ref={scrollViewRef}>
314
- <Header>
315
- {action === 'reject' && (
316
- <>
317
- {!notShowCustomerPhone && (
298
+ <KeyboardAvoidingView style={{ flex: 1 }}>
299
+ <View style={styles.parent}>
300
+ <View style={styles.upper}>
301
+ <TopActions>
302
+ <OIconButton
303
+ icon={theme.images.general.arrow_left}
304
+ borderColor={theme.colors.clear}
305
+ iconStyle={{ width: 20, height: 20 }}
306
+ style={{
307
+ maxWidth: 40,
308
+ height: 35,
309
+ justifyContent: 'flex-end',
310
+ marginBottom: 10,
311
+ }}
312
+ onClick={() => handleArrowBack()}
313
+ />
314
+ <OText
315
+ size={20}
316
+ color={theme.colors.textGray}
317
+ style={{
318
+ fontFamily: 'Poppins',
319
+ fontStyle: 'normal',
320
+ marginBottom: 10,
321
+ }}
322
+ weight="600">
323
+ {titleOrder}
324
+ </OText>
325
+ </TopActions>
326
+ <Content showsVerticalScrollIndicator={false} ref={scrollViewRef}>
327
+ <Header>
328
+ {action === 'reject' && (
318
329
  <>
330
+ {!notShowCustomerPhone && (
331
+ <>
332
+ <OText
333
+ size={15}
334
+ color={theme.colors.textGray}
335
+ style={{ marginTop: 10 }}>
336
+ {t(
337
+ 'CALL_YOUR_CUSTOMER_TO_RESOLVE_THE_ISSUE_AS_POLITELY_AS_POSSIBLE',
338
+ 'Call your customer to resolve the issue as politely as possible',
339
+ )}
340
+ </OText>
341
+
342
+ {numberToShow ? (
343
+ <OButton
344
+ bgColor="transparent"
345
+ borderColor={theme.colors.primary}
346
+ textStyle={{
347
+ color: theme.colors.primary,
348
+ fontSize: 20,
349
+ }}
350
+ style={{
351
+ borderRadius: 10,
352
+ marginVertical: 20,
353
+ }}
354
+ imgLeftStyle={{
355
+ resizeMode: 'contain',
356
+ left: 20,
357
+ position: 'absolute',
358
+ }}
359
+ imgLeftSrc={theme.images.general.cellphone}
360
+ text={numberToShow}
361
+ onClick={() =>
362
+ Linking.openURL(`tel:${customerCellphone}`)
363
+ }
364
+ />
365
+ ) : (
366
+ <OButton
367
+ bgColor="transparent"
368
+ borderColor={theme.colors.primary}
369
+ textStyle={{
370
+ color: theme.colors.primary,
371
+ fontSize: 15,
372
+ }}
373
+ style={{
374
+ borderRadius: 10,
375
+ marginVertical: 20,
376
+ }}
377
+ imgLeftStyle={{
378
+ resizeMode: 'contain',
379
+ left: 20,
380
+ position: 'absolute',
381
+ }}
382
+ isDisabled={true}
383
+ imgLeftSrc={theme.images.general.cellphone}
384
+ text={t('NOT_NUMBER', "There's not phonenumber.")}
385
+ onClick={() =>
386
+ Linking.openURL(`tel:${customerCellphone}`)
387
+ }
388
+ />
389
+ )}
390
+ </>
391
+ )}
392
+
319
393
  <OText
320
394
  size={15}
321
395
  color={theme.colors.textGray}
322
- style={{ marginTop: 10 }}>
396
+ style={{ marginBottom: 10 }}>
323
397
  {t(
324
- 'CALL_YOUR_CUSTOMER_TO_RESOLVE_THE_ISSUE_AS_POLITELY_AS_POSSIBLE',
325
- 'Call your customer to resolve the issue as politely as possible',
398
+ 'MARK_THE_ORDER_AS_REJECTED',
399
+ 'Mark the order as rejected',
326
400
  )}
327
401
  </OText>
328
402
 
329
- {numberToShow ? (
330
- <OButton
331
- bgColor="transparent"
332
- borderColor={theme.colors.primary}
333
- textStyle={{
334
- color: theme.colors.primary,
335
- fontSize: 20,
336
- }}
337
- style={{
338
- borderRadius: 10,
339
- marginVertical: 20,
340
- }}
341
- imgLeftStyle={{
342
- resizeMode: 'contain',
343
- left: 20,
344
- position: 'absolute',
345
- }}
346
- imgLeftSrc={theme.images.general.cellphone}
347
- text={numberToShow}
348
- onClick={() =>
349
- Linking.openURL(`tel:${customerCellphone}`)
350
- }
351
- />
352
- ) : (
353
- <OButton
354
- bgColor="transparent"
355
- borderColor={theme.colors.primary}
356
- textStyle={{
357
- color: theme.colors.primary,
358
- fontSize: 15,
359
- }}
360
- style={{
361
- borderRadius: 10,
362
- marginVertical: 20,
363
- }}
364
- imgLeftStyle={{
365
- resizeMode: 'contain',
366
- left: 20,
367
- position: 'absolute',
368
- }}
369
- isDisabled={true}
370
- imgLeftSrc={theme.images.general.cellphone}
371
- text={t('NOT_NUMBER', "There's not phonenumber.")}
372
- onClick={() =>
373
- Linking.openURL(`tel:${customerCellphone}`)
374
- }
375
- />
376
- )}
403
+ <OText>
404
+ <OText style={{ fontWeight: '600' }}>
405
+ {t('NOTE', 'Note')}
406
+ {': '}
407
+ </OText>
408
+
409
+ <OText size={15} color={theme.colors.textGray}>
410
+ {t(
411
+ 'YOUR_CUSTOMER_WILL_RECEIVE_A_NOTIFICATION_ABOUT_THIS_ACTIONS',
412
+ 'Your customer will receive a notification about this actions',
413
+ )}
414
+ </OText>
415
+ </OText>
377
416
  </>
378
417
  )}
418
+ </Header>
379
419
 
380
- <OText
381
- size={15}
382
- color={theme.colors.textGray}
383
- style={{ marginBottom: 10 }}>
384
- {t(
385
- 'MARK_THE_ORDER_AS_REJECTED',
386
- 'Mark the order as rejected',
387
- )}
388
- </OText>
389
-
390
- <OText>
391
- <OText style={{ fontWeight: '600' }}>
392
- {t('NOTE', 'Note')}
393
- {': '}
394
- </OText>
395
-
396
- <OText size={15} color={theme.colors.textGray}>
397
- {t(
398
- 'YOUR_CUSTOMER_WILL_RECEIVE_A_NOTIFICATION_ABOUT_THIS_ACTIONS',
399
- 'Your customer will receive a notification about this actions',
400
- )}
401
- </OText>
402
- </OText>
403
- </>
404
- )}
405
- </Header>
406
-
407
- {action === 'accept' && (
408
- <View style={{ height: 400, justifyContent: 'center' }}>
409
- <Timer onPress={() => openTimerIOnput()}>
410
- <OText weight="600" style={{ textAlign: 'center' }} size={55}>
411
- {hour}
412
- </OText>
413
- {hour.length > 0 && <OText size={55}>:</OText>}
414
- <OText weight="600" style={{ textAlign: 'center' }} size={55}>
415
- {min}
416
- </OText>
417
- </Timer>
418
- </View>
419
- )}
420
- <TimeField
421
- ref={timerRef}
422
- keyboardType="numeric"
423
- value={time}
424
- placeholder={'00:00'}
425
- onChangeText={handleTime}
426
- onPressOut={() => handleFixTime()}
427
- editable={true}
428
- selectionColor={theme.colors.primary}
429
- placeholderTextColor={theme.colors.textGray}
430
- color={theme.colors.textGray}
431
- onEndEditing={handleFixTime}
432
- onSubmitEditing={() => handleAcceptOrReject()}
433
- onBlur={() => actions && action === 'accept' && timerRef?.current?.focus?.()}
434
- />
435
-
436
- {orderCommentsList && isDriverApp && (
437
- <CommentsButtonGroup>
438
- <SelectDropdown
439
- defaultButtonText={t('REJECT_REASONS_OPTIONS', 'Reject reasons')}
440
- data={orderCommentsList?.list}
441
- onSelect={(selectedItem) => {
442
- setRejectReason(selectedItem?.value)
443
- }}
444
- buttonTextAfterSelection={(selectedItem) => selectedItem.content}
445
- rowTextForSelection={(item) => item.key}
446
- buttonStyle={styles.selectOption}
447
- buttonTextStyle={styles.buttonTextStyle}
448
- renderDropdownIcon={isOpened => {
449
- return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
450
- }}
451
- dropdownStyle={styles.dropdownStyle}
452
- dropdownOverlayColor='transparent'
453
- rowStyle={styles.rowStyle}
454
- renderCustomizedRowChild={(item) => {
455
- return (
456
- <View
457
- style={{
458
- flexDirection: 'row',
459
- alignItems: 'center'
460
- }}
461
- >
462
- <View>
463
- <OText
464
- size={14}
465
- color={'#748194'}
466
- style={{ textTransform: 'capitalize' }}
467
- >
468
- {item?.content}
469
- </OText>
470
- </View>
471
- </View>
472
- );
473
- }}
474
- />
475
- </CommentsButtonGroup>
476
- )}
477
-
478
- {showTextArea && (
479
- <Comments ref={viewRef}>
480
- <OTextarea
481
- textTareaRef={textTareaRef}
482
- autoFocus
483
- onFocus={handleFocus}
484
- placeholder={t(
485
- 'PLEASE_TYPE_YOUR_COMMENTS_IN_HERE',
486
- 'Please type your comments in here',
487
- )}
488
- value={comments}
489
- onChange={setComments}
420
+ {action === 'accept' && (
421
+ <View style={{ height: 400, justifyContent: 'center' }}>
422
+ <Timer onPress={() => openTimerIOnput()}>
423
+ <OText weight="600" style={{ textAlign: 'center' }} size={55}>
424
+ {hour}
425
+ </OText>
426
+ {hour.length > 0 && <OText size={55}>:</OText>}
427
+ <OText weight="600" style={{ textAlign: 'center' }} size={55}>
428
+ {min}
429
+ </OText>
430
+ </Timer>
431
+ </View>
432
+ )}
433
+ <TimeField
434
+ ref={timerRef}
435
+ keyboardType="numeric"
436
+ value={time}
437
+ placeholder={'00:00'}
438
+ onChangeText={handleTime}
439
+ onPressOut={() => handleFixTime()}
440
+ editable={true}
441
+ selectionColor={theme.colors.primary}
442
+ placeholderTextColor={theme.colors.textGray}
443
+ color={theme.colors.textGray}
444
+ onEndEditing={handleFixTime}
445
+ onSubmitEditing={() => handleAcceptOrReject()}
446
+ onBlur={() => actions && action === 'accept' && timerRef?.current?.focus?.()}
490
447
  />
491
- </Comments>
492
- )}
493
- </Content>
494
-
495
- <Action>
496
- <FloatingButton
497
- firstButtonClick={() => {
498
- handleAcceptOrReject();
448
+
449
+ {orderCommentsList && isDriverApp && (
450
+ <CommentsButtonGroup>
451
+ <SelectDropdown
452
+ defaultButtonText={t('REJECT_REASONS_OPTIONS', 'Reject reasons')}
453
+ data={orderCommentsList?.list}
454
+ onSelect={(selectedItem) => {
455
+ setRejectReason(selectedItem?.value)
456
+ }}
457
+ buttonTextAfterSelection={(selectedItem) => selectedItem.content}
458
+ rowTextForSelection={(item) => item.key}
459
+ buttonStyle={styles.selectOption}
460
+ buttonTextStyle={styles.buttonTextStyle}
461
+ renderDropdownIcon={isOpened => {
462
+ return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
463
+ }}
464
+ dropdownStyle={styles.dropdownStyle}
465
+ dropdownOverlayColor='transparent'
466
+ rowStyle={styles.rowStyle}
467
+ renderCustomizedRowChild={(item) => {
468
+ return (
469
+ <View
470
+ style={{
471
+ flexDirection: 'row',
472
+ alignItems: 'center'
473
+ }}
474
+ >
475
+ <View>
476
+ <OText
477
+ size={14}
478
+ color={'#748194'}
479
+ style={{ textTransform: 'capitalize' }}
480
+ >
481
+ {item?.content}
482
+ </OText>
483
+ </View>
484
+ </View>
485
+ );
486
+ }}
487
+ />
488
+ </CommentsButtonGroup>
489
+ )}
490
+
491
+ {showTextArea && (
492
+ <Comments ref={viewRef}>
493
+ <OTextarea
494
+ textTareaRef={textTareaRef}
495
+ autoFocus
496
+ onFocus={handleFocus}
497
+ placeholder={t(
498
+ 'PLEASE_TYPE_YOUR_COMMENTS_IN_HERE',
499
+ 'Please type your comments in here',
500
+ )}
501
+ value={comments}
502
+ onChange={setComments}
503
+ />
504
+ </Comments>
505
+ )}
506
+ </Content>
507
+ </View>
508
+ <View
509
+ style={{
510
+ ...styles.bottomParent,
511
+ marginBottom: (keyboardState.height === 0) ? isPage ? 0 : 30 : keyboardState.height - (isPage ? 20 : -10)
499
512
  }}
500
- btnText={buttonText}
501
- color={action === 'accept' ? theme.colors.green : theme.colors.red}
502
- widthButton={'100%'}
503
- />
504
- </Action>
513
+ >
514
+ <OButton
515
+ text={buttonText}
516
+ bgColor={action === 'accept' ? theme.colors.green : theme.colors.red}
517
+ borderColor={action === 'accept' ? theme.colors.green : theme.colors.red}
518
+ imgRightSrc={null}
519
+ style={{ borderRadius: 7, height: 45 }}
520
+ parentStyle={{ width: '100%' }}
521
+ textStyle={{color: '#FFF', fontSize: 18 }}
522
+ onClick={() => handleAcceptOrReject()}
523
+ />
524
+ </View>
525
+ </View>
505
526
  </KeyboardAvoidingView>
506
527
  );
507
528
  };
@@ -1,10 +1,14 @@
1
1
  import styled from 'styled-components/native';
2
2
 
3
3
  export const Content = styled.ScrollView`
4
- background-color: ${(props: any) => props.theme.colors.white};
5
- margin-bottom: 30px;
4
+ padding-horizontal: 30px;
6
5
  `;
7
6
 
7
+ export const TopActions = styled.View`
8
+ padding-horizontal: 30px;
9
+ padding-bottom: 10px;
10
+ `
11
+
8
12
  export const Timer = styled.TouchableOpacity`
9
13
  padding: 40px;
10
14
  justify-content: center;
@@ -29,8 +33,6 @@ export const TimeField = styled.TextInput`
29
33
 
30
34
  export const Header = styled.View``;
31
35
 
32
- export const Action = styled.View``;
33
-
34
36
  export const Comments = styled.View`
35
37
  margin-top: 20px;
36
38
  padding-bottom: 40px;
@@ -55,7 +55,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
55
55
  ordersGroup,
56
56
  setOrdersGroup,
57
57
  orderStatus,
58
- ordersGroupedFormatted,
58
+ ordersFormatted,
59
59
  loadOrders,
60
60
  loadMoreOrders,
61
61
  onNavigationRedirect,
@@ -98,7 +98,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
98
98
  const [slaSettingTime, setSlaSettingTime] = useState(6000)
99
99
  const [currentDeliveryType, setCurrentDeliveryType] = useState('Delivery')
100
100
  const [search, setSearch] = useState(defaultSearchList)
101
- const [selectedTabStatus, setSelectedTabStatus] = useState([])
101
+ const [selectedTabStatus, setSelectedTabStatus] = useState<any>([])
102
102
  const [hour, setHour] = useState(0)
103
103
  const [minute, setMinute] = useState(0)
104
104
  const [openedSelect, setOpenedSelect] = useState('')
@@ -585,9 +585,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
585
585
  currentTabSelected !== 'logisticOrders' &&
586
586
  (
587
587
  <PreviousOrders
588
- orders={currentOrdersGroup?.orders}
588
+ orders={ordersFormatted}
589
589
  navigation={props.navigation}
590
- ordersGrouped={ordersGroupedFormatted}
591
590
  onNavigationRedirect={onNavigationRedirect}
592
591
  getOrderStatus={getOrderStatus}
593
592
  handleClickOrder={handleClickOrder}
@@ -840,7 +839,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
840
839
  </ScrollView>
841
840
  </FiltersTab>
842
841
  <DeliveryStatusWrapper>
843
- {selectedTabStatus && selectedTabStatus.length > 0 && selectedTabStatus.map((item, i) => (
842
+ {selectedTabStatus && selectedTabStatus.length > 0 && selectedTabStatus.map((item: any, i: number) => (
844
843
  <StatusBlock
845
844
  key={i}
846
845
  item={item}
@@ -67,7 +67,7 @@ export const OrdersGroupedItem = (props: any) => {
67
67
  resizeMode={FastImage.resizeMode.cover}
68
68
  />
69
69
  </View>
70
- <View style={{ flex: 1, marginLeft: 10, flexDirection: 'column' }}>
70
+ <View style={{ flex: 1, marginLeft: 5, flexDirection: 'column' }}>
71
71
  <View>
72
72
  <OText numberOfLines={1} style={styles.title}>
73
73
  {t('GROUP_NRO', 'Group No.')}{groupId}
@@ -15,7 +15,6 @@ import { GoogleMap } from '../GoogleMap';
15
15
  export const PreviousOrders = (props: any) => {
16
16
  const {
17
17
  orders,
18
- ordersGrouped,
19
18
  onNavigationRedirect,
20
19
  getOrderStatus,
21
20
  handleClickOrder,
@@ -186,153 +185,154 @@ export const PreviousOrders = (props: any) => {
186
185
 
187
186
  return (
188
187
  <>
189
- {ordersGrouped && Object.keys(ordersGrouped)?.length > 0 && (
190
- <View style={{ marginBottom: 10 }}>
191
- {Object.keys(ordersGrouped).map(k => (
192
- <OrdersGroupedItem
193
- key={k}
194
- groupId={k}
195
- orders={ordersGrouped[k]}
196
- >
197
- {ordersGrouped[k]?.length > 0 &&
198
- ordersGrouped[k]
199
- ?.filter((order: any) => hash[order?.id] ? false : (hash[order?.id] = true))
200
- ?.map((_order: any) => {
201
- const order = _order?.isLogistic && !_order?.order_group && isLogisticOrder ? _order?.order : _order
202
- return (
203
- <OrdersList key={order.id} order={order} _order={_order} hideBtns />
188
+ {orders && orders?.length > 0 && orders.map((_order: any) => {
189
+ const order = !Array.isArray(_order) && (_order?.isLogistic && !_order?.order_group && isLogisticOrder ? _order?.order : _order)
190
+ const _ordersGrouped = Array.isArray(_order) && Object.fromEntries(_order)
191
+ return (
192
+ _ordersGrouped ? (
193
+ <View key={_order[0]} style={{ marginBottom: 10 }}>
194
+ {Object.keys(_ordersGrouped).map((k, idx) => (
195
+ <OrdersGroupedItem
196
+ key={`${k}_${idx}`}
197
+ groupId={k}
198
+ orders={_ordersGrouped[k]}
199
+ >
200
+ {_ordersGrouped[k]?.length > 0 &&
201
+ _ordersGrouped[k]
202
+ ?.filter((order: any) => hash[order?.id] ? false : (hash[order?.id] = true))
203
+ ?.map((_order: any) => {
204
+ const order_ = _order?.isLogistic && !_order?.order_group && isLogisticOrder ? _order?.order : _order
205
+ return (
206
+ <OrdersList key={order_.id} order={order_} _order={_order} hideBtns />
207
+ )
208
+ }
204
209
  )
205
210
  }
206
- )
207
- }
208
- {ordersGrouped[k][0]?.status === 0 && (
209
- <AcceptOrRejectOrderStyle>
210
- <OButton
211
- text={t('REJECT_ALL', 'Reject all')}
212
- bgColor={theme.colors.danger100}
213
- borderColor={theme.colors.danger100}
214
- imgRightSrc={null}
215
- style={{ borderRadius: 7, height: 40 }}
216
- parentStyle={{ width: '45%' }}
217
- textStyle={{ color: theme.colors.danger500, fontSize: 12 }}
218
- onClick={() => ordersGroupAction('', '', {
219
- action: 'reject',
220
- order: ordersGrouped[k][0],
221
- ids: ordersGrouped[k].map((o: any) => o.id)
222
- })}
223
- />
224
- <OButton
225
- text={t('ACCEPT_ALL', 'Accept all')}
226
- bgColor={theme.colors.success100}
227
- borderColor={theme.colors.success100}
228
- imgRightSrc={null}
229
- style={{ borderRadius: 7, height: 40 }}
230
- parentStyle={{ width: '45%' }}
231
- textStyle={{ color: theme.colors.success500, fontSize: 12 }}
232
- onClick={() => ordersGroupAction('', '', {
233
- action: 'accept',
234
- order: ordersGrouped[k][0],
235
- ids: ordersGrouped[k].map((o: any) => o.id)
236
- })}
237
- />
238
- </AcceptOrRejectOrderStyle>
239
- )}
240
- <View>
241
- {ordersGrouped[k][0]?.status === 7 && (
242
- <OButton
243
- text={t('READY_FOR_PICKUP', 'Ready for pickup')}
244
- bgColor={theme.colors.primaryLight}
245
- borderColor={theme.colors.primaryLight}
246
- imgRightSrc={null}
247
- style={{ borderRadius: 7, height: 40 }}
248
- parentStyle={{ width: '100%' }}
249
- textStyle={{ color: theme.colors.primary, fontSize: 12 }}
250
- onClick={() => handleChangeOrderStatus(
251
- 4,
252
- ordersGrouped[k].map((o: any) => o.id),
211
+ {_ordersGrouped[k][0]?.status === 0 && (
212
+ <AcceptOrRejectOrderStyle>
213
+ <OButton
214
+ text={t('REJECT_ALL', 'Reject all')}
215
+ bgColor={theme.colors.danger100}
216
+ borderColor={theme.colors.danger100}
217
+ imgRightSrc={null}
218
+ style={{ borderRadius: 7, height: 40 }}
219
+ parentStyle={{ width: '45%' }}
220
+ textStyle={{ color: theme.colors.danger500, fontSize: 12 }}
221
+ onClick={() => onNavigationRedirect('AcceptOrRejectOrder', {
222
+ action: 'reject',
223
+ order: _ordersGrouped[k][0],
224
+ ids: _ordersGrouped[k].map((o: any) => o.id),
225
+ handleChangeOrderStatus
226
+ })}
227
+ />
228
+ <OButton
229
+ text={t('ACCEPT_ALL', 'Accept all')}
230
+ bgColor={theme.colors.success100}
231
+ borderColor={theme.colors.success100}
232
+ imgRightSrc={null}
233
+ style={{ borderRadius: 7, height: 40 }}
234
+ parentStyle={{ width: '45%' }}
235
+ textStyle={{ color: theme.colors.success500, fontSize: 12 }}
236
+ onClick={() => onNavigationRedirect('AcceptOrRejectOrder', {
237
+ action: 'accept',
238
+ order: _ordersGrouped[k][0],
239
+ ids: _ordersGrouped[k].map((o: any) => o.id),
240
+ handleChangeOrderStatus
241
+ })}
242
+ />
243
+ </AcceptOrRejectOrderStyle>
244
+ )}
245
+ <View>
246
+ {_ordersGrouped[k][0]?.status === 7 && (
247
+ <OButton
248
+ text={t('READY_FOR_PICKUP', 'Ready for pickup')}
249
+ bgColor={theme.colors.primaryLight}
250
+ borderColor={theme.colors.primaryLight}
251
+ imgRightSrc={null}
252
+ style={{ borderRadius: 7, height: 40 }}
253
+ parentStyle={{ width: '100%' }}
254
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
255
+ onClick={() => handleChangeOrderStatus(
256
+ 4,
257
+ _ordersGrouped[k].map((o: any) => o.id),
258
+ )}
259
+ />
253
260
  )}
254
- />
255
- )}
256
- </View>
257
- <View>
258
- {viewMapStatus.includes(ordersGrouped[k][0]?.status) && (
259
- <OButton
260
- text={t('TRACK_REAL_TIME_POSITION', 'Track real time position')}
261
- bgColor={theme.colors.primaryLight}
262
- borderColor={theme.colors.primaryLight}
263
- imgRightSrc={null}
264
- style={{ borderRadius: 7, height: 40 }}
265
- parentStyle={{ width: '100%' }}
266
- textStyle={{ color: theme.colors.primary, fontSize: 12 }}
267
- onClick={() => handleOpenMapView({ orders: ordersGrouped[k] })}
268
- />
269
- )}
270
- </View>
271
- {ordersGrouped[k][0]?.status === 4 &&
272
- ![1].includes(ordersGrouped[k][0]?.delivery_type) &&
273
- (
274
- <AcceptOrRejectOrderStyle>
275
- <OButton
276
- text={t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', 'Order not picked up by customer')}
277
- bgColor={theme.colors.danger100}
278
- borderColor={theme.colors.danger100}
279
- imgRightSrc={null}
280
- style={{ borderRadius: 7, height: 40, paddingLeft: 10, paddingRight: 10 }}
281
- parentStyle={{ width: '45%' }}
282
- textStyle={{ color: theme.colors.danger500, fontSize: 12, textAlign: 'center' }}
283
- onClick={() => handleChangeOrderStatus(
284
- 17,
285
- ordersGrouped[k].map((o: any) => o.id),
261
+ </View>
262
+ <View>
263
+ {viewMapStatus.includes(_ordersGrouped[k][0]?.status) && (
264
+ <OButton
265
+ text={t('TRACK_REAL_TIME_POSITION', 'Track real time position')}
266
+ bgColor={theme.colors.primaryLight}
267
+ borderColor={theme.colors.primaryLight}
268
+ imgRightSrc={null}
269
+ style={{ borderRadius: 7, height: 40 }}
270
+ parentStyle={{ width: '100%' }}
271
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
272
+ onClick={() => handleOpenMapView({ orders: _ordersGrouped[k] })}
273
+ />
286
274
  )}
287
- />
288
- <OButton
289
- text={t('PICKUP_COMPLETED_BY_CUSTOMER', 'Pickup completed by customer')}
290
- bgColor={theme.colors.success100}
291
- borderColor={theme.colors.success100}
292
- imgRightSrc={null}
293
- style={{ borderRadius: 7, height: 40, paddingLeft: 10, paddingRight: 10 }}
294
- parentStyle={{ width: '45%' }}
295
- textStyle={{ color: theme.colors.success500, fontSize: 12, textAlign: 'center' }}
296
- onClick={() => handleChangeOrderStatus(
297
- 15,
298
- ordersGrouped[k].map((o: any) => o.id),
299
- )}
300
- />
301
- </AcceptOrRejectOrderStyle>
302
- )}
303
- {!ordersGrouped[k][0]?.user_review &&
304
- pastOrderStatuses.includes(ordersGrouped[k][0]?.status) &&
305
- (
306
- <OButton
307
- text={t('REVIEW_CUSTOMER', 'Review customer')}
308
- bgColor={theme.colors.primary}
309
- borderColor={theme.colors.primary}
310
- imgRightSrc={null}
311
- style={{ borderRadius: 8, height: 40 }}
312
- parentStyle={{ width: '100%' }}
313
- textStyle={{ color: theme.colors.white }}
314
- onClick={() => setOpenReviewModal({
315
- order: ordersGrouped[k][0],
316
- customerId: ordersGrouped[k][0]?.customer_id,
317
- ids: ordersGrouped[k].map((o: any) => o.id)
318
- })}
319
- />
320
- )}
321
- </OrdersGroupedItem>
322
- ))}
323
- </View>
324
- )}
325
- {orders?.length > 0 &&
326
- orders
327
- ?.filter((order: any) => hash[order?.id] ? false : (hash[order?.id] = true))
328
- ?.map((_order: any) => {
329
- const order = _order?.isLogistic && !_order?.order_group && isLogisticOrder ? _order?.order : _order
330
- return (
331
- <OrdersList key={order.id} order={order} _order={_order} />
332
- )
333
- }
275
+ </View>
276
+ {_ordersGrouped[k][0]?.status === 4 &&
277
+ ![1].includes(_ordersGrouped[k][0]?.delivery_type) &&
278
+ (
279
+ <AcceptOrRejectOrderStyle>
280
+ <OButton
281
+ text={t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', 'Order not picked up by customer')}
282
+ bgColor={theme.colors.danger100}
283
+ borderColor={theme.colors.danger100}
284
+ imgRightSrc={null}
285
+ style={{ borderRadius: 7, height: 40, paddingLeft: 10, paddingRight: 10 }}
286
+ parentStyle={{ width: '45%' }}
287
+ textStyle={{ color: theme.colors.danger500, fontSize: 12, textAlign: 'center' }}
288
+ onClick={() => handleChangeOrderStatus(
289
+ 17,
290
+ _ordersGrouped[k].map((o: any) => o.id),
291
+ )}
292
+ />
293
+ <OButton
294
+ text={t('PICKUP_COMPLETED_BY_CUSTOMER', 'Pickup completed by customer')}
295
+ bgColor={theme.colors.success100}
296
+ borderColor={theme.colors.success100}
297
+ imgRightSrc={null}
298
+ style={{ borderRadius: 7, height: 40, paddingLeft: 10, paddingRight: 10 }}
299
+ parentStyle={{ width: '45%' }}
300
+ textStyle={{ color: theme.colors.success500, fontSize: 12, textAlign: 'center' }}
301
+ onClick={() => handleChangeOrderStatus(
302
+ 15,
303
+ _ordersGrouped[k].map((o: any) => o.id),
304
+ )}
305
+ />
306
+ </AcceptOrRejectOrderStyle>
307
+ )}
308
+ {!_ordersGrouped[k][0]?.user_review &&
309
+ pastOrderStatuses.includes(_ordersGrouped[k][0]?.status) &&
310
+ (
311
+ <OButton
312
+ text={t('REVIEW_CUSTOMER', 'Review customer')}
313
+ bgColor={theme.colors.primary}
314
+ borderColor={theme.colors.primary}
315
+ imgRightSrc={null}
316
+ style={{ borderRadius: 8, height: 40 }}
317
+ parentStyle={{ width: '100%' }}
318
+ textStyle={{ color: theme.colors.white }}
319
+ onClick={() => setOpenReviewModal({
320
+ order: _ordersGrouped[k][0],
321
+ customerId: _ordersGrouped[k][0]?.customer_id,
322
+ ids: _ordersGrouped[k].map((o: any) => o.id)
323
+ })}
324
+ />
325
+ )}
326
+ </OrdersGroupedItem>
327
+ ))}
328
+ </View>
329
+ ) : (
330
+ <View key={order.id}>
331
+ <OrdersList order={order} _order={_order} />
332
+ </View>
333
+ )
334
334
  )
335
- }
335
+ })}
336
336
 
337
337
  <OModal
338
338
  open={openModal}
@@ -311,7 +311,7 @@ export interface OrdersOptionParams {
311
311
  isLogisticActivated?: boolean;
312
312
  isAlsea?: boolean;
313
313
  checkNotification?: boolean;
314
- ordersGroupedFormatted?: any;
314
+ ordersFormatted?: any;
315
315
  handleChangeOrderStatus?: () => void;
316
316
  handleSendCustomerReview?: () => void;
317
317
  orderDetailsProps?: any;
@@ -573,14 +573,17 @@ export interface AcceptOrRejectOrderParams {
573
573
  loading?: boolean;
574
574
  action: string;
575
575
  orderId?: number;
576
- handleUpdateOrder?: () => void;
576
+ handleUpdateOrder?: (p1: any, p2: any) => {};
577
577
  notShowCustomerPhone?: boolean | undefined;
578
- actions?: actions;
578
+ actions?: any;
579
579
  titleAccept?: textTranslate;
580
580
  titleReject?: textTranslate;
581
581
  titleNotReady?: textTranslate;
582
582
  appTitle?: textTranslate;
583
583
  orderTitle?: any
584
+ isPage?: boolean
585
+ navigation?: any
586
+ route?: any
584
587
  }
585
588
 
586
589
  export interface MapViewParams {