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