ordering-ui-react-native 0.16.17 → 0.16.18-release

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 (203) hide show
  1. package/package.json +7 -4
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  5. package/src/components/AddressForm/index.tsx +18 -2
  6. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  7. package/src/components/BusinessController/index.tsx +10 -8
  8. package/src/components/BusinessInformation/index.tsx +33 -4
  9. package/src/components/BusinessInformation/styles.tsx +2 -2
  10. package/src/components/BusinessProductsList/index.tsx +10 -10
  11. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  12. package/src/components/BusinessesListing/index.tsx +1 -1
  13. package/src/components/Checkout/index.tsx +2 -1
  14. package/src/components/LanguageSelector/index.tsx +21 -16
  15. package/src/components/LoginForm/index.tsx +118 -30
  16. package/src/components/LoginForm/styles.tsx +6 -0
  17. package/src/components/Messages/index.tsx +2 -2
  18. package/src/components/NotificationSetting/index.tsx +85 -0
  19. package/src/components/OrderDetails/index.tsx +2 -20
  20. package/src/components/OrdersOption/index.tsx +54 -56
  21. package/src/components/PaymentOptions/index.tsx +335 -365
  22. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  23. package/src/components/ReviewDriver/index.tsx +1 -1
  24. package/src/components/ReviewOrder/index.tsx +2 -1
  25. package/src/components/ReviewProducts/index.tsx +11 -0
  26. package/src/components/SignupForm/index.tsx +143 -61
  27. package/src/components/SingleProductReview/index.tsx +8 -5
  28. package/src/components/StripeElementsForm/index.tsx +25 -16
  29. package/src/components/VerifyPhone/styles.tsx +1 -2
  30. package/src/components/shared/OBottomPopup.tsx +6 -2
  31. package/src/index.tsx +2 -0
  32. package/src/pages/BusinessesListing.tsx +7 -6
  33. package/src/pages/OrderDetails.tsx +1 -1
  34. package/src/pages/ReviewDriver.tsx +2 -2
  35. package/src/pages/ReviewOrder.tsx +2 -2
  36. package/src/theme.json +0 -1
  37. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  38. package/src/types/index.tsx +13 -9
  39. package/src/utils/index.tsx +0 -1
  40. package/themes/business/index.tsx +4 -0
  41. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  42. package/themes/business/src/components/Chat/index.tsx +42 -34
  43. package/themes/business/src/components/DriverMap/index.tsx +7 -5
  44. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  45. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  46. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  47. package/themes/business/src/components/MapView/index.tsx +12 -1
  48. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  49. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  50. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -3
  51. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +25 -19
  52. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  53. package/themes/business/src/components/OrdersOption/index.tsx +65 -21
  54. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  55. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  56. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  57. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  58. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  59. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  60. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  61. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  62. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  63. package/themes/business/src/components/PreviousOrders/index.tsx +21 -23
  64. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  65. package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
  66. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  67. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  68. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  69. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  70. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  71. package/themes/business/src/components/shared/OModal.tsx +40 -37
  72. package/themes/business/src/types/index.tsx +15 -9
  73. package/themes/business/src/utils/index.tsx +10 -0
  74. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  75. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  76. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  77. package/themes/kiosk/src/components/BusinessMenu/index.tsx +2 -1
  78. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  79. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +1 -0
  80. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  81. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  82. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  83. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  84. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  85. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  86. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  87. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  88. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  89. package/themes/kiosk/src/types/index.d.ts +2 -0
  90. package/themes/original/index.tsx +12 -0
  91. package/themes/original/src/components/AddressForm/index.tsx +136 -133
  92. package/themes/original/src/components/AddressList/index.tsx +1 -1
  93. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  94. package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
  95. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  96. package/themes/original/src/components/BusinessController/index.tsx +173 -108
  97. package/themes/original/src/components/BusinessItemAccordion/index.tsx +9 -7
  98. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +4 -0
  99. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  100. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  101. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  102. package/themes/original/src/components/BusinessListingSearch/index.tsx +106 -126
  103. package/themes/original/src/components/BusinessListingSearch/styles.tsx +18 -13
  104. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  105. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  106. package/themes/original/src/components/BusinessProductsList/index.tsx +49 -52
  107. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  108. package/themes/original/src/components/BusinessProductsListing/index.tsx +278 -175
  109. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -8
  110. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  111. package/themes/original/src/components/BusinessTypeFilter/index.tsx +109 -40
  112. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  113. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
  114. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  115. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +676 -0
  116. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  117. package/themes/original/src/components/BusinessesListing/index.tsx +103 -495
  118. package/themes/original/src/components/Cart/index.tsx +42 -10
  119. package/themes/original/src/components/Cart/styles.tsx +4 -0
  120. package/themes/original/src/components/CartContent/index.tsx +22 -16
  121. package/themes/original/src/components/Checkout/index.tsx +106 -66
  122. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  123. package/themes/original/src/components/DriverTips/index.tsx +4 -4
  124. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  125. package/themes/original/src/components/Favorite/index.tsx +1 -0
  126. package/themes/original/src/components/Favorite/styles.tsx +1 -0
  127. package/themes/original/src/components/FavoriteList/index.tsx +142 -93
  128. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  129. package/themes/original/src/components/GoogleMap/index.tsx +20 -12
  130. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
  131. package/themes/original/src/components/HelpGuide/index.tsx +8 -3
  132. package/themes/original/src/components/HelpOrder/index.tsx +8 -3
  133. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  134. package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -2
  135. package/themes/original/src/components/LoginForm/index.tsx +79 -42
  136. package/themes/original/src/components/Messages/index.tsx +17 -17
  137. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  138. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  139. package/themes/original/src/components/MultiCheckout/index.tsx +13 -1
  140. package/themes/original/src/components/MultiOrdersDetails/index.tsx +21 -17
  141. package/themes/original/src/components/MyOrders/index.tsx +68 -6
  142. package/themes/original/src/components/NavBar/index.tsx +11 -5
  143. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  144. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  145. package/themes/original/src/components/Notifications/index.tsx +148 -0
  146. package/themes/original/src/components/Notifications/styles.tsx +17 -0
  147. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  148. package/themes/original/src/components/OrderDetails/index.tsx +200 -42
  149. package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
  150. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  151. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  152. package/themes/original/src/components/OrderProgress/index.tsx +8 -2
  153. package/themes/original/src/components/OrderSummary/index.tsx +1 -34
  154. package/themes/original/src/components/OrderTypeSelector/index.tsx +84 -36
  155. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  156. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +100 -106
  157. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +17 -12
  158. package/themes/original/src/components/OrdersOption/index.tsx +38 -23
  159. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  160. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  161. package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
  162. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  163. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  164. package/themes/original/src/components/ProductForm/index.tsx +712 -655
  165. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  166. package/themes/original/src/components/ProductItemAccordion/index.tsx +170 -128
  167. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  168. package/themes/original/src/components/ProfessionalFilter/index.tsx +129 -0
  169. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  170. package/themes/original/src/components/ProfessionalProfile/index.tsx +309 -0
  171. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  172. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  173. package/themes/original/src/components/ReviewOrder/index.tsx +18 -3
  174. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  175. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  176. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  177. package/themes/original/src/components/SearchBar/index.tsx +10 -5
  178. package/themes/original/src/components/ServiceForm/index.tsx +631 -0
  179. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  180. package/themes/original/src/components/SignupForm/index.tsx +301 -158
  181. package/themes/original/src/components/SingleOrderCard/index.tsx +213 -179
  182. package/themes/original/src/components/SingleProductCard/index.tsx +194 -108
  183. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  184. package/themes/original/src/components/SingleProductReview/index.tsx +30 -3
  185. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  186. package/themes/original/src/components/StripeElementsForm/index.tsx +15 -7
  187. package/themes/original/src/components/UpsellingProducts/index.tsx +14 -4
  188. package/themes/original/src/components/UserDetails/index.tsx +31 -17
  189. package/themes/original/src/components/UserFormDetails/index.tsx +74 -81
  190. package/themes/original/src/components/UserProfile/index.tsx +57 -29
  191. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  192. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  193. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  194. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  195. package/themes/original/src/components/Wallets/index.tsx +174 -162
  196. package/themes/original/src/components/Wallets/styles.tsx +10 -8
  197. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  198. package/themes/original/src/components/shared/OButton.tsx +10 -3
  199. package/themes/original/src/components/shared/OInput.tsx +3 -2
  200. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  201. package/themes/original/src/types/index.tsx +123 -30
  202. package/themes/original/src/utils/index.tsx +77 -0
  203. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -0,0 +1,631 @@
1
+ import React, { useState, useEffect, useRef } from 'react'
2
+ import { useTheme } from 'styled-components/native'
3
+ import { Platform, View, StyleSheet, Dimensions, ScrollView, TouchableOpacity } from 'react-native'
4
+ import { OText, OButton, OModal, OIcon } from '../shared'
5
+ import FastImage from 'react-native-fast-image'
6
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
7
+ import SelectDropdown from 'react-native-select-dropdown'
8
+ import moment from 'moment'
9
+ import CalendarPicker from 'react-native-calendar-picker'
10
+ import FeatherIcon from 'react-native-vector-icons/Feather';
11
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
12
+ import { ServiceFormParams } from '../../types'
13
+ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
14
+
15
+ import {
16
+ ProductForm as ProductFormController,
17
+ useUtils,
18
+ useLanguage,
19
+ useConfig,
20
+ useOrder,
21
+ useSession
22
+ } from 'ordering-components/native'
23
+
24
+ import {
25
+ Container,
26
+ ProfessionalPhoto,
27
+ InfoWrapper,
28
+ Divider,
29
+ ProfessionalWrapper,
30
+ ScheduleWrapper,
31
+ CalendarWrapper,
32
+ ButtonWrapper
33
+ } from './styles'
34
+
35
+ const screenWidth = Dimensions.get('window').width
36
+
37
+ const ServiceFormUI = (props: ServiceFormParams) => {
38
+ const {
39
+ professionalSelected,
40
+ productObject,
41
+ handleSave,
42
+ productCart,
43
+ navigation,
44
+ isSoldOut,
45
+ maxProductQuantity,
46
+ onClose,
47
+ professionalListState,
48
+ isCartProduct
49
+ } = props
50
+
51
+ const theme = useTheme()
52
+ const [, t] = useLanguage()
53
+ const [{ optimizeImage, parsePrice, parseDate }] = useUtils()
54
+ const { top } = useSafeAreaInsets()
55
+ const [{ configs }] = useConfig()
56
+ const [orderState] = useOrder()
57
+ const [{ auth }] = useSession()
58
+ const { product, loading, error } = productObject;
59
+
60
+ const [selectDate, setSelectedDate] = useState<any>(new Date())
61
+ const [timeList, setTimeList] = useState<any>([])
62
+ const [isEnabled, setIsEnabled] = useState(false)
63
+ const [timeSelected, setTimeSelected] = useState(null)
64
+ const [dateSelected, setDateSelected] = useState<any>(null)
65
+ const [isOpen, setIsOpen] = useState(false)
66
+ const [currentProfessional, setCurrentProfessional] = useState<any>(null)
67
+
68
+ const dropdownRef = useRef<any>(null)
69
+
70
+ const styles = StyleSheet.create({
71
+ photoStyle: {
72
+ width: 45,
73
+ height: 45,
74
+ borderRadius: 7.6
75
+ },
76
+ buttonStyle: {
77
+ borderRadius: 7.6,
78
+ height: 44,
79
+ borderWidth: 0
80
+ },
81
+ professionalSelect: {
82
+ borderRadius: 7.6,
83
+ padding: 11,
84
+ borderWidth: 1,
85
+ borderColor: theme.colors.backgroundGray200,
86
+ flexDirection: 'row',
87
+ alignItems: 'center',
88
+ justifyContent: 'space-between'
89
+ },
90
+ professionalItem: {
91
+ paddingVertical: 11,
92
+ borderColor: theme.colors.backgroundGray200,
93
+ borderTopWidth: 1
94
+ },
95
+ selectOption: {
96
+ width: '100%',
97
+ backgroundColor: theme.colors.backgroundGray100,
98
+ paddingVertical: 5,
99
+ paddingHorizontal: 14,
100
+ flexDirection: 'row-reverse',
101
+ alignItems: 'center',
102
+ justifyContent: 'space-between',
103
+ height: 40,
104
+ marginBottom: 30
105
+ },
106
+ professionalList: {
107
+ paddingHorizontal: 40,
108
+ paddingVertical: 30
109
+ }
110
+ })
111
+
112
+ const isBusyTime = (professional: any) => {
113
+ if (professional?.busy_times?.length === 0 || !dateSelected) return false
114
+ const valid = professional?.busy_times.some((item: any) => {
115
+ return moment(item?.start).valueOf() <= moment(dateSelected).valueOf() &&
116
+ moment(dateSelected).valueOf() <= moment(item?.end).valueOf()
117
+ })
118
+ return valid
119
+ }
120
+
121
+ const onDateChange = (date: any) => {
122
+ setSelectedDate(date)
123
+ setTimeSelected(null)
124
+ dropdownRef?.current && dropdownRef.current.reset()
125
+ }
126
+
127
+ const dropDownIcon = () => {
128
+ return (
129
+ <IconAntDesign
130
+ name='down'
131
+ color={theme.colors.textThird}
132
+ size={12}
133
+ />
134
+ )
135
+ }
136
+
137
+ const customDayHeaderStylesCallback = () => {
138
+ return {
139
+ textStyle: {
140
+ color: theme.colors.disabled,
141
+ fontSize: 12,
142
+ },
143
+ };
144
+ };
145
+
146
+ const handleSaveService = () => {
147
+ const updated = {
148
+ serviceTime: moment(dateSelected).utc().format('YYYY-MM-DD HH:mm:00'),
149
+ professional: currentProfessional
150
+ }
151
+ handleSave && handleSave(updated)
152
+ }
153
+
154
+ const validateSelectedDate = (curdate: any, menu: any) => {
155
+ const day = moment(curdate).format('d')
156
+ setIsEnabled(menu?.schedule?.[day]?.enabled || false)
157
+ }
158
+
159
+ const handleRedirectLogin = () => {
160
+ navigation && navigation.navigate('Login', {
161
+ store_slug: props.businessSlug
162
+ });
163
+ onClose && onClose()
164
+ };
165
+
166
+ const getTimes = (curdate: any, menu: any) => {
167
+ validateSelectedDate(curdate, menu)
168
+ const date = new Date()
169
+ var dateSeleted = new Date(curdate)
170
+ var times = []
171
+ for (var k = 0; k < menu.schedule[dateSeleted.getDay()].lapses.length; k++) {
172
+ var open = {
173
+ hour: menu.schedule[dateSeleted.getDay()].lapses[k].open.hour,
174
+ minute: menu.schedule[dateSeleted.getDay()].lapses[k].open.minute
175
+ }
176
+ var close = {
177
+ hour: menu.schedule[dateSeleted.getDay()].lapses[k].close.hour,
178
+ minute: menu.schedule[dateSeleted.getDay()].lapses[k].close.minute
179
+ }
180
+ for (var i = open.hour; i <= close.hour; i++) {
181
+ if (date.getDate() !== dateSeleted.getDate() || i >= date.getHours()) {
182
+ let hour = ''
183
+ let meridian = ''
184
+ if (configs?.format_time?.value === '12') {
185
+ if (i === 0) {
186
+ hour = '12'
187
+ meridian = ' ' + t('AM', 'AM')
188
+ } else if (i > 0 && i < 12) {
189
+ hour = (i < 10 ? '0' + i : i)
190
+ meridian = ' ' + t('AM', 'AM')
191
+ } else if (i === 12) {
192
+ hour = '12'
193
+ meridian = ' ' + t('PM', 'PM')
194
+ } else {
195
+ hour = ((i - 12 < 10) ? '0' + (i - 12) : `${(i - 12)}`)
196
+ meridian = ' ' + t('PM', 'PM')
197
+ }
198
+ } else {
199
+ hour = i < 10 ? '0' + i : i
200
+ }
201
+ for (let j = (i === open.hour ? open.minute : 0); j <= (i === close.hour ? close.minute : 59); j += 15) {
202
+ if (i !== date.getHours() || j >= date.getMinutes() || date.getDate() !== dateSeleted.getDate()) {
203
+ times.push({
204
+ text: hour + ':' + (j < 10 ? '0' + j : j) + meridian,
205
+ value: (i < 10 ? '0' + i : i) + ':' + (j < 10 ? '0' + j : j)
206
+ })
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ return times
213
+ }
214
+
215
+ const addressRedirect = () => {
216
+ navigation && navigation.navigate('AddressList')
217
+ onClose && onClose()
218
+ }
219
+
220
+ const handleChangeProfessional = (professional: any) => {
221
+ setCurrentProfessional(professional)
222
+ setIsOpen(false)
223
+ }
224
+
225
+ useEffect(() => {
226
+ if (selectDate === null || currentProfessional === null) return
227
+ const _times = getTimes(selectDate, currentProfessional)
228
+ setTimeList(_times)
229
+ }, [selectDate, currentProfessional])
230
+
231
+ useEffect(() => {
232
+ if (!selectDate || !timeSelected) {
233
+ setDateSelected(null)
234
+ return
235
+ }
236
+ const date = `${moment(selectDate).format('YYYY-MM-DD')} ${timeSelected}:00`
237
+ setDateSelected(date)
238
+ }, [selectDate, timeSelected])
239
+
240
+ useEffect(() => {
241
+ if (!professionalSelected?.schedule) return
242
+ setCurrentProfessional(professionalSelected)
243
+ }, [professionalSelected])
244
+
245
+ useEffect(() => {
246
+ if (isCartProduct && professionalListState?.professionals?.length > 0) {
247
+ const professional = professionalListState?.professionals?.find((item: any) => item.id === professionalSelected?.id)
248
+ setCurrentProfessional(professional)
249
+ }
250
+ }, [isCartProduct, professionalListState?.professionals])
251
+
252
+ return (
253
+ <>
254
+ {loading && !error && (
255
+ <Placeholder Animation={Fade}>
256
+ <PlaceholderLine
257
+ height={258}
258
+ style={{ borderRadius: 0 }}
259
+ width={screenWidth}
260
+ />
261
+ </Placeholder>
262
+ )}
263
+ {!loading && !error && (
264
+ <Container>
265
+ {!!product?.images ? (
266
+ <ProfessionalPhoto
267
+ source={{
268
+ uri: product?.images
269
+ }}
270
+ />
271
+ ) : (
272
+ <OIcon
273
+ src={theme?.images?.dummies?.product}
274
+ cover={false}
275
+ style={{ alignSelf: 'center' }}
276
+ width={200}
277
+ height={200}
278
+ />
279
+ )}
280
+ <InfoWrapper>
281
+ <OText
282
+ size={20}
283
+ style={{ marginBottom: 4 }}
284
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
285
+ >
286
+ {product?.name}
287
+ </OText>
288
+ <OText
289
+ size={16}
290
+ style={{ marginBottom: 10 }}
291
+ weight={'400'}
292
+ >
293
+ {parsePrice(product?.price)} • {product?.duration}min
294
+ </OText>
295
+ <OText
296
+ size={14}
297
+ weight={'400'}
298
+ color={theme?.colors?.disabled}
299
+ >
300
+ {product?.description}
301
+ </OText>
302
+ </InfoWrapper>
303
+ <Divider />
304
+ <ProfessionalWrapper>
305
+ <View
306
+ style={{
307
+ flexDirection: 'row',
308
+ justifyContent: 'space-between',
309
+ alignItems: 'center',
310
+ marginBottom: 23
311
+ }}
312
+ >
313
+ <OText
314
+ size={16}
315
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
316
+ >
317
+ {t('PROFESSIONAL', 'Professional')}
318
+ </OText>
319
+ <OText
320
+ size={10}
321
+ weight={'400'}
322
+ color={theme.colors?.danger5}
323
+ >
324
+ {t('REQUIRED', 'Required')}
325
+ </OText>
326
+ </View>
327
+ <TouchableOpacity
328
+ style={styles.professionalSelect}
329
+ onPress={() => setIsOpen(true)}
330
+ >
331
+ {!!currentProfessional ? (
332
+ <>
333
+ <View style={{ flexDirection: 'row' }}>
334
+ {!!currentProfessional?.photo ? (
335
+ <FastImage
336
+ style={styles.photoStyle}
337
+ source={{
338
+ uri: optimizeImage(currentProfessional?.photo, 'h_250,c_limit'),
339
+ priority: FastImage.priority.normal,
340
+ }}
341
+ resizeMode={FastImage.resizeMode.cover}
342
+ />
343
+ ) : (
344
+ <OIcon
345
+ src={theme?.images?.general?.user}
346
+ cover={false}
347
+ style={styles.photoStyle}
348
+ />
349
+ )}
350
+ <View style={{ marginLeft: 14 }}>
351
+ <OText
352
+ size={14}
353
+ weight={'400'}
354
+ lineHeight={22}
355
+ >
356
+ {currentProfessional?.name} {currentProfessional?.lastname}
357
+ </OText>
358
+ <OText
359
+ size={12}
360
+ weight={'400'}
361
+ lineHeight={17}
362
+ color={isBusyTime(currentProfessional) ? theme.colors.danger5 : theme.colors.success500}
363
+ >
364
+ {isBusyTime(currentProfessional)
365
+ ? t('BUSY_ON_SELECTED_TIME', 'Busy on selected time')
366
+ : t('AVAILABLE', 'Available')
367
+ }
368
+ </OText>
369
+ </View>
370
+ </View>
371
+ </>
372
+ ) : (
373
+ <OText size={12}>{t('SELECT_PROFESSIONAL', 'Select professional')}</OText>
374
+ )}
375
+ <View style={{ marginLeft: 5 }}>
376
+ <IconAntDesign
377
+ name='down'
378
+ color={theme.colors.textThird}
379
+ size={12}
380
+ />
381
+ </View>
382
+ </TouchableOpacity>
383
+ </ProfessionalWrapper>
384
+ <ScheduleWrapper>
385
+ <View
386
+ style={{
387
+ flexDirection: 'row',
388
+ justifyContent: 'space-between',
389
+ alignItems: 'center',
390
+ marginBottom: 23
391
+ }}
392
+ >
393
+ <OText
394
+ size={16}
395
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
396
+ >
397
+ {t('SCHEDULE', 'Schedule')}
398
+ </OText>
399
+ <OText
400
+ size={10}
401
+ weight={'400'}
402
+ color={theme.colors?.danger5}
403
+ >
404
+ {t('REQUIRED', 'Required')}
405
+ </OText>
406
+ </View>
407
+ {!!currentProfessional?.schedule ? (
408
+ <CalendarWrapper>
409
+ {(timeList?.length > 0 && isEnabled) ? (
410
+ <SelectDropdown
411
+ ref={dropdownRef}
412
+ defaultValue={timeSelected}
413
+ data={timeList}
414
+ onSelect={(selectedItem, index) => {
415
+ setTimeSelected(selectedItem?.value)
416
+ }}
417
+ buttonTextAfterSelection={(selectedItem, index) => {
418
+ return selectedItem?.text
419
+ }}
420
+ rowTextForSelection={(item, index) => {
421
+ return item.text
422
+ }}
423
+ buttonStyle={{borderRadius: 7.6, ...styles.selectOption}}
424
+ buttonTextStyle={{
425
+ color: theme.colors.disabled,
426
+ fontSize: 14,
427
+ textAlign: 'left',
428
+ marginHorizontal: 0
429
+ }}
430
+ dropdownStyle={{
431
+ borderRadius: 8,
432
+ borderColor: theme.colors.lightGray,
433
+ marginTop: Platform.OS === 'ios' ? 12 : -top
434
+ }}
435
+ rowStyle={{
436
+ borderBottomColor: theme.colors.backgroundGray100,
437
+ backgroundColor: theme.colors.backgroundGray100,
438
+ height: 30,
439
+ flexDirection: 'column',
440
+ alignItems: 'flex-start',
441
+ paddingTop: 8,
442
+ paddingHorizontal: 12
443
+ }}
444
+ rowTextStyle={{
445
+ color: theme.colors.disabled,
446
+ fontSize: 14,
447
+ marginHorizontal: 0
448
+ }}
449
+ renderDropdownIcon={() => dropDownIcon()}
450
+ dropdownOverlayColor='transparent'
451
+ />
452
+ ) : (
453
+ <OText
454
+ size={12}
455
+ style={{ marginBottom: 30 }}
456
+ weight={'400'}
457
+ color={theme.colors?.danger5}
458
+ >
459
+ {t('PROFESSIONAL_NOT_AVAILABLE', 'Professional is not available at the moment')}
460
+ </OText>
461
+ )}
462
+ <CalendarPicker
463
+ previousComponent={
464
+ <FeatherIcon
465
+ name='chevron-left'
466
+ color={theme.colors.disabled}
467
+ size={24}
468
+ style={{ marginHorizontal: 4 }}
469
+ />
470
+ }
471
+ nextComponent={
472
+ <FeatherIcon
473
+ name='chevron-right'
474
+ color={theme.colors.disabled}
475
+ size={24}
476
+ style={{ marginHorizontal: 4 }}
477
+ />
478
+ }
479
+ width={screenWidth - 110}
480
+ selectedDayTextColor={theme.colors.white}
481
+ selectedDayColor={theme.colors.primary}
482
+ todayBackgroundColor={theme.colors.border}
483
+ dayLabelsWrapper={{ borderColor: theme.colors.clear }}
484
+ onDateChange={onDateChange}
485
+ minDate={new Date()}
486
+ customDayHeaderStyles={customDayHeaderStylesCallback}
487
+ selectedStartDate={selectDate}
488
+ />
489
+ </CalendarWrapper>
490
+ ) : (
491
+ <OText
492
+ size={16}
493
+ style={{ marginBottom: 30, textAlign: 'center' }}
494
+ color={theme?.colors?.disabled}
495
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
496
+ >
497
+ {t('NO_SCHEDULE', 'No schedule')}
498
+ </OText>
499
+ )}
500
+ </ScheduleWrapper>
501
+ <ButtonWrapper>
502
+ <OText
503
+ size={14}
504
+ weight={Platform.OS === 'ios' ? '600' : 'bold'}
505
+ >
506
+ {dateSelected && moment(dateSelected).format('hh:mm A')}
507
+ </OText>
508
+ {((productCart &&
509
+ auth &&
510
+ orderState.options?.address_id)) && (
511
+ <OButton
512
+ bgColor={theme.colors.primary}
513
+ onClick={() => handleSaveService()}
514
+ text={orderState.loading
515
+ ? t('LOADING', 'Loading')
516
+ : ((isSoldOut || maxProductQuantity <= 0)
517
+ ? t('SOLD_OUT', 'Sold out')
518
+ : t('BOOK', 'Book'))}
519
+ style={styles.buttonStyle}
520
+ isDisabled={isSoldOut || maxProductQuantity <= 0 || !currentProfessional?.id || !dateSelected}
521
+ textStyle={{ fontSize: 14, color: theme.colors.white }}
522
+ />
523
+ )}
524
+ {auth &&
525
+ !orderState.options?.address_id &&
526
+ (orderState.loading ? (
527
+ <OButton
528
+ isDisabled
529
+ text={t('LOADING', 'Loading')}
530
+ imgRightSrc=""
531
+ textStyle={{ fontSize: 10 }}
532
+ />
533
+ ) : (
534
+ <OButton onClick={() => addressRedirect()} />
535
+ ))}
536
+ {!auth && (
537
+ <OButton
538
+ isDisabled={isSoldOut || maxProductQuantity <= 0}
539
+ onClick={() => handleRedirectLogin()}
540
+ text={
541
+ isSoldOut || maxProductQuantity <= 0
542
+ ? t('SOLD_OUT', 'Sold out')
543
+ : t('LOGIN_SIGNUP', 'Login / Sign Up')
544
+ }
545
+ imgRightSrc=""
546
+ textStyle={{ color: theme.colors.primary, fontSize: 14 }}
547
+ style={{
548
+ height: 44,
549
+ borderColor: theme.colors.primary,
550
+ backgroundColor: theme.colors.white,
551
+ }}
552
+ />
553
+ )}
554
+ </ButtonWrapper>
555
+ </Container>
556
+ )}
557
+
558
+ <OModal
559
+ open={isOpen}
560
+ onClose={() => setIsOpen(false)}
561
+ entireModal
562
+ >
563
+ <ScrollView contentContainerStyle={styles.professionalList}>
564
+ <View style={{ paddingVertical: 11 }}>
565
+ <OText
566
+ size={14}
567
+ weight={'400'}
568
+ >
569
+ {t('ANY_OROFESSIONAL_MEMBER', 'Any professional member')}
570
+ </OText>
571
+ </View>
572
+ {professionalListState?.professionals?.map((professional: any) => (
573
+ <TouchableOpacity
574
+ key={professional?.id}
575
+ style={styles.professionalItem}
576
+ onPress={() => handleChangeProfessional(professional)}
577
+ >
578
+ <View style={{ flexDirection: 'row' }}>
579
+ {!!professional?.photo ? (
580
+ <FastImage
581
+ style={styles.photoStyle}
582
+ source={{
583
+ uri: optimizeImage(professional?.photo, 'h_250,c_limit'),
584
+ priority: FastImage.priority.normal,
585
+ }}
586
+ resizeMode={FastImage.resizeMode.cover}
587
+ />
588
+ ) : (
589
+ <OIcon
590
+ src={theme?.images?.general?.user}
591
+ cover={false}
592
+ style={styles.photoStyle}
593
+ />
594
+ )}
595
+ <View style={{ marginLeft: 14 }}>
596
+ <OText
597
+ size={14}
598
+ weight={'400'}
599
+ lineHeight={22}
600
+ >
601
+ {professional?.name} {professional?.lastname}
602
+ </OText>
603
+ <OText
604
+ size={12}
605
+ weight={'400'}
606
+ lineHeight={17}
607
+ color={isBusyTime(professional) ? theme.colors.danger5 : theme.colors.success500}
608
+ >
609
+ {isBusyTime(professional)
610
+ ? t('BUSY_ON_SELECTED_TIME', 'Busy on selected time')
611
+ : t('AVAILABLE', 'Available')
612
+ }
613
+ </OText>
614
+ </View>
615
+ </View>
616
+ </TouchableOpacity>
617
+ ))}
618
+ </ScrollView>
619
+ </OModal>
620
+ </>
621
+ )
622
+ }
623
+
624
+ export const ServiceForm = (props: any) => {
625
+ const serviceFormProps = {
626
+ ...props,
627
+ UIComponent: ServiceFormUI,
628
+ isService: true
629
+ }
630
+ return <ProductFormController {...serviceFormProps} />
631
+ }
@@ -0,0 +1,50 @@
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
+ padding-horizontal: 40px;
15
+ margin-vertical: 30px;
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 ProfessionalWrapper = styled.View`
25
+ padding-horizontal: 40px;
26
+ margin-top: 30px;
27
+ `
28
+
29
+ export const ScheduleWrapper = styled(ProfessionalWrapper)``
30
+
31
+ export const CalendarWrapper = styled.View`
32
+ flex: 1;
33
+ border-width: 1px;
34
+ border-color: ${(props: any) => props.theme.colors.backgroundGray200};
35
+ border-radius: 7.6px;
36
+ padding: 15px;
37
+ `
38
+
39
+ export const ButtonWrapper = styled.View`
40
+ justify-content: space-between;
41
+ align-items: center;
42
+ flex-direction: row;
43
+ padding-vertical: 13px;
44
+ padding-horizontal: 40px;
45
+ margin-top: 30px;
46
+ margin-bottom: 40px;
47
+ width: 100%;
48
+ border-top-width: 1px;
49
+ border-top-color: ${(props: any) => props.theme.colors.backgroundGray200};
50
+ `