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