ordering-ui-react-native 0.16.28 → 0.16.31

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 (26) hide show
  1. package/package.json +2 -1
  2. package/src/components/AddressForm/index.tsx +15 -2
  3. package/themes/original/index.tsx +8 -0
  4. package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
  5. package/themes/original/src/components/BusinessListingSearch/index.tsx +3 -2
  6. package/themes/original/src/components/BusinessProductsListing/index.tsx +255 -208
  7. package/themes/original/src/components/BusinessProductsListing/styles.tsx +5 -0
  8. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
  9. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  10. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +549 -0
  11. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +106 -0
  12. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +519 -0
  13. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Original/styles.tsx} +0 -0
  14. package/themes/original/src/components/BusinessesListing/index.tsx +13 -515
  15. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  16. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  17. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +7 -4
  18. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +14 -12
  19. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  20. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  21. package/themes/original/src/components/ProfessionalProfile/index.tsx +297 -0
  22. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  23. package/themes/original/src/components/ServiceForm/index.tsx +485 -0
  24. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  25. package/themes/original/src/types/index.tsx +31 -1
  26. package/themes/original/src/utils/index.tsx +11 -0
@@ -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
+ `