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