ordering-ui-react-native 0.16.90 → 0.16.91

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.16.90",
3
+ "version": "0.16.91",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -742,7 +742,7 @@ const ChatUI = (props: MessagesParams) => {
742
742
  color: '#414954'
743
743
  }}
744
744
  style={{ ...styles.editButton }}
745
- onClick={() => handleClickQuickMessage(quickMessage.text)}
745
+ onClick={() => handleClickQuickMessage(message?.length > 0 ? ' ' + quickMessage.text : quickMessage.text)}
746
746
  />
747
747
  </React.Fragment>
748
748
  ))}
@@ -5,6 +5,7 @@ import {
5
5
  StyleSheet,
6
6
  Dimensions,
7
7
  ScrollView,
8
+ RefreshControl,
8
9
  } from 'react-native';
9
10
  import { Contacts, useLanguage } from 'ordering-components/native';
10
11
  import { useTheme } from 'styled-components/native';
@@ -24,6 +25,7 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
24
25
  messages,
25
26
  onNavigationRedirect,
26
27
  setSortBy,
28
+ getOrders
27
29
  } = props;
28
30
 
29
31
  const theme = useTheme();
@@ -55,6 +57,7 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
55
57
  const [tabsFilter, setTabsFilter] = useState(tabs[0].tags);
56
58
  const [activeTag, setActiveTag] = useState(tags[0].key);
57
59
  const [reload, setReload] = useState(false);
60
+ const [refreshing] = useState(false);
58
61
  const [unreadMessages, setUnreadMessages] = useState(
59
62
  values?.reduce(
60
63
  (total: number, order: any) => total + order.unread_count,
@@ -247,7 +250,14 @@ const MessagesOptionUI = (props: MessagesOptionParams) => {
247
250
  />
248
251
  )}
249
252
 
250
- <ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1 }}>
253
+ <ScrollView
254
+ showsVerticalScrollIndicator={false}
255
+ style={{ flex: 1 }}
256
+ refreshControl={<RefreshControl
257
+ refreshing={refreshing}
258
+ onRefresh={() => getOrders?.()}
259
+ />}
260
+ >
251
261
  {!reload &&
252
262
  !error &&
253
263
  values.length > 0 &&
@@ -5,6 +5,7 @@ import SelectDropdown from 'react-native-select-dropdown'
5
5
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
6
6
  import FeatherIcon from 'react-native-vector-icons/Feather';
7
7
  import FontistoIcon from 'react-native-vector-icons/Fontisto'
8
+ import AntDesignIcon from 'react-native-vector-icons/AntDesign'
8
9
  import { useTheme } from 'styled-components/native';
9
10
  import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
10
11
  import { NotificationSetting } from '../../../../../src/components/NotificationSetting'
@@ -33,7 +34,8 @@ import {
33
34
  ItemContent,
34
35
  TimerInputWrapper,
35
36
  OverLine,
36
- Actions
37
+ Actions,
38
+ InputContainer
37
39
  } from './styles';
38
40
  import { PreviousOrders } from '../PreviousOrders';
39
41
  import { OrdersOptionParams } from '../../types';
@@ -48,7 +50,7 @@ import { OrdersOptionDelivery } from '../OrdersOptionDelivery';
48
50
  import { OrdersOptionPaymethod } from '../OrdersOptionPaymethod';
49
51
  import { OrdersOptionDriver } from '../OrdersOptionDriver';
50
52
  import { OrdersOptionDate } from '../OrdersOptionDate';
51
-
53
+ import { GestureEvent, GestureDetector } from 'react-native-gesture-handler'
52
54
  const tabsList: any = {
53
55
  pending: 1,
54
56
  inProgress: 2,
@@ -123,7 +125,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
123
125
  const [selectedTabStatus, setSelectedTabStatus] = useState([])
124
126
  const [hour, setHour] = useState(0)
125
127
  const [minute, setMinute] = useState(0)
126
-
128
+ const [openedSelect, setOpenedSelect] = useState('')
127
129
  const WIDTH_SCREEN = orientationState?.dimensions?.width
128
130
  const HEIGHT_SCREEN = orientationState?.dimensions?.height
129
131
  const IS_PORTRAIT = orientationState.orientation === PORTRAIT
@@ -403,10 +405,11 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
403
405
  setOpenSLASettingModal(false)
404
406
  }
405
407
 
406
- useEffect(() => {
407
- setCurrentFilters(null)
408
- onFiltered && onFiltered(null)
408
+ const handleClearFilters = () => {
409
409
  setSearch(defaultSearchList)
410
+ }
411
+
412
+ useEffect(() => {
410
413
  scrollRefTab.current?.scrollTo({ animated: true });
411
414
  scrollListRef.current?.scrollTo({ animated: true });
412
415
  scrollRef.current?.scrollTo({ y: 0, animated: true });
@@ -415,7 +418,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
415
418
  useEffect(() => {
416
419
  setSelectedTabStatus(deliveryStatus)
417
420
  }, [])
418
-
421
+
419
422
  return (
420
423
  // <GestureRecognizer
421
424
  // onSwipeLeft={onSwipeLeft}
@@ -754,22 +757,34 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
754
757
  {openSearchModal && (
755
758
  <SearchModalContent>
756
759
  <ModalTitle>{t('SEARCH_ORDERS', 'Search orders')}</ModalTitle>
757
- <OInput
758
- value={search.id}
759
- onChange={(value: any) => setSearch({ ...search, id: value })}
760
- style={styles.inputStyle}
761
- placeholder={t('ORDER_NUMBER', 'Order number')}
762
- autoCorrect={false}
763
- />
760
+ <InputContainer>
761
+ <OInput
762
+ value={search.id}
763
+ onChange={(value: any) => setSearch({ ...search, id: value })}
764
+ style={styles.inputStyle}
765
+ placeholder={t('ORDER_NUMBER', 'Order number')}
766
+ autoCorrect={false}
767
+ />
768
+ <AntDesignIcon
769
+ name='close'
770
+ size={20}
771
+ style={{ position: 'absolute', right: 12, top: 13 }}
772
+ onPress={() => setSearch({ ...search, id: '' })}
773
+ />
774
+ </InputContainer>
764
775
  <OrdersOptionDate
765
776
  {...props}
766
777
  search={search}
767
778
  onSearch={setSearch}
779
+ setOpenedSelect={setOpenedSelect}
780
+ openedSelect={openedSelect}
768
781
  />
769
782
  <OrdersOptionCity
770
783
  {...props}
771
784
  search={search}
772
785
  onSearch={setSearch}
786
+ setOpenedSelect={setOpenedSelect}
787
+ openedSelect={openedSelect}
773
788
  />
774
789
  {isBusinessApp && (
775
790
  <>
@@ -777,21 +792,29 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
777
792
  {...props}
778
793
  search={search}
779
794
  onSearch={setSearch}
795
+ setOpenedSelect={setOpenedSelect}
796
+ openedSelect={openedSelect}
780
797
  />
781
798
  <OrdersOptionDelivery
782
799
  {...props}
783
800
  search={search}
784
801
  onSearch={setSearch}
802
+ setOpenedSelect={setOpenedSelect}
803
+ openedSelect={openedSelect}
785
804
  />
786
805
  <OrdersOptionDriver
787
806
  {...props}
788
807
  search={search}
789
808
  onSearch={setSearch}
809
+ setOpenedSelect={setOpenedSelect}
810
+ openedSelect={openedSelect}
790
811
  />
791
812
  <OrdersOptionPaymethod
792
813
  {...props}
793
814
  search={search}
794
815
  onSearch={setSearch}
816
+ setOpenedSelect={setOpenedSelect}
817
+ openedSelect={openedSelect}
795
818
  />
796
819
  </>
797
820
  )}
@@ -801,13 +824,24 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
801
824
  imgRightSrc={null}
802
825
  style={{
803
826
  borderRadius: 7.6,
804
- marginBottom: 70,
827
+ marginBottom: 10,
805
828
  marginTop: 60,
806
829
  zIndex: 12
807
830
  }}
808
831
  onClick={applyFilters}
809
832
  />
810
-
833
+ <OButton
834
+ text={t('CLEAR_SEARCh', 'Clear search')}
835
+ imgRightSrc={null}
836
+ bgColor='#fff'
837
+ style={{
838
+ borderRadius: 7.6,
839
+ marginBottom: 0,
840
+ marginTop: 0,
841
+ zIndex: 12
842
+ }}
843
+ onClick={handleClearFilters}
844
+ />
811
845
  </SearchModalContent>
812
846
  )}
813
847
  {openSLASettingModal && (
@@ -149,4 +149,8 @@ export const OverLine = styled.View`
149
149
  `
150
150
  export const Actions = styled.View`
151
151
 
152
- `
152
+ `
153
+
154
+ export const InputContainer = styled.View`
155
+ position: relative;
156
+ `
@@ -10,7 +10,9 @@ export const OrdersOptionBusinessUI = (props: any) => {
10
10
  const {
11
11
  search,
12
12
  onSearch,
13
- businessesList
13
+ businessesList,
14
+ setOpenedSelect,
15
+ openedSelect
14
16
  } = props
15
17
 
16
18
  const theme = useTheme();
@@ -25,6 +27,14 @@ export const OrdersOptionBusinessUI = (props: any) => {
25
27
  setOptionsList(businesses)
26
28
  }, [businessesList?.businesses])
27
29
 
30
+ const handleClear = () => {
31
+ onSearch({ ...search, option: '' })
32
+ }
33
+
34
+ const handleOpenSelect = () => {
35
+ setOpenedSelect('business')
36
+ }
37
+
28
38
  return (
29
39
  <Container isIos={Platform.OS === 'ios'}>
30
40
  <ODropDown
@@ -36,6 +46,10 @@ export const OrdersOptionBusinessUI = (props: any) => {
36
46
  textcolor={theme.colors.unselectText}
37
47
  placeholder={t('SELECT_BUSINESS', 'Select Business')}
38
48
  dropViewMaxHeight={200}
49
+ handleClear={handleClear}
50
+ handleOpenSelect={handleOpenSelect}
51
+ openedSelect={openedSelect}
52
+ selectType='business'
39
53
  />
40
54
  </Container>
41
55
  );
@@ -10,7 +10,9 @@ export const OrdersOptionCityUI = (props: any) => {
10
10
  const {
11
11
  search,
12
12
  onSearch,
13
- allListValues
13
+ allListValues,
14
+ setOpenedSelect,
15
+ openedSelect
14
16
  } = props
15
17
 
16
18
  const theme = useTheme();
@@ -27,6 +29,14 @@ export const OrdersOptionCityUI = (props: any) => {
27
29
  setOptionsList(cities)
28
30
  }, [allListValues?.countries])
29
31
 
32
+ const handleClear = () => {
33
+ onSearch({ ...search, city: '' })
34
+ }
35
+
36
+ const handleOpenSelect = () => {
37
+ setOpenedSelect('city')
38
+ }
39
+
30
40
  return (
31
41
  <Container isIos={Platform.OS === 'ios'}>
32
42
  <ODropDown
@@ -38,6 +48,10 @@ export const OrdersOptionCityUI = (props: any) => {
38
48
  textcolor={theme.colors.unselectText}
39
49
  placeholder={t('SELECT_CITY', 'Select City')}
40
50
  dropViewMaxHeight={200}
51
+ handleClear={handleClear}
52
+ handleOpenSelect={handleOpenSelect}
53
+ openedSelect={openedSelect}
54
+ selectType='city'
41
55
  />
42
56
  </Container>
43
57
  );
@@ -3,12 +3,16 @@ import { useLanguage } from 'ordering-components/native';
3
3
  import { useTheme } from 'styled-components/native';
4
4
  import { Container } from './styles';
5
5
  import ODropDownCalendar from '../shared/ODropDownCalendar';
6
- import { Platform } from 'react-native'
7
-
6
+ import { Button, Platform, Touchable, TouchableOpacity, View } from 'react-native'
7
+ import DoubleClick from 'react-native-double-tap'
8
+ import { OText } from '../shared';
9
+ import DoubleTap from 'react-native-double-tap';
8
10
  export const OrdersOptionDate = (props: any) => {
9
11
  const {
10
12
  search,
11
- onSearch
13
+ onSearch,
14
+ setOpenedSelect,
15
+ openedSelect
12
16
  } = props
13
17
 
14
18
  const theme = useTheme();
@@ -22,18 +26,23 @@ export const OrdersOptionDate = (props: any) => {
22
26
 
23
27
  const handleChangeOption = (option: any) => {
24
28
  if (option === 'calendar') {
25
- onSearch({...search, date: {...search.date, type: option}})
29
+ onSearch({ ...search, date: { ...search.date, type: option } })
26
30
  } else {
27
- onSearch({...search, date: {from: '', to: '', type: option}})
31
+ onSearch({ ...search, date: { from: '', to: '', type: option } })
28
32
  }
29
33
  }
30
34
 
31
35
  const handleChangeDate = (from: any, to: any) => {
32
- onSearch({...search, date: {...search.date, from: from, to: to}})
36
+ onSearch({ ...search, date: { ...search.date, from: from, to: to } })
37
+ }
38
+
39
+ const handleOpenSelect = () => {
40
+ setOpenedSelect('calendar')
33
41
  }
34
42
 
35
43
  return (
36
44
  <Container isIos={Platform.OS === 'ios'}>
45
+
37
46
  <ODropDownCalendar
38
47
  options={optionsList}
39
48
  defaultValue={search.date.type}
@@ -47,6 +56,10 @@ export const OrdersOptionDate = (props: any) => {
47
56
  rangeDate={search.date}
48
57
  handleChangeDate={handleChangeDate}
49
58
  isCalendarAlwaysVisible
59
+ handleClear={() => onSearch({ ...search, date: { from: '', to: '', type: '' } })}
60
+ handleOpenSelect={handleOpenSelect}
61
+ openedSelect={openedSelect}
62
+ selectType='calendar'
50
63
  />
51
64
  </Container>
52
65
  );
@@ -8,7 +8,9 @@ import { Platform } from 'react-native'
8
8
  export const OrdersOptionDelivery = (props: any) => {
9
9
  const {
10
10
  search,
11
- onSearch
11
+ onSearch,
12
+ setOpenedSelect,
13
+ openedSelect
12
14
  } = props
13
15
 
14
16
  const theme = useTheme();
@@ -18,6 +20,14 @@ export const OrdersOptionDelivery = (props: any) => {
18
20
  { value: '2', content: t('PICKUP', 'Pickup') }
19
21
  ]
20
22
 
23
+ const handleClear = () => {
24
+ onSearch({ ...search, delivery_type: '' })
25
+ }
26
+
27
+ const handleOpenSelect = () => {
28
+ setOpenedSelect('delivery_type')
29
+ }
30
+
21
31
  return (
22
32
  <Container isIos={Platform.OS === 'ios'}>
23
33
  <ODropDown
@@ -29,6 +39,10 @@ export const OrdersOptionDelivery = (props: any) => {
29
39
  textcolor={theme.colors.unselectText}
30
40
  placeholder={t('SELECT_DELIVERY_TYPE', 'Select Delivery type')}
31
41
  dropViewMaxHeight={200}
42
+ handleClear={handleClear}
43
+ handleOpenSelect={handleOpenSelect}
44
+ openedSelect={openedSelect}
45
+ selectType='delivery_type'
32
46
  />
33
47
  </Container>
34
48
  );
@@ -9,7 +9,9 @@ export const OrdersOptionDriverUI = (props: any) => {
9
9
  const {
10
10
  search,
11
11
  onSearch,
12
- driverList
12
+ driverList,
13
+ setOpenedSelect,
14
+ openedSelect
13
15
  } = props
14
16
 
15
17
  const theme = useTheme();
@@ -24,6 +26,14 @@ export const OrdersOptionDriverUI = (props: any) => {
24
26
  setOptionsList(drivers)
25
27
  }, [driverList?.drivers])
26
28
 
29
+ const handleClear = () => {
30
+ onSearch({ ...search, driver: '' })
31
+ }
32
+
33
+ const handleOpenSelect = () => {
34
+ setOpenedSelect('driver')
35
+ }
36
+
27
37
  return (
28
38
  <Container isIos={Platform.OS === 'ios'}>
29
39
  <ODropDown
@@ -35,6 +45,10 @@ export const OrdersOptionDriverUI = (props: any) => {
35
45
  textcolor={theme.colors.unselectText}
36
46
  placeholder={t('SELECT_DRIVER', 'Select Driver')}
37
47
  dropViewMaxHeight={165}
48
+ handleClear={handleClear}
49
+ handleOpenSelect={handleOpenSelect}
50
+ openedSelect={openedSelect}
51
+ selectType='driver'
38
52
  />
39
53
  </Container>
40
54
  );
@@ -9,7 +9,9 @@ export const OrdersOptionPaymethodUI = (props: any) => {
9
9
  const {
10
10
  search,
11
11
  onSearch,
12
- paymethodList
12
+ paymethodList,
13
+ setOpenedSelect,
14
+ openedSelect
13
15
  } = props
14
16
 
15
17
  const theme = useTheme();
@@ -24,6 +26,14 @@ export const OrdersOptionPaymethodUI = (props: any) => {
24
26
  setOptionsList(paymethods)
25
27
  }, [paymethodList?.paymethods])
26
28
 
29
+ const handleClear = () => {
30
+ onSearch({ ...search, paymethod: '' })
31
+ }
32
+
33
+ const handleOpenSelect = () => {
34
+ setOpenedSelect('paymethod')
35
+ }
36
+
27
37
  return (
28
38
  <Container isIos={Platform.OS === 'ios'}>
29
39
  <ODropDown
@@ -35,6 +45,10 @@ export const OrdersOptionPaymethodUI = (props: any) => {
35
45
  textcolor={theme.colors.unselectText}
36
46
  placeholder={t('SELECT_PAYMETHOD', 'Select Paymethod')}
37
47
  dropViewMaxHeight={200}
48
+ handleClear={handleClear}
49
+ handleOpenSelect={handleOpenSelect}
50
+ openedSelect={openedSelect}
51
+ selectType='paymethod'
38
52
  />
39
53
  </Container>
40
54
  );
@@ -11,7 +11,9 @@ export const OrdersOptionStatus = (props: any) => {
11
11
  tabs,
12
12
  orderStatus,
13
13
  search,
14
- onSearch
14
+ onSearch,
15
+ setOpenedSelect,
16
+ openedSelect
15
17
  } = props
16
18
 
17
19
  const theme = useTheme();
@@ -29,6 +31,10 @@ export const OrdersOptionStatus = (props: any) => {
29
31
  setOptionsList(_optionList)
30
32
  }, [currentTabSelected, tabs, orderStatus])
31
33
 
34
+ const handleOpenSelect = () => {
35
+ setOpenedSelect('state')
36
+ }
37
+
32
38
  return (
33
39
  <Container isIos={Platform.OS === 'ios'}>
34
40
  <ODropDown
@@ -40,6 +46,9 @@ export const OrdersOptionStatus = (props: any) => {
40
46
  textcolor={theme.colors.unselectText}
41
47
  placeholder={t('SELECT_STATUS', 'Select Status')}
42
48
  dropViewMaxHeight={200}
49
+ handleOpenSelect={handleOpenSelect}
50
+ openedSelect={openedSelect}
51
+ selectType='state'
43
52
  />
44
53
  </Container>
45
54
  );
@@ -230,6 +230,7 @@ export const PreviousMessages = (props: PreviousMessagesParams) => {
230
230
  fontWeight: '600',
231
231
  fontSize: 16,
232
232
  color: theme.colors.textGray,
233
+ width: '85%'
233
234
  },
234
235
  badge: {
235
236
  marginBottom: 6,
@@ -4,6 +4,7 @@ import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler'
4
4
  import { ScrollView as CustomScrollView, TouchableOpacity as CustomTouchableOpacity, View } from 'react-native'
5
5
  import FeatherIcon from 'react-native-vector-icons/Feather';
6
6
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
7
+ import AntDesign from 'react-native-vector-icons/AntDesign';
7
8
  import { Text } from 'react-native-paper';
8
9
 
9
10
  interface Props {
@@ -16,7 +17,11 @@ interface Props {
16
17
  dropViewMaxHeight?: any,
17
18
  isModal?: any,
18
19
  bgcolor?: string,
19
- textcolor?: string
20
+ textcolor?: string,
21
+ handleClear?: any,
22
+ handleOpenSelect?: any,
23
+ openedSelect?: string,
24
+ selectType?: string
20
25
  }
21
26
 
22
27
  const Wrapper = styled.View`
@@ -70,7 +75,11 @@ const ODropDown = (props: Props) => {
70
75
  placeholder,
71
76
  onSelect,
72
77
  dropViewMaxHeight,
73
- isModal
78
+ isModal,
79
+ handleClear,
80
+ handleOpenSelect,
81
+ openedSelect,
82
+ selectType
74
83
  } = props
75
84
 
76
85
  const theme = useTheme();
@@ -82,6 +91,7 @@ const ODropDown = (props: Props) => {
82
91
 
83
92
  const onToggle = () => {
84
93
  setIsOpen(!isOpen)
94
+ if (!isOpen) handleOpenSelect?.()
85
95
  }
86
96
 
87
97
  const onSelectOption = (option: any) => {
@@ -91,12 +101,25 @@ const ODropDown = (props: Props) => {
91
101
  setIsOpen(false)
92
102
  }
93
103
 
104
+ const handleClearSearch = () => {
105
+ handleClear()
106
+ if (isOpen) {
107
+ onToggle()
108
+ }
109
+ }
110
+
94
111
  useEffect(() => {
95
112
  const _defaultOption = options?.find((option: any) => option.value === defaultValue)
96
113
  setSelectedOption(_defaultOption)
97
114
  setValue(defaultValue)
98
115
  }, [defaultValue, options])
99
116
 
117
+ useEffect(() => {
118
+ if (openedSelect !== selectType && typeof openedSelect === 'string') {
119
+ setIsOpen(false)
120
+ }
121
+ }, [openedSelect])
122
+
100
123
  return (
101
124
  <Wrapper style={props.style}>
102
125
  <Selected
@@ -110,11 +133,22 @@ const ODropDown = (props: Props) => {
110
133
  >
111
134
  {selectedOption?.content || selectedOption?.name || placeholder}
112
135
  </SelectedLabel>
113
- <FeatherIcon
114
- name='chevron-down'
115
- color={props.textcolor}
116
- size={24}
117
- />
136
+ {selectedOption && handleClear ? (
137
+ <AntDesign
138
+ name={'close'}
139
+ size={20}
140
+ onPress={() => handleClearSearch()}
141
+ style={{ position: 'absolute', right: 12, top: 13 }}
142
+ />
143
+ ) : (
144
+ <FeatherIcon
145
+ name='chevron-down'
146
+ color={props.textcolor}
147
+ size={24}
148
+ style={{ position: 'absolute', right: 12, top: 13 }}
149
+
150
+ />
151
+ )}
118
152
  </Selected>
119
153
  {isOpen && options && (
120
154
  <DropView
@@ -154,7 +188,7 @@ const ODropDown = (props: Props) => {
154
188
  maxHeight: dropViewMaxHeight || null,
155
189
  paddingBottom: 15
156
190
  }}
157
- nestedScrollEnabled={true}
191
+ nestedScrollEnabled={true}
158
192
  >
159
193
  {options.map((option: any, index: number) => (
160
194
  <CustomTouchableOpacity
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from 'react'
1
+ import React, { useState, useEffect, useRef } from 'react'
2
2
  import styled, { css, useTheme } from 'styled-components/native'
3
3
  import { useLanguage } from 'ordering-components/native';
4
4
  import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler'
@@ -24,6 +24,10 @@ interface Props {
24
24
  handleChangeDate?: any,
25
25
  rangeDate?: any,
26
26
  isCalendarAlwaysVisible?: boolean
27
+ handleClear?: any;
28
+ handleOpenSelect?: any,
29
+ openedSelect?: string,
30
+ selectType?: string
27
31
  }
28
32
 
29
33
  const Wrapper = styled.View`
@@ -96,7 +100,11 @@ const ODropDownCalendar = (props: Props) => {
96
100
  isCalendar,
97
101
  handleChangeDate,
98
102
  rangeDate,
99
- isCalendarAlwaysVisible
103
+ isCalendarAlwaysVisible,
104
+ handleClear,
105
+ handleOpenSelect,
106
+ openedSelect,
107
+ selectType
100
108
  } = props
101
109
 
102
110
  const theme = useTheme();
@@ -110,6 +118,7 @@ const ODropDownCalendar = (props: Props) => {
110
118
 
111
119
  const onToggle = () => {
112
120
  setIsOpen(!isOpen)
121
+ if (!isOpen) handleOpenSelect?.()
113
122
  }
114
123
 
115
124
  const onSelectOption = (option: any) => {
@@ -122,7 +131,7 @@ const ODropDownCalendar = (props: Props) => {
122
131
  const onDateChange = (date: any, type: any) => {
123
132
  if (!date) return
124
133
  if (type === 'END_DATE') {
125
- handleChangeDate(rangeDate.from, date.format('MM/DD/YY'))
134
+ handleChangeDate(rangeDate.from, new Date(date.format('MM/DD/YY')) === rangeDate.from ? '' : date.format('MM/DD/YY'))
126
135
  } else {
127
136
  handleChangeDate(date.format('MM/DD/YY'), '')
128
137
  }
@@ -142,12 +151,31 @@ const ODropDownCalendar = (props: Props) => {
142
151
  return (from || to) ? (from + (to ? end : '')) : placeholder
143
152
  }
144
153
 
154
+ const handleClearCalendar = () => {
155
+ handleClear && handleClear()
156
+ if (isOpen) {
157
+ onToggle()
158
+ }
159
+ }
160
+
145
161
  useEffect(() => {
146
162
  const _defaultOption = options?.find((option: any) => option.value === defaultValue)
147
163
  setSelectedOption(_defaultOption)
148
164
  setValue(defaultValue)
149
165
  }, [defaultValue, options])
150
166
 
167
+ useEffect(() => {
168
+ if (openedSelect !== selectType && typeof openedSelect === 'string') {
169
+ setIsOpen(false)
170
+ }
171
+ }, [openedSelect])
172
+
173
+ useEffect(() => {
174
+ if (rangeDate.to && rangeDate.from) {
175
+ onSelect('calendar')
176
+ }
177
+ }, [rangeDate.to, rangeDate.from])
178
+
151
179
  return (
152
180
  <Wrapper style={props.style}>
153
181
  <Selected
@@ -165,10 +193,11 @@ const ODropDownCalendar = (props: Props) => {
165
193
  : `${selectedOption?.content || selectedOption?.name || placeholder}`
166
194
  }
167
195
  </SelectedLabel>
168
- <FeatherIcon
169
- name='calendar'
170
- color={theme.colors.backArrow}
171
- size={24}
196
+ <AntDesign
197
+ name={selectedOption && handleClear ? 'close' : 'calendar'}
198
+ size={20}
199
+ onPress={() => handleClearCalendar()}
200
+ style={{ position: 'absolute', right: 12, top: 13 }}
172
201
  />
173
202
  </Selected>
174
203
  {isOpen && options && (
@@ -256,6 +256,7 @@ export interface MessagesOptionParams {
256
256
  messagesReadList?: any;
257
257
  onNavigationRedirect?: any;
258
258
  setSortBy?: any;
259
+ getOrders: any
259
260
  }
260
261
  export interface OrdersOptionParams {
261
262
  orderList?: any;
@@ -409,7 +410,7 @@ export interface MessagesParams {
409
410
  order?: any;
410
411
  orderId?: number;
411
412
  messages?: any;
412
- message?: string;
413
+ message: string;
413
414
  image?: string;
414
415
  messagesToShow?: any;
415
416
  sendMessage?: any;