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,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,6 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View`
4
+ flex-direction: row;
5
+ width: 100%;
6
+ `
@@ -7,11 +7,12 @@ import { ListWrapper } from './styles'
7
7
  import {
8
8
  View,
9
9
  StyleSheet,
10
- ScrollView
10
+ ScrollView,
11
+ Dimensions
11
12
  } from 'react-native';
12
13
  import { PreviousBusinessOrderedParams } from '../../../types';
13
14
 
14
- export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams) => {
15
+ export const PreviousBusinessOrderedUI = (props: PreviousBusinessOrderedParams) => {
15
16
  const {
16
17
  navigation,
17
18
  businessesList,
@@ -23,6 +24,8 @@ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams)
23
24
  } = props
24
25
 
25
26
  const [orderState] = useOrder()
27
+ const windowWidth = Dimensions.get('window').width;
28
+
26
29
  const onBusinessClick = (business: any) => {
27
30
  onNavigationRedirect('Business', { store: business.slug })
28
31
  }
@@ -120,7 +123,7 @@ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams)
120
123
  <>
121
124
  {!businessLoading && (
122
125
  <BusinessControllerList
123
- style={{ width: 320, marginRight: 20 }}
126
+ style={{ width: windowWidth - 80, marginRight: 20 }}
124
127
  />
125
128
  )}
126
129
  </>
@@ -137,7 +140,7 @@ export const PreviousBusinessOrderedUI = (props : PreviousBusinessOrderedParams)
137
140
  )
138
141
  }
139
142
 
140
- export const PreviousBusinessOrdered = (props) => {
143
+ export const PreviousBusinessOrdered = (props: PreviousBusinessOrderedParams) => {
141
144
  const previousBusinessOrderedController = {
142
145
  ...props,
143
146
  UIComponent: PreviousBusinessOrderedUI,
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { ScrollView, StyleSheet } from 'react-native'
2
+ import { ScrollView, StyleSheet, Dimensions } from 'react-native'
3
3
  import {
4
4
  ListWrapper
5
5
  } from './styles'
@@ -7,13 +7,15 @@ import {
7
7
  import { SingleProductCard } from '../../SingleProductCard'
8
8
  import { PreviousProductsOrderedParams } from '../../../types'
9
9
 
10
- export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) => {
10
+ export const PreviousProductsOrdered = (props: PreviousProductsOrderedParams) => {
11
11
  const {
12
12
  products,
13
13
  onProductClick,
14
14
  isBusinessesSearchList
15
15
  } = props
16
16
 
17
+ const windowWidth = Dimensions.get('window').width;
18
+
17
19
  const styles = StyleSheet.create({
18
20
  container: {
19
21
  marginBottom: 0,
@@ -24,15 +26,15 @@ export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) =
24
26
  return (
25
27
  <>
26
28
  {products?.map((product: any) => (
27
- <SingleProductCard
28
- key={product?.id}
29
- isSoldOut={(product.inventoried && !product.quantity)}
30
- product={product}
31
- businessId={product?.business?.id}
32
- onProductClick={onProductClick}
33
- style={style}
34
- productAddedToCartLength={0}
35
- />
29
+ <SingleProductCard
30
+ key={product?.id}
31
+ isSoldOut={(product.inventoried && !product.quantity)}
32
+ product={product}
33
+ businessId={product?.business?.id}
34
+ onProductClick={onProductClick}
35
+ style={style}
36
+ productAddedToCartLength={0}
37
+ />
36
38
  ))}
37
39
  </>
38
40
  )
@@ -40,7 +42,7 @@ export const PreviousProductsOrdered = (props : PreviousProductsOrderedParams) =
40
42
  return (
41
43
  <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
42
44
  {isBusinessesSearchList ? (
43
- <ProductList style={{ width: 320, marginRight: 20 }} />
45
+ <ProductList style={{ width: windowWidth - 80, marginRight: 20 }} />
44
46
  ) : (
45
47
  <ListWrapper isBusinessesSearchList={isBusinessesSearchList}>
46
48
  <ProductList />
@@ -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
+ }