ordering-ui-react-native 0.17.98 → 0.17.99
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 +1 -1
- package/themes/business/src/components/PreviousOrders/index.tsx +2 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +1 -0
- package/themes/original/src/components/ProfessionalFilter/SingleProfessionalCard/index.tsx +108 -0
- package/themes/original/src/components/ProfessionalFilter/index.tsx +20 -50
- package/themes/original/src/components/ProfessionalProfile/index.tsx +1 -1
- package/themes/original/src/components/ServiceForm/index.tsx +11 -3
- package/themes/original/src/types/index.tsx +2 -1
package/package.json
CHANGED
|
@@ -93,7 +93,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
93
93
|
imgRightSrc={null}
|
|
94
94
|
style={{ borderRadius: 7, height: 40 }}
|
|
95
95
|
parentStyle={{ width: '45%' }}
|
|
96
|
-
textStyle={{ color: theme.colors.
|
|
96
|
+
textStyle={{ color: theme.colors.white }}
|
|
97
97
|
/>
|
|
98
98
|
<OButton
|
|
99
99
|
text={t('ACCEPT', 'Accept')}
|
|
@@ -103,7 +103,7 @@ export const PreviousOrders = (props: any) => {
|
|
|
103
103
|
imgRightSrc={null}
|
|
104
104
|
style={{ borderRadius: 7, height: 40 }}
|
|
105
105
|
parentStyle={{ width: '45%' }}
|
|
106
|
-
textStyle={{ color: theme.colors.
|
|
106
|
+
textStyle={{ color: theme.colors.white }}
|
|
107
107
|
/>
|
|
108
108
|
</>
|
|
109
109
|
)}
|
|
@@ -448,6 +448,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
448
448
|
professionals={business?.professionals}
|
|
449
449
|
professionalSelected={professionalSelected}
|
|
450
450
|
handleChangeProfessionalSelected={handleChangeProfessionalSelected}
|
|
451
|
+
handleUpdateProfessionals={handleUpdateProfessionals}
|
|
451
452
|
/>
|
|
452
453
|
</ProfessionalFilterWrapper>
|
|
453
454
|
)}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
useSession,
|
|
4
|
+
useUtils,
|
|
5
|
+
SingleProfessionalCard as SingleProfessionalCardController
|
|
6
|
+
} from 'ordering-components/native'
|
|
7
|
+
import { useTheme } from 'styled-components/native'
|
|
8
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
9
|
+
import FastImage from 'react-native-fast-image'
|
|
10
|
+
import { OIcon, OText } from '../../shared'
|
|
11
|
+
import IconAntDesign from 'react-native-vector-icons/AntDesign';
|
|
12
|
+
|
|
13
|
+
const SingleProfessionalCardUI = (props) => {
|
|
14
|
+
const {
|
|
15
|
+
professional,
|
|
16
|
+
handleFavoriteProfessional,
|
|
17
|
+
active,
|
|
18
|
+
handleProfessionalClick
|
|
19
|
+
} = props
|
|
20
|
+
|
|
21
|
+
const theme = useTheme()
|
|
22
|
+
const [{ auth }] = useSession()
|
|
23
|
+
const [{ optimizeImage }] = useUtils()
|
|
24
|
+
|
|
25
|
+
const handleChangeFavorite = () => {
|
|
26
|
+
if (auth) {
|
|
27
|
+
handleFavoriteProfessional && handleFavoriteProfessional(!professional?.favorite)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
professionalItem: {
|
|
33
|
+
flexDirection: 'row',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
borderRadius: 7.6,
|
|
36
|
+
padding: 11,
|
|
37
|
+
borderWidth: 1,
|
|
38
|
+
marginRight: 12,
|
|
39
|
+
minHeight: 64
|
|
40
|
+
},
|
|
41
|
+
photoStyle: {
|
|
42
|
+
width: 42,
|
|
43
|
+
height: 42,
|
|
44
|
+
borderRadius: 7.6
|
|
45
|
+
},
|
|
46
|
+
favoriteIconStyle: {
|
|
47
|
+
width: 16,
|
|
48
|
+
height: 16,
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<TouchableOpacity
|
|
54
|
+
onPress={() => handleProfessionalClick(professional)}
|
|
55
|
+
>
|
|
56
|
+
<View
|
|
57
|
+
style={{
|
|
58
|
+
...styles.professionalItem,
|
|
59
|
+
borderColor: active
|
|
60
|
+
? theme.colors.primary
|
|
61
|
+
: theme.colors.border
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
{professional?.photo ? (
|
|
65
|
+
<FastImage
|
|
66
|
+
style={styles.photoStyle}
|
|
67
|
+
source={{
|
|
68
|
+
uri: optimizeImage(professional?.photo, 'h_250,c_limit'),
|
|
69
|
+
priority: FastImage.priority.normal,
|
|
70
|
+
}}
|
|
71
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
72
|
+
/>
|
|
73
|
+
) : (
|
|
74
|
+
<OIcon
|
|
75
|
+
src={theme?.images?.general?.user}
|
|
76
|
+
cover={false}
|
|
77
|
+
style={styles.photoStyle}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
<View style={{ marginLeft: 12 }}>
|
|
81
|
+
<OText
|
|
82
|
+
size={12}
|
|
83
|
+
weight={'400'}
|
|
84
|
+
>
|
|
85
|
+
{professional?.name} {professional?.lastname}
|
|
86
|
+
</OText>
|
|
87
|
+
|
|
88
|
+
<TouchableOpacity
|
|
89
|
+
onPress={() => handleChangeFavorite()}
|
|
90
|
+
>
|
|
91
|
+
{professional?.favorite
|
|
92
|
+
? <IconAntDesign name='heart' size={16} color={theme.colors.danger5} />
|
|
93
|
+
: <IconAntDesign name='hearto' size={16} color={theme.colors.danger5} />
|
|
94
|
+
}
|
|
95
|
+
</TouchableOpacity>
|
|
96
|
+
</View>
|
|
97
|
+
</View>
|
|
98
|
+
</TouchableOpacity>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const SingleProfessionalCard = (props) => {
|
|
103
|
+
const singleProfessionalCardProps = {
|
|
104
|
+
...props,
|
|
105
|
+
UIComponent: SingleProfessionalCardUI
|
|
106
|
+
}
|
|
107
|
+
return <SingleProfessionalCardController {...singleProfessionalCardProps} />
|
|
108
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import { ScrollView, TouchableOpacity, View, StyleSheet
|
|
3
|
-
import {
|
|
2
|
+
import { ScrollView, TouchableOpacity, View, StyleSheet } from 'react-native'
|
|
3
|
+
import { useLanguage } from 'ordering-components/native'
|
|
4
4
|
import { useTheme } from 'styled-components/native'
|
|
5
|
-
import
|
|
6
|
-
import { OIcon, OText, OModal } from '../shared'
|
|
5
|
+
import { OText, OModal } from '../shared'
|
|
7
6
|
import { ProfessionalProfile } from '../ProfessionalProfile'
|
|
8
7
|
import { ProfessionalFilterParams } from '../../types'
|
|
8
|
+
import { SingleProfessionalCard } from './SingleProfessionalCard'
|
|
9
9
|
|
|
10
10
|
export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
11
11
|
const {
|
|
12
12
|
professionals,
|
|
13
13
|
professionalSelected,
|
|
14
|
-
handleChangeProfessionalSelected
|
|
14
|
+
handleChangeProfessionalSelected,
|
|
15
|
+
handleUpdateProfessionals
|
|
15
16
|
} = props
|
|
16
17
|
|
|
17
18
|
const theme = useTheme()
|
|
18
|
-
const [{ optimizeImage }] = useUtils()
|
|
19
19
|
const [, t] = useLanguage()
|
|
20
20
|
const [open, setOpen] = useState(false)
|
|
21
21
|
const [currentProfessional, setCurrentProfessional] = useState(null)
|
|
@@ -30,6 +30,11 @@ export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
|
30
30
|
setOpen(false)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
const onUpdateProfessionals = (id, changes) => {
|
|
34
|
+
const updatedProfessional = professionals.find(professional => professional.id === id)
|
|
35
|
+
handleUpdateProfessionals({ ...updatedProfessional, ...changes })
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
const styles = StyleSheet.create({
|
|
34
39
|
professionalItem: {
|
|
35
40
|
flexDirection: 'row',
|
|
@@ -39,12 +44,7 @@ export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
|
39
44
|
borderWidth: 1,
|
|
40
45
|
marginRight: 12,
|
|
41
46
|
minHeight: 64
|
|
42
|
-
}
|
|
43
|
-
photoStyle: {
|
|
44
|
-
width: 42,
|
|
45
|
-
height: 42,
|
|
46
|
-
borderRadius: 7.6
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
return (
|
|
@@ -73,44 +73,14 @@ export const ProfessionalFilter = (props: ProfessionalFilterParams) => {
|
|
|
73
73
|
</OText>
|
|
74
74
|
</View>
|
|
75
75
|
</TouchableOpacity>
|
|
76
|
-
{professionals.map((professional: any
|
|
77
|
-
<
|
|
78
|
-
key={
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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?.general?.user}
|
|
101
|
-
cover={false}
|
|
102
|
-
style={styles.photoStyle}
|
|
103
|
-
/>
|
|
104
|
-
)}
|
|
105
|
-
<OText
|
|
106
|
-
size={12}
|
|
107
|
-
style={{ marginLeft: 12 }}
|
|
108
|
-
weight={'400'}
|
|
109
|
-
>
|
|
110
|
-
{professional?.name} {professional?.lastname}
|
|
111
|
-
</OText>
|
|
112
|
-
</View>
|
|
113
|
-
</TouchableOpacity>
|
|
76
|
+
{professionals.map((professional: any) => (
|
|
77
|
+
<SingleProfessionalCard
|
|
78
|
+
key={professional.id}
|
|
79
|
+
professional={professional}
|
|
80
|
+
active={professional?.id === professionalSelected?.id}
|
|
81
|
+
handleProfessionalClick={handleOpenProfile}
|
|
82
|
+
handleUpdateProfessionals={onUpdateProfessionals}
|
|
83
|
+
/>
|
|
114
84
|
))}
|
|
115
85
|
</ScrollView>
|
|
116
86
|
<OModal
|
|
@@ -147,7 +147,7 @@ export const ProfessionalProfile = (props: ProfessionalProfileParams) => {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
useEffect(() => {
|
|
150
|
-
if (selectDate === null) return
|
|
150
|
+
if (selectDate === null || !professional?.schedule) return
|
|
151
151
|
const _times = getTimes(selectDate, professional)
|
|
152
152
|
setTimeList(_times)
|
|
153
153
|
}, [selectDate, professional])
|
|
@@ -117,16 +117,24 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
117
117
|
})
|
|
118
118
|
|
|
119
119
|
const isBusyTime = (professional: any) => {
|
|
120
|
-
if (
|
|
120
|
+
if (!dateSelected) return false
|
|
121
|
+
const startDay = moment(dateSelected).utc().format('d')
|
|
122
|
+
const isStartScheduleEnabled = professional?.schedule?.[startDay]?.enabled
|
|
121
123
|
const duration = product?.duration ?? 0
|
|
124
|
+
const endDay = moment(dateSelected).add(duration - 1, 'minutes').utc().format('d')
|
|
125
|
+
const isEndScheduleEnabled = professional?.schedule?.[endDay]?.enabled
|
|
126
|
+
if (!isStartScheduleEnabled || !isEndScheduleEnabled) return true
|
|
127
|
+
|
|
128
|
+
if (professional?.busy_times?.length === 0) return false
|
|
129
|
+
|
|
122
130
|
const busyTimes = isCartProduct
|
|
123
131
|
? professional?.busy_times.filter((item: any) => !(item.start === productCart?.calendar_event?.start && item.end === productCart?.calendar_event?.end))
|
|
124
132
|
: [...professional?.busy_times]
|
|
125
133
|
const valid = busyTimes.some((item: any) => {
|
|
126
134
|
return (moment.utc(item?.start).local().valueOf() <= moment(dateSelected).valueOf() &&
|
|
127
|
-
moment(dateSelected).valueOf()
|
|
135
|
+
moment(dateSelected).valueOf() < moment.utc(item?.end).local().valueOf()) ||
|
|
128
136
|
(moment.utc(item?.start).local().valueOf() <= moment(dateSelected).add(duration, 'minutes').valueOf() &&
|
|
129
|
-
moment(dateSelected).add(duration, 'minutes').valueOf()
|
|
137
|
+
moment(dateSelected).add(duration, 'minutes').valueOf() < moment.utc(item?.end).local().valueOf())
|
|
130
138
|
})
|
|
131
139
|
return valid
|
|
132
140
|
}
|
|
@@ -778,7 +778,8 @@ export interface ServiceFormParams {
|
|
|
778
778
|
export interface ProfessionalFilterParams {
|
|
779
779
|
professionals?: any,
|
|
780
780
|
professionalSelected?: any,
|
|
781
|
-
handleChangeProfessionalSelected: any
|
|
781
|
+
handleChangeProfessionalSelected: any,
|
|
782
|
+
handleUpdateProfessionals?: any
|
|
782
783
|
}
|
|
783
784
|
|
|
784
785
|
export interface ProfessionalProfileParams {
|