ordering-ui-react-native 0.16.29 → 0.16.32
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 +2 -1
- package/src/components/AddressForm/index.tsx +15 -2
- package/themes/business/src/components/Chat/index.tsx +4 -4
- package/themes/original/index.tsx +8 -0
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
- package/themes/original/src/components/BusinessProductsListing/index.tsx +255 -208
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +5 -0
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
- package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +549 -0
- package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +106 -0
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +519 -0
- package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Original/styles.tsx} +0 -0
- package/themes/original/src/components/BusinessesListing/index.tsx +13 -515
- package/themes/original/src/components/MomentSelector/index.tsx +197 -0
- package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
- package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
- package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
- package/themes/original/src/components/ProfessionalProfile/index.tsx +297 -0
- package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
- package/themes/original/src/components/ServiceForm/index.tsx +485 -0
- package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
- package/themes/original/src/types/index.tsx +31 -1
- package/themes/original/src/utils/index.tsx +11 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { StyleSheet, View, Platform } from 'react-native'
|
|
3
|
+
import SelectDropdown from 'react-native-select-dropdown'
|
|
4
|
+
import { useTheme } from 'styled-components/native'
|
|
5
|
+
import {
|
|
6
|
+
MomentOption as MomentOptionController,
|
|
7
|
+
useConfig,
|
|
8
|
+
useUtils
|
|
9
|
+
} from 'ordering-components/native'
|
|
10
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
11
|
+
import IconAntDesign from 'react-native-vector-icons/AntDesign'
|
|
12
|
+
import { Container } from './styles'
|
|
13
|
+
import moment from 'moment'
|
|
14
|
+
|
|
15
|
+
const MomentSelectorUI = (props: any) => {
|
|
16
|
+
const {
|
|
17
|
+
datesList,
|
|
18
|
+
hoursList,
|
|
19
|
+
dateSelected,
|
|
20
|
+
timeSelected,
|
|
21
|
+
handleChangeDate,
|
|
22
|
+
handleChangeTime,
|
|
23
|
+
} = props
|
|
24
|
+
|
|
25
|
+
const theme = useTheme()
|
|
26
|
+
const { top } = useSafeAreaInsets()
|
|
27
|
+
const [{ configs }] = useConfig()
|
|
28
|
+
const [{ parseTime }] = useUtils()
|
|
29
|
+
|
|
30
|
+
const [customizedDateList, setCustomizedDateList] = useState([])
|
|
31
|
+
const [customizedTimeList, setCustomizedTimeList] = useState([])
|
|
32
|
+
|
|
33
|
+
const is12hours = configs?.dates_moment_format?.value?.includes('hh:mm')
|
|
34
|
+
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
selectOption: {
|
|
37
|
+
width: '100%',
|
|
38
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
39
|
+
paddingVertical: 5,
|
|
40
|
+
paddingHorizontal: 14,
|
|
41
|
+
flexDirection: 'row-reverse',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'space-between',
|
|
44
|
+
height: 30
|
|
45
|
+
},
|
|
46
|
+
selectWrapper: {
|
|
47
|
+
flex: 1
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const updatedDatesList = datesList?.map((date: any) => {
|
|
53
|
+
return { value: moment(date).format('MMM DD, YYYY'), key: date }
|
|
54
|
+
})
|
|
55
|
+
setCustomizedDateList(updatedDatesList)
|
|
56
|
+
}, [datesList])
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (hoursList?.length > 0) {
|
|
60
|
+
|
|
61
|
+
const updatedHoursList = hoursList?.map((hour: any) => {
|
|
62
|
+
const timeValue = is12hours ? (
|
|
63
|
+
hour?.startTime?.includes('12')
|
|
64
|
+
? `${hour.startTime}PM`
|
|
65
|
+
: parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
66
|
+
) : (
|
|
67
|
+
parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
|
|
68
|
+
)
|
|
69
|
+
return { value: timeValue, key: hour.startTime }
|
|
70
|
+
})
|
|
71
|
+
setCustomizedTimeList(updatedHoursList)
|
|
72
|
+
}
|
|
73
|
+
}, [hoursList])
|
|
74
|
+
|
|
75
|
+
const dropDownIcon = () => {
|
|
76
|
+
return (
|
|
77
|
+
<IconAntDesign
|
|
78
|
+
name='down'
|
|
79
|
+
color={theme.colors.textThird}
|
|
80
|
+
size={12}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Container>
|
|
87
|
+
<View style={styles.selectWrapper}>
|
|
88
|
+
<SelectDropdown
|
|
89
|
+
defaultValue={customizedDateList?.find((item: any) => item.key === dateSelected)}
|
|
90
|
+
data={customizedDateList}
|
|
91
|
+
onSelect={(selectedItem, index) => {
|
|
92
|
+
handleChangeDate(selectedItem?.key)
|
|
93
|
+
}}
|
|
94
|
+
buttonTextAfterSelection={(selectedItem, index) => {
|
|
95
|
+
return selectedItem?.value
|
|
96
|
+
}}
|
|
97
|
+
rowTextForSelection={(item, index) => {
|
|
98
|
+
return item.value
|
|
99
|
+
}}
|
|
100
|
+
buttonStyle={{borderTopLeftRadius: 7.6, borderBottomLeftRadius: 7.6, ...styles.selectOption}}
|
|
101
|
+
buttonTextStyle={{
|
|
102
|
+
color: theme.colors.disabled,
|
|
103
|
+
fontSize: 12,
|
|
104
|
+
textAlign: 'left',
|
|
105
|
+
marginHorizontal: 0
|
|
106
|
+
}}
|
|
107
|
+
dropdownStyle={{
|
|
108
|
+
borderRadius: 8,
|
|
109
|
+
borderColor: theme.colors.lightGray,
|
|
110
|
+
marginTop: Platform.OS === 'ios' ? 12 : -top
|
|
111
|
+
}}
|
|
112
|
+
rowStyle={{
|
|
113
|
+
borderBottomColor: theme.colors.backgroundGray100,
|
|
114
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
115
|
+
height: 30,
|
|
116
|
+
flexDirection: 'column',
|
|
117
|
+
alignItems: 'flex-start',
|
|
118
|
+
paddingTop: 8,
|
|
119
|
+
paddingHorizontal: 12
|
|
120
|
+
}}
|
|
121
|
+
rowTextStyle={{
|
|
122
|
+
color: theme.colors.disabled,
|
|
123
|
+
fontSize: 12,
|
|
124
|
+
marginHorizontal: 0
|
|
125
|
+
}}
|
|
126
|
+
renderDropdownIcon={() => dropDownIcon()}
|
|
127
|
+
dropdownOverlayColor='transparent'
|
|
128
|
+
/>
|
|
129
|
+
</View>
|
|
130
|
+
<View style={styles.selectWrapper}>
|
|
131
|
+
<SelectDropdown
|
|
132
|
+
defaultValue={customizedTimeList?.find((item: any) => item.key === timeSelected)}
|
|
133
|
+
data={customizedTimeList}
|
|
134
|
+
onSelect={(selectedItem, index) => {
|
|
135
|
+
handleChangeTime(selectedItem.key)
|
|
136
|
+
}}
|
|
137
|
+
buttonTextAfterSelection={(selectedItem, index) => {
|
|
138
|
+
return selectedItem.value
|
|
139
|
+
}}
|
|
140
|
+
rowTextForSelection={(item, index) => {
|
|
141
|
+
return item.value
|
|
142
|
+
}}
|
|
143
|
+
buttonStyle={{borderTopRightRadius: 7.6, borderBottomRightRadius: 7.6, ...styles.selectOption}}
|
|
144
|
+
buttonTextStyle={{
|
|
145
|
+
color: theme.colors.disabled,
|
|
146
|
+
fontSize: 12,
|
|
147
|
+
textAlign: 'left',
|
|
148
|
+
marginHorizontal: 0
|
|
149
|
+
}}
|
|
150
|
+
dropdownStyle={{
|
|
151
|
+
borderRadius: 8,
|
|
152
|
+
borderColor: theme.colors.lightGray,
|
|
153
|
+
marginTop: Platform.OS === 'ios' ? 12 : -top
|
|
154
|
+
}}
|
|
155
|
+
rowStyle={{
|
|
156
|
+
borderBottomColor: theme.colors.backgroundGray100,
|
|
157
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
158
|
+
height: 30,
|
|
159
|
+
flexDirection: 'column',
|
|
160
|
+
alignItems: 'flex-start',
|
|
161
|
+
paddingTop: 8,
|
|
162
|
+
paddingHorizontal: 14
|
|
163
|
+
}}
|
|
164
|
+
rowTextStyle={{
|
|
165
|
+
color: theme.colors.disabled,
|
|
166
|
+
fontSize: 12,
|
|
167
|
+
marginHorizontal: 0
|
|
168
|
+
}}
|
|
169
|
+
renderDropdownIcon={() => dropDownIcon()}
|
|
170
|
+
dropdownOverlayColor='transparent'
|
|
171
|
+
/>
|
|
172
|
+
</View>
|
|
173
|
+
</Container>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export const MomentSelector = (props: any) => {
|
|
178
|
+
const [{ configs }] = useConfig()
|
|
179
|
+
|
|
180
|
+
const limitDays = parseInt(configs?.max_days_preorder?.value, 10)
|
|
181
|
+
|
|
182
|
+
const currentDate = new Date()
|
|
183
|
+
const time = limitDays > 1
|
|
184
|
+
? currentDate.getTime() + ((limitDays - 1) * 24 * 60 * 60 * 1000)
|
|
185
|
+
: limitDays === 1 ? currentDate.getTime() : currentDate.getTime() + (6 * 24 * 60 * 60 * 1000)
|
|
186
|
+
|
|
187
|
+
currentDate.setTime(time)
|
|
188
|
+
currentDate.setHours(23)
|
|
189
|
+
currentDate.setMinutes(59)
|
|
190
|
+
|
|
191
|
+
const businessPreorderProps = {
|
|
192
|
+
...props,
|
|
193
|
+
UIComponent: MomentSelectorUI,
|
|
194
|
+
maxDate: currentDate
|
|
195
|
+
}
|
|
196
|
+
return <MomentOptionController {...businessPreorderProps} />
|
|
197
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { ScrollView, TouchableOpacity, View, StyleSheet, Platform } from 'react-native'
|
|
3
|
+
import { useUtils, useLanguage } from 'ordering-components/native'
|
|
4
|
+
import { useTheme } from 'styled-components/native'
|
|
5
|
+
import FastImage from 'react-native-fast-image'
|
|
6
|
+
import { OIcon, OText, OModal } from '../shared'
|
|
7
|
+
import { ProfessionalProfile } from '../ProfessionalProfile'
|
|
8
|
+
import { ProfessionalFilterParams } from '../../types'
|
|
9
|
+
|
|
10
|
+
export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
11
|
+
const {
|
|
12
|
+
professionals,
|
|
13
|
+
professionalSelected,
|
|
14
|
+
handleChangeProfessionalSelected
|
|
15
|
+
} = props
|
|
16
|
+
|
|
17
|
+
const theme = useTheme()
|
|
18
|
+
const [{ optimizeImage }] = useUtils()
|
|
19
|
+
const [, t] = useLanguage()
|
|
20
|
+
const [open, setOpen] = useState(false)
|
|
21
|
+
const [currentProfessional, setCurrentProfessional] = useState(null)
|
|
22
|
+
|
|
23
|
+
const handleOpenProfile = (professional: any) => {
|
|
24
|
+
setCurrentProfessional(professional)
|
|
25
|
+
setOpen(true)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const handleCloseProfile = () => {
|
|
29
|
+
setCurrentProfessional(null)
|
|
30
|
+
setOpen(false)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const styles = StyleSheet.create({
|
|
34
|
+
professionalItem: {
|
|
35
|
+
flexDirection: 'row',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
borderRadius: 7.6,
|
|
38
|
+
padding: 11,
|
|
39
|
+
borderWidth: 1,
|
|
40
|
+
marginRight: 12,
|
|
41
|
+
minHeight: 64
|
|
42
|
+
},
|
|
43
|
+
photoStyle: {
|
|
44
|
+
width: 42,
|
|
45
|
+
height: 42,
|
|
46
|
+
borderRadius: 7.6
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<ScrollView
|
|
53
|
+
horizontal
|
|
54
|
+
showsVerticalScrollIndicator={false}
|
|
55
|
+
showsHorizontalScrollIndicator={false}
|
|
56
|
+
>
|
|
57
|
+
<TouchableOpacity
|
|
58
|
+
onPress={() => handleChangeProfessionalSelected(null)}
|
|
59
|
+
>
|
|
60
|
+
<View
|
|
61
|
+
style={{
|
|
62
|
+
...styles.professionalItem,
|
|
63
|
+
borderColor: !professionalSelected
|
|
64
|
+
? theme.colors.primary
|
|
65
|
+
: theme.colors.border
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
<OText
|
|
69
|
+
size={12}
|
|
70
|
+
weight={'400'}
|
|
71
|
+
>
|
|
72
|
+
{t('ANY_PROFESSIONAL_MEMBER', 'Any professional member')}
|
|
73
|
+
</OText>
|
|
74
|
+
</View>
|
|
75
|
+
</TouchableOpacity>
|
|
76
|
+
{professionals.map((professional: any, i: number) => (
|
|
77
|
+
<TouchableOpacity
|
|
78
|
+
key={i}
|
|
79
|
+
onPress={() => handleOpenProfile(professional)}
|
|
80
|
+
>
|
|
81
|
+
<View
|
|
82
|
+
style={{
|
|
83
|
+
...styles.professionalItem,
|
|
84
|
+
borderColor: (professional?.id === professionalSelected?.id)
|
|
85
|
+
? theme.colors.primary
|
|
86
|
+
: theme.colors.border
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{professional?.photo ? (
|
|
90
|
+
<FastImage
|
|
91
|
+
style={styles.photoStyle}
|
|
92
|
+
source={{
|
|
93
|
+
uri: optimizeImage(professional?.photo, 'h_250,c_limit'),
|
|
94
|
+
priority: FastImage.priority.normal,
|
|
95
|
+
}}
|
|
96
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
97
|
+
/>
|
|
98
|
+
) : (
|
|
99
|
+
<OIcon
|
|
100
|
+
src={theme?.images?.dummies?.product}
|
|
101
|
+
style={styles.photoStyle}
|
|
102
|
+
/>
|
|
103
|
+
)}
|
|
104
|
+
<OText
|
|
105
|
+
size={12}
|
|
106
|
+
style={{ marginLeft: 12 }}
|
|
107
|
+
weight={'400'}
|
|
108
|
+
>
|
|
109
|
+
{professional?.name} {professional?.lastname}
|
|
110
|
+
</OText>
|
|
111
|
+
</View>
|
|
112
|
+
</TouchableOpacity>
|
|
113
|
+
))}
|
|
114
|
+
</ScrollView>
|
|
115
|
+
<OModal
|
|
116
|
+
open={open}
|
|
117
|
+
onClose={() => handleCloseProfile()}
|
|
118
|
+
entireModal
|
|
119
|
+
>
|
|
120
|
+
<ProfessionalProfile
|
|
121
|
+
professional={currentProfessional}
|
|
122
|
+
onClose={() => handleCloseProfile()}
|
|
123
|
+
handleChangeProfessionalSelected={handleChangeProfessionalSelected}
|
|
124
|
+
/>
|
|
125
|
+
</OModal>
|
|
126
|
+
</>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import { StyleSheet, Platform, View, Dimensions } from 'react-native'
|
|
3
|
+
import { useUtils, useLanguage, useConfig } from 'ordering-components/native'
|
|
4
|
+
import { useTheme } from 'styled-components/native'
|
|
5
|
+
import CalendarPicker from 'react-native-calendar-picker'
|
|
6
|
+
import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
7
|
+
import moment from 'moment'
|
|
8
|
+
import SelectDropdown from 'react-native-select-dropdown'
|
|
9
|
+
import { OButton, OText } from '../shared'
|
|
10
|
+
import IconAntDesign from 'react-native-vector-icons/AntDesign'
|
|
11
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
12
|
+
import { ProfessionalProfileParams } from '../../types'
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
Container,
|
|
16
|
+
ProfessionalPhoto,
|
|
17
|
+
InfoWrapper,
|
|
18
|
+
Divider,
|
|
19
|
+
ScheduleWrapper,
|
|
20
|
+
ButtonWrapper,
|
|
21
|
+
CalendarWrapper
|
|
22
|
+
} from './styles'
|
|
23
|
+
|
|
24
|
+
const windowWidth = Dimensions.get('window').width
|
|
25
|
+
|
|
26
|
+
export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
|
|
27
|
+
const {
|
|
28
|
+
professional,
|
|
29
|
+
handleChangeProfessionalSelected,
|
|
30
|
+
onClose
|
|
31
|
+
} = props
|
|
32
|
+
|
|
33
|
+
const [{ optimizeImage }] = useUtils()
|
|
34
|
+
const theme = useTheme()
|
|
35
|
+
const [, t] = useLanguage()
|
|
36
|
+
const [{ configs }] = useConfig()
|
|
37
|
+
const { top } = useSafeAreaInsets()
|
|
38
|
+
|
|
39
|
+
const [selectDate, setSelectedDate] = useState<any>(new Date())
|
|
40
|
+
const [isEnabled, setIsEnabled] = useState(false)
|
|
41
|
+
const [timeList, setTimeList] = useState<any>([])
|
|
42
|
+
const dropdownRef = useRef<any>(null)
|
|
43
|
+
|
|
44
|
+
const styles = StyleSheet.create({
|
|
45
|
+
buttonStyle: {
|
|
46
|
+
borderRadius: 7.6,
|
|
47
|
+
height: 44,
|
|
48
|
+
borderWidth: 0
|
|
49
|
+
},
|
|
50
|
+
selectOption: {
|
|
51
|
+
width: '100%',
|
|
52
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
53
|
+
paddingVertical: 5,
|
|
54
|
+
paddingHorizontal: 14,
|
|
55
|
+
flexDirection: 'row-reverse',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'space-between',
|
|
58
|
+
height: 40,
|
|
59
|
+
marginBottom: 30
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const onDateChange = (date: any) => {
|
|
64
|
+
setSelectedDate(date)
|
|
65
|
+
dropdownRef.current.reset()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const dropDownIcon = () => {
|
|
69
|
+
return (
|
|
70
|
+
<IconAntDesign
|
|
71
|
+
name='down'
|
|
72
|
+
color={theme.colors.textThird}
|
|
73
|
+
size={12}
|
|
74
|
+
/>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const customDayHeaderStylesCallback = () => {
|
|
79
|
+
return {
|
|
80
|
+
textStyle: {
|
|
81
|
+
color: theme.colors.disabled,
|
|
82
|
+
fontSize: 12,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const validateSelectedDate = (curdate: any, menu: any) => {
|
|
88
|
+
const day = moment(curdate).format('d')
|
|
89
|
+
setIsEnabled(menu?.schedule?.[day]?.enabled || false)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const getTimes = (curdate: any, menu: any) => {
|
|
93
|
+
validateSelectedDate(curdate, menu)
|
|
94
|
+
const date = new Date()
|
|
95
|
+
var dateSeleted = new Date(curdate)
|
|
96
|
+
var times = []
|
|
97
|
+
for (var k = 0; k < menu.schedule[dateSeleted.getDay()].lapses.length; k++) {
|
|
98
|
+
var open = {
|
|
99
|
+
hour: menu.schedule[dateSeleted.getDay()].lapses[k].open.hour,
|
|
100
|
+
minute: menu.schedule[dateSeleted.getDay()].lapses[k].open.minute
|
|
101
|
+
}
|
|
102
|
+
var close = {
|
|
103
|
+
hour: menu.schedule[dateSeleted.getDay()].lapses[k].close.hour,
|
|
104
|
+
minute: menu.schedule[dateSeleted.getDay()].lapses[k].close.minute
|
|
105
|
+
}
|
|
106
|
+
for (var i = open.hour; i <= close.hour; i++) {
|
|
107
|
+
if (date.getDate() !== dateSeleted.getDate() || i >= date.getHours()) {
|
|
108
|
+
let hour = ''
|
|
109
|
+
let meridian = ''
|
|
110
|
+
if (configs?.format_time?.value === '12') {
|
|
111
|
+
if (i === 0) {
|
|
112
|
+
hour = '12'
|
|
113
|
+
meridian = ' ' + t('AM', 'AM')
|
|
114
|
+
} else if (i > 0 && i < 12) {
|
|
115
|
+
hour = (i < 10 ? '0' + i : i)
|
|
116
|
+
meridian = ' ' + t('AM', 'AM')
|
|
117
|
+
} else if (i === 12) {
|
|
118
|
+
hour = '12'
|
|
119
|
+
meridian = ' ' + t('PM', 'PM')
|
|
120
|
+
} else {
|
|
121
|
+
hour = ((i - 12 < 10) ? '0' + (i - 12) : `${(i - 12)}`)
|
|
122
|
+
meridian = ' ' + t('PM', 'PM')
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
hour = i < 10 ? '0' + i : i
|
|
126
|
+
}
|
|
127
|
+
for (let j = (i === open.hour ? open.minute : 0); j <= (i === close.hour ? close.minute : 59); j += 15) {
|
|
128
|
+
if (i !== date.getHours() || j >= date.getMinutes() || date.getDate() !== dateSeleted.getDate()) {
|
|
129
|
+
times.push({
|
|
130
|
+
text: hour + ':' + (j < 10 ? '0' + j : j) + meridian,
|
|
131
|
+
value: (i < 10 ? '0' + i : i) + ':' + (j < 10 ? '0' + j : j)
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return times
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const handleSelectProfessional = () => {
|
|
142
|
+
handleChangeProfessionalSelected(professional)
|
|
143
|
+
onClose && onClose()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (selectDate === null) return
|
|
148
|
+
const _times = getTimes(selectDate, professional)
|
|
149
|
+
setTimeList(_times)
|
|
150
|
+
}, [selectDate, professional])
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<Container>
|
|
154
|
+
<ProfessionalPhoto
|
|
155
|
+
source={{
|
|
156
|
+
uri:
|
|
157
|
+
professional?.photo ||
|
|
158
|
+
optimizeImage(theme.images.general.user, 'h_250,c_limit'),
|
|
159
|
+
}}
|
|
160
|
+
/>
|
|
161
|
+
<InfoWrapper>
|
|
162
|
+
<OText
|
|
163
|
+
size={20}
|
|
164
|
+
style={{ marginBottom: 3 }}
|
|
165
|
+
weight={Platform.OS === 'ios' ? '600' : 'bold'}
|
|
166
|
+
>
|
|
167
|
+
{professional?.name} {professional?.lastname}
|
|
168
|
+
</OText>
|
|
169
|
+
</InfoWrapper>
|
|
170
|
+
<Divider />
|
|
171
|
+
<ScheduleWrapper>
|
|
172
|
+
<View
|
|
173
|
+
style={{
|
|
174
|
+
flexDirection: 'row',
|
|
175
|
+
justifyContent: 'space-between',
|
|
176
|
+
alignItems: 'center',
|
|
177
|
+
marginBottom: 23
|
|
178
|
+
}}
|
|
179
|
+
>
|
|
180
|
+
<OText
|
|
181
|
+
size={16}
|
|
182
|
+
weight={Platform.OS === 'ios' ? '600' : 'bold'}
|
|
183
|
+
>
|
|
184
|
+
{t('SCHEDULE', 'Schedule')}
|
|
185
|
+
</OText>
|
|
186
|
+
<OText
|
|
187
|
+
size={10}
|
|
188
|
+
weight={'400'}
|
|
189
|
+
color={theme.colors?.danger5}
|
|
190
|
+
>
|
|
191
|
+
{t('REQUIRED', 'Required')}
|
|
192
|
+
</OText>
|
|
193
|
+
</View>
|
|
194
|
+
{(!!professional?.schedule && isEnabled) ? (
|
|
195
|
+
<CalendarWrapper>
|
|
196
|
+
{timeList?.length > 0 ? (
|
|
197
|
+
<SelectDropdown
|
|
198
|
+
ref={dropdownRef}
|
|
199
|
+
data={timeList}
|
|
200
|
+
onSelect={(selectedItem, index) => {
|
|
201
|
+
console.log(selectedItem.value)
|
|
202
|
+
}}
|
|
203
|
+
buttonTextAfterSelection={(selectedItem, index) => {
|
|
204
|
+
return selectedItem.text
|
|
205
|
+
}}
|
|
206
|
+
rowTextForSelection={(item, index) => {
|
|
207
|
+
return item.text
|
|
208
|
+
}}
|
|
209
|
+
buttonStyle={{borderRadius: 7.6, ...styles.selectOption}}
|
|
210
|
+
buttonTextStyle={{
|
|
211
|
+
color: theme.colors.disabled,
|
|
212
|
+
fontSize: 14,
|
|
213
|
+
textAlign: 'left',
|
|
214
|
+
marginHorizontal: 0
|
|
215
|
+
}}
|
|
216
|
+
dropdownStyle={{
|
|
217
|
+
borderRadius: 8,
|
|
218
|
+
borderColor: theme.colors.lightGray,
|
|
219
|
+
marginTop: Platform.OS === 'ios' ? 12 : -top
|
|
220
|
+
}}
|
|
221
|
+
rowStyle={{
|
|
222
|
+
borderBottomColor: theme.colors.backgroundGray100,
|
|
223
|
+
backgroundColor: theme.colors.backgroundGray100,
|
|
224
|
+
height: 30,
|
|
225
|
+
flexDirection: 'column',
|
|
226
|
+
alignItems: 'flex-start',
|
|
227
|
+
paddingTop: 8,
|
|
228
|
+
paddingHorizontal: 12
|
|
229
|
+
}}
|
|
230
|
+
rowTextStyle={{
|
|
231
|
+
color: theme.colors.disabled,
|
|
232
|
+
fontSize: 14,
|
|
233
|
+
marginHorizontal: 0
|
|
234
|
+
}}
|
|
235
|
+
renderDropdownIcon={() => dropDownIcon()}
|
|
236
|
+
dropdownOverlayColor='transparent'
|
|
237
|
+
/>
|
|
238
|
+
) : (
|
|
239
|
+
<OText
|
|
240
|
+
size={20}
|
|
241
|
+
style={{ marginBottom: 30 }}
|
|
242
|
+
weight={Platform.OS === 'ios' ? '600' : 'bold'}
|
|
243
|
+
>
|
|
244
|
+
{t('NOT_AVAILABLE', 'Not available')}
|
|
245
|
+
</OText>
|
|
246
|
+
)}
|
|
247
|
+
|
|
248
|
+
<CalendarPicker
|
|
249
|
+
previousComponent={
|
|
250
|
+
<FeatherIcon
|
|
251
|
+
name='chevron-left'
|
|
252
|
+
color={theme.colors.disabled}
|
|
253
|
+
size={24}
|
|
254
|
+
style={{ marginHorizontal: 4 }}
|
|
255
|
+
/>
|
|
256
|
+
}
|
|
257
|
+
nextComponent={
|
|
258
|
+
<FeatherIcon
|
|
259
|
+
name='chevron-right'
|
|
260
|
+
color={theme.colors.disabled}
|
|
261
|
+
size={24}
|
|
262
|
+
style={{ marginHorizontal: 4 }}
|
|
263
|
+
/>
|
|
264
|
+
}
|
|
265
|
+
width={windowWidth - 110}
|
|
266
|
+
selectedDayTextColor={theme.colors.white}
|
|
267
|
+
selectedDayColor={theme.colors.primary}
|
|
268
|
+
todayBackgroundColor={theme.colors.border}
|
|
269
|
+
dayLabelsWrapper={{ borderColor: theme.colors.clear }}
|
|
270
|
+
onDateChange={onDateChange}
|
|
271
|
+
minDate={new Date()}
|
|
272
|
+
customDayHeaderStyles={customDayHeaderStylesCallback}
|
|
273
|
+
selectedStartDate={selectDate}
|
|
274
|
+
/>
|
|
275
|
+
</CalendarWrapper>
|
|
276
|
+
) : (
|
|
277
|
+
<OText
|
|
278
|
+
size={20}
|
|
279
|
+
style={{ marginBottom: 30 }}
|
|
280
|
+
weight={Platform.OS === 'ios' ? '600' : 'bold'}
|
|
281
|
+
>
|
|
282
|
+
{t('NO_SCHEDULE', 'No schedule')}
|
|
283
|
+
</OText>
|
|
284
|
+
)}
|
|
285
|
+
</ScheduleWrapper>
|
|
286
|
+
<ButtonWrapper>
|
|
287
|
+
<OButton
|
|
288
|
+
bgColor={theme.colors.primary}
|
|
289
|
+
onClick={() => handleSelectProfessional()}
|
|
290
|
+
text={t('BOOK', 'Book')}
|
|
291
|
+
style={styles.buttonStyle}
|
|
292
|
+
textStyle={{ fontSize: 14, color: theme.colors.white }}
|
|
293
|
+
/>
|
|
294
|
+
</ButtonWrapper>
|
|
295
|
+
</Container>
|
|
296
|
+
)
|
|
297
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import styled from 'styled-components/native'
|
|
2
|
+
|
|
3
|
+
export const Container = styled.ScrollView``
|
|
4
|
+
|
|
5
|
+
export const ProfessionalPhoto = styled.ImageBackground`
|
|
6
|
+
width: 100%;
|
|
7
|
+
position: relative;
|
|
8
|
+
max-height: 258px;
|
|
9
|
+
height: 258px;
|
|
10
|
+
resize-mode: cover;
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const InfoWrapper = styled.View`
|
|
14
|
+
margin-vertical: 30px;
|
|
15
|
+
padding-horizontal: 40px;
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
export const Divider = styled.View`
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 8px;
|
|
21
|
+
background-color: ${(props: any) => props.theme.colors.backgroundGray100};
|
|
22
|
+
`
|
|
23
|
+
|
|
24
|
+
export const ScheduleWrapper = styled.View`
|
|
25
|
+
padding-horizontal: 40px;
|
|
26
|
+
margin-top: 30px;
|
|
27
|
+
`
|
|
28
|
+
|
|
29
|
+
export const ButtonWrapper = styled.View`
|
|
30
|
+
justify-content: center;
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
padding-vertical: 13px;
|
|
33
|
+
margin-top: 30px;
|
|
34
|
+
margin-bottom: 40px;
|
|
35
|
+
width: 100%;
|
|
36
|
+
border-top-width: 1px;
|
|
37
|
+
border-top-color: ${(props: any) => props.theme.colors.backgroundGray200};
|
|
38
|
+
`
|
|
39
|
+
|
|
40
|
+
export const CalendarWrapper = styled.View`
|
|
41
|
+
flex: 1;
|
|
42
|
+
border-width: 1px;
|
|
43
|
+
border-color: ${(props: any) => props.theme.colors.backgroundGray200};
|
|
44
|
+
border-radius: 7.6px;
|
|
45
|
+
padding: 15px;
|
|
46
|
+
`
|