ordering-ui-react-native 0.15.87 → 0.15.88-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 (239) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +1 -1
  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 +16 -8
  8. package/src/components/BusinessInformation/index.tsx +14 -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 +25 -3
  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/PaymentOptions/index.tsx +335 -365
  20. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  21. package/src/components/ReviewDriver/index.tsx +1 -1
  22. package/src/components/ReviewOrder/index.tsx +2 -1
  23. package/src/components/ReviewProducts/index.tsx +11 -0
  24. package/src/components/SignupForm/index.tsx +145 -61
  25. package/src/components/SingleProductCard/index.tsx +16 -4
  26. package/src/components/SingleProductReview/index.tsx +1 -1
  27. package/src/components/StripeElementsForm/index.tsx +25 -16
  28. package/src/components/StripeMethodForm/index.tsx +22 -24
  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/index.tsx +18 -11
  46. package/src/utils/index.tsx +28 -29
  47. package/themes/business/index.tsx +4 -0
  48. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +100 -60
  49. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  50. package/themes/business/src/components/Chat/index.tsx +52 -92
  51. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  52. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  53. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  54. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  55. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  56. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  57. package/themes/business/src/components/MapView/index.tsx +1 -1
  58. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  59. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  60. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  61. package/themes/business/src/components/OrderDetails/Delivery.tsx +17 -7
  62. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +26 -18
  63. package/themes/business/src/components/OrdersListManager/index.tsx +11 -4
  64. package/themes/business/src/components/OrdersOption/index.tsx +66 -20
  65. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  66. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  67. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  68. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  69. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  70. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  71. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  72. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  73. package/themes/business/src/components/PreviousMessages/index.tsx +1 -0
  74. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  75. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  76. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  77. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  78. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  79. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  80. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  81. package/themes/business/src/components/shared/OModal.tsx +41 -38
  82. package/themes/business/src/types/index.tsx +15 -7
  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 +25 -26
  87. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  88. package/themes/kiosk/src/components/Cart/index.tsx +10 -11
  89. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  90. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  91. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  92. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  93. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  94. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  95. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  96. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  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 +9 -11
  101. package/themes/kiosk/src/components/PaymentOptions/index.tsx +55 -53
  102. package/themes/kiosk/src/components/ProductForm/index.tsx +6 -7
  103. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  104. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  105. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  106. package/themes/kiosk/src/types/index.d.ts +1 -0
  107. package/themes/original/index.tsx +22 -0
  108. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  109. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  110. package/themes/original/src/components/AddressForm/index.tsx +26 -33
  111. package/themes/original/src/components/AddressList/index.tsx +2 -2
  112. package/themes/original/src/components/AppleLogin/index.tsx +6 -8
  113. package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
  114. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  115. package/themes/original/src/components/BusinessController/index.tsx +179 -96
  116. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  117. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -8
  118. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  119. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  120. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  121. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  122. package/themes/original/src/components/BusinessListingSearch/index.tsx +217 -127
  123. package/themes/original/src/components/BusinessListingSearch/styles.tsx +29 -11
  124. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  125. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  126. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  127. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  128. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  129. package/themes/original/src/components/BusinessProductsList/index.tsx +66 -73
  130. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  131. package/themes/original/src/components/BusinessProductsListing/index.tsx +296 -178
  132. package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -0
  133. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  134. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
  135. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  136. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
  137. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  138. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +673 -0
  139. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  140. package/themes/original/src/components/BusinessesListing/index.tsx +104 -462
  141. package/themes/original/src/components/Cart/index.tsx +83 -38
  142. package/themes/original/src/components/Cart/styles.tsx +4 -0
  143. package/themes/original/src/components/CartContent/index.tsx +3 -3
  144. package/themes/original/src/components/Checkout/index.tsx +143 -91
  145. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  146. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  147. package/themes/original/src/components/Favorite/index.tsx +92 -0
  148. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  149. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  150. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  151. package/themes/original/src/components/ForgotPasswordForm/index.tsx +13 -4
  152. package/themes/original/src/components/GPSButton/index.tsx +25 -17
  153. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  154. package/themes/original/src/components/Help/index.tsx +21 -4
  155. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
  156. package/themes/original/src/components/HelpGuide/index.tsx +8 -3
  157. package/themes/original/src/components/HelpOrder/index.tsx +8 -3
  158. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  159. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  160. package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -3
  161. package/themes/original/src/components/LoginForm/index.tsx +52 -13
  162. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  163. package/themes/original/src/components/Messages/index.tsx +17 -17
  164. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  165. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  166. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  167. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  168. package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
  169. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  170. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  171. package/themes/original/src/components/MultiOrdersDetails/index.tsx +262 -0
  172. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  173. package/themes/original/src/components/MyOrders/index.tsx +132 -27
  174. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  175. package/themes/original/src/components/NavBar/index.tsx +11 -5
  176. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  177. package/themes/original/src/components/OrderDetails/index.tsx +153 -77
  178. package/themes/original/src/components/OrderDetails/styles.tsx +5 -2
  179. package/themes/original/src/components/OrderItAgain/index.tsx +73 -0
  180. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  181. package/themes/original/src/components/OrderProgress/index.tsx +8 -2
  182. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  183. package/themes/original/src/components/OrderTypeSelector/index.tsx +84 -36
  184. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  185. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +140 -0
  186. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  187. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  188. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  189. package/themes/original/src/components/OrdersOption/index.tsx +138 -46
  190. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  191. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  192. package/themes/original/src/components/PaymentOptionWallet/index.tsx +15 -22
  193. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  194. package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
  195. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  196. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  197. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  198. package/themes/original/src/components/ProductForm/index.tsx +737 -682
  199. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  200. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  201. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  202. package/themes/original/src/components/ProductOptionSubOption/index.tsx +13 -9
  203. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  204. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  205. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  206. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  207. package/themes/original/src/components/Promotions/index.tsx +22 -6
  208. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  209. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  210. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  211. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  212. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  213. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  214. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  215. package/themes/original/src/components/SignupForm/index.tsx +237 -127
  216. package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
  217. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  218. package/themes/original/src/components/SingleProductCard/index.tsx +197 -95
  219. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  220. package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
  221. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  222. package/themes/original/src/components/UpsellingProducts/index.tsx +7 -3
  223. package/themes/original/src/components/UserDetails/index.tsx +32 -18
  224. package/themes/original/src/components/UserFormDetails/index.tsx +108 -74
  225. package/themes/original/src/components/UserProfile/index.tsx +5 -1
  226. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  227. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  228. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  229. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  230. package/themes/original/src/components/Wallets/index.tsx +177 -163
  231. package/themes/original/src/components/Wallets/styles.tsx +10 -8
  232. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  233. package/themes/original/src/components/shared/OButton.tsx +10 -3
  234. package/themes/original/src/components/shared/OInput.tsx +3 -2
  235. package/themes/original/src/components/shared/OModal.tsx +4 -2
  236. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  237. package/themes/original/src/types/index.tsx +199 -48
  238. package/themes/original/src/utils/index.tsx +77 -0
  239. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,4 +1,16 @@
1
- import React, { useEffect, useRef, useCallback } from 'react';
1
+ import React, { useEffect, useRef, useState, useCallback } from 'react';
2
+ import {
3
+ View,
4
+ Keyboard,
5
+ TextInput,
6
+ TouchableOpacity,
7
+ StyleSheet,
8
+ Dimensions,
9
+ I18nManager,
10
+ SafeAreaView,
11
+ Platform,
12
+ Button
13
+ } from 'react-native';
2
14
  import {
3
15
  ProductForm as ProductOptions,
4
16
  useSession,
@@ -15,17 +27,10 @@ import Swiper from 'react-native-swiper'
15
27
  import FastImage from 'react-native-fast-image';
16
28
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
17
29
  import YoutubePlayer from "react-native-youtube-iframe"
18
- import { TextInput } from 'react-native'
19
- import {
20
- Grayscale
21
- } from 'react-native-color-matrix-image-filters'
22
-
23
- import { View, TouchableOpacity, StyleSheet, Dimensions, I18nManager, SafeAreaView, Platform, Button } from 'react-native';
24
30
 
25
31
  import {
26
32
  WrapHeader,
27
33
  TopHeader,
28
- WrapContent,
29
34
  ProductTitle,
30
35
  ProductDescription,
31
36
  ProductEditions,
@@ -45,8 +50,6 @@ import { ScrollView } from 'react-native-gesture-handler';
45
50
  import { ProductOptionSubOption } from '../ProductOptionSubOption';
46
51
  import { NotFoundSource } from '../NotFoundSource';
47
52
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
48
- import { useState } from 'react';
49
- const windowHeight = Dimensions.get('window').height;
50
53
  const windowWidth = Dimensions.get('window').width;
51
54
 
52
55
  export const ProductOptionsUI = (props: any) => {
@@ -151,6 +154,13 @@ export const ProductOptionsUI = (props: any) => {
151
154
  productTagNameStyle: {
152
155
  paddingHorizontal: 6,
153
156
  marginRight: 5
157
+ },
158
+ actionContainer: {
159
+ flexDirection: 'row',
160
+ alignItems: 'center',
161
+ justifyContent: 'space-between',
162
+ width: '100%',
163
+ marginTop: 10
154
164
  }
155
165
  });
156
166
 
@@ -162,7 +172,7 @@ export const ProductOptionsUI = (props: any) => {
162
172
  const [gallery, setGallery] = useState([])
163
173
  const [thumbsSwiper, setThumbsSwiper] = useState(0)
164
174
  const [indexGallery, setIndexGallery] = useState(0)
165
- const [selOpt, setSelectedOpt] = useState(0);
175
+ const [selOpt, setSelectedOpt] = useState(-1);
166
176
  const [isHaveWeight, setIsHaveWeight] = useState(false)
167
177
  const [playing, setPlaying] = useState(false);
168
178
  const [qtyBy, setQtyBy] = useState({
@@ -175,6 +185,7 @@ export const ProductOptionsUI = (props: any) => {
175
185
  const [optionLayout, setOptionLayout] = useState<any>({})
176
186
  const [headerRefHeight, setHeaderRefHeight] = useState(0)
177
187
  const [summaryRefHeight, setSummaryRefHeight] = useState(0)
188
+ const [isScrollAvailable, setIsScrollAvailable] = useState(null)
178
189
 
179
190
  const isError = (id: number) => {
180
191
  let bgColor = theme.colors.white;
@@ -278,6 +289,62 @@ export const ProductOptionsUI = (props: any) => {
278
289
  setOptionLayout(_optionLayout)
279
290
  }
280
291
 
292
+ const saveErrors =
293
+ orderState.loading ||
294
+ maxProductQuantity === 0 ||
295
+ Object.keys(errors).length > 0;
296
+
297
+ const ExtraOptions = ({ eID, options }: any) => (
298
+ <>
299
+ {options.map(({ id, name, respect_to, suboptions }: any) => (
300
+ <React.Fragment key={`cont_key_${id}`}>
301
+ {respect_to == null && suboptions?.length > 0 && (
302
+ <TouchableOpacity
303
+ key={`eopt_key_${id}`}
304
+ onPress={() => setSelectedOpt(id)}
305
+ style={[
306
+ styles.extraItem,
307
+ {
308
+ borderBottomColor:
309
+ selOpt == id ? theme.colors.textNormal : theme.colors.border,
310
+ },
311
+ ]}>
312
+ <OText
313
+ color={
314
+ selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
315
+ }
316
+ size={selOpt == id ? 14 : 12}
317
+ weight={selOpt == id ? '600' : 'normal'}
318
+ style={{ maxWidth: 150 }}
319
+ numberOfLines={1}>
320
+ {name}
321
+ </OText>
322
+ </TouchableOpacity>
323
+ )}
324
+ </React.Fragment>
325
+ ))}
326
+ </>
327
+ );
328
+
329
+ const handleScroll = ({ nativeEvent: { contentOffset, layoutMeasurement } }: any) => {
330
+
331
+ const _topOption = Object.keys(optionLayout).find(((option: any) => Math.abs(contentOffset?.y - layoutMeasurement?.height - optionLayout[option]?.y) < 20))
332
+ if (_topOption) {
333
+ const _topOptionId = Number(_topOption.replace('id:', ''))
334
+ }
335
+ }
336
+
337
+ const handleGoBack = navigation?.canGoBack()
338
+ ? () => navigation.goBack()
339
+ : () => navigation.navigate('Business', { store: props.businessSlug })
340
+
341
+ useEffect(() => {
342
+ if (isScrollAvailable) {
343
+ setIsScrollAvailable(null)
344
+ scrollDown(isScrollAvailable)
345
+ }
346
+ }, [errors])
347
+
281
348
  useEffect(() => {
282
349
  const imageList: any = []
283
350
  const videoList: any = []
@@ -319,732 +386,719 @@ export const ProductOptionsUI = (props: any) => {
319
386
  }
320
387
  }, [product])
321
388
 
322
- const saveErrors =
323
- orderState.loading ||
324
- maxProductQuantity === 0 ||
325
- Object.keys(errors).length > 0;
326
-
327
- const ExtraOptions = ({ eID, options }: any) => (
328
- <>
329
- {options.map(({ id, name, respect_to, suboptions }: any) => (
330
- <React.Fragment key={`cont_key_${id}`}>
331
- {respect_to == null && suboptions?.length > 0 && (
332
- <TouchableOpacity
333
- key={`eopt_key_${id}`}
334
- onPress={() => setSelectedOpt(id)}
335
- style={[
336
- styles.extraItem,
337
- {
338
- borderBottomColor:
339
- selOpt == id ? theme.colors.textNormal : theme.colors.border,
340
- },
341
- ]}>
342
- <OText
343
- color={
344
- selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
345
- }
346
- size={selOpt == id ? 14 : 12}
347
- weight={selOpt == id ? '600' : 'normal'}>
348
- {name}
349
- </OText>
350
- </TouchableOpacity>
389
+ const ActionButton = () => {
390
+ return (
391
+ <View
392
+ style={{
393
+ width: isHaveWeight ? '100%' : ((isSoldOut || maxProductQuantity <= 0) ? '60%' : '40%'),
394
+ }}>
395
+ {((productCart &&
396
+ auth &&
397
+ orderState.options?.address_id) || (isSoldOut || maxProductQuantity <= 0)) && (
398
+ <OButton
399
+ onClick={() => handleSaveProduct()}
400
+ imgRightSrc=""
401
+ text={`${orderState.loading
402
+ ? t('LOADING', 'Loading')
403
+ : (isSoldOut || maxProductQuantity <= 0)
404
+ ? t('SOLD_OUT', 'Sold out')
405
+ : editMode
406
+ ? t('UPDATE', 'Update')
407
+ : t('ADD', 'Add')
408
+ }`}
409
+ isDisabled={isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order))}
410
+ textStyle={{
411
+ color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
412
+ fontSize: orderState.loading || editMode ? 10 : 14
413
+ }}
414
+ style={{
415
+ backgroundColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order)) ? theme.colors.lightGray : theme.colors.primary,
416
+ borderColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order)) ? theme.colors.white : theme.colors.primary,
417
+ opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
418
+ borderRadius: 7.6,
419
+ height: 44,
420
+ shadowOpacity: 0,
421
+ borderWidth: 1,
422
+ marginTop: isHaveWeight ? 10 : 0
423
+ }}
424
+ />
351
425
  )}
352
- </React.Fragment>
353
- ))}
354
- </>
355
- );
426
+ {auth &&
427
+ !orderState.options?.address_id &&
428
+ (orderState.loading ? (
429
+ <OButton
430
+ isDisabled
431
+ text={t('LOADING', 'Loading')}
432
+ imgRightSrc=""
433
+ textStyle={{ fontSize: 10 }}
434
+ />
435
+ ) : (
436
+ <OButton onClick={navigation.navigate('AddressList')} />
437
+ ))}
438
+ {!auth && (
439
+ <OButton
440
+ isDisabled={isSoldOut || maxProductQuantity <= 0}
441
+ onClick={() => handleRedirectLogin()}
442
+ text={
443
+ isSoldOut || maxProductQuantity <= 0
444
+ ? t('SOLD_OUT', 'Sold out')
445
+ : t('LOGIN_SIGNUP', 'Login / Sign Up')
446
+ }
447
+ imgRightSrc=""
448
+ textStyle={{ color: theme.colors.primary, fontSize: 14 }}
449
+ style={{
450
+ height: 44,
451
+ borderColor: theme.colors.primary,
452
+ backgroundColor: theme.colors.white,
453
+ }}
454
+ />
455
+ )}
456
+ </View>
457
+ )
458
+ }
459
+
460
+ useEffect(() => {
461
+ const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
462
+ scrollViewRef.current.scrollToEnd({ animated: true })
463
+ })
464
+ return () => {
465
+ keyboardDidShowListener.remove()
466
+ }
467
+ }, [])
356
468
 
357
- const handleGoBack = navigation?.canGoBack()
358
- ? () => navigation.goBack()
359
- : () => navigation.navigate('Business', { store: props.businessSlug })
360
469
 
361
470
  return (
362
471
  <SafeAreaView style={{ flex: 1 }}>
363
472
  <TopHeader>
364
473
  <TopActions onPress={() => handleGoBack()}>
365
- <OIcon src={theme.images.general.arrow_left} width={15} />
474
+ <IconAntDesign name='arrowleft' size={26} />
366
475
  </TopActions>
367
476
  </TopHeader>
368
- <ScrollView ref={scrollViewRef}>
369
- {!error && (
370
- <View style={{ paddingBottom: 80 }}>
371
- <WrapHeader onLayout={(event: any) => setHeaderRefHeight(event.nativeEvent.layout?.height)}>
372
- {loading && !product ? (
373
- <View style={styles.productHeaderSkeleton}>
374
- <Placeholder Animation={Fade}>
375
- <PlaceholderLine
376
- height={258}
377
- style={{ borderRadius: 0 }}
378
- width={windowWidth}
379
- />
380
- </Placeholder>
381
- </View>
382
- ) : (
383
- <>
384
- <Swiper
385
- loop={false}
386
- ref={swiperRef}
387
- showsButtons={true}
388
- style={styles.mainSwiper}
389
- showsPagination={false}
390
- onIndexChanged={(index) => handleChangeMainIndex(index)}
391
- prevButton={
392
- <View style={styles.swiperButton}>
393
- <IconAntDesign
394
- name="caretleft"
395
- color={theme.colors.white}
396
- size={13}
397
- // style={styles.starIcon}
398
- />
399
- </View>
400
- }
401
- nextButton={
402
- <View style={styles.swiperButton}>
403
- <IconAntDesign
404
- name="caretright"
405
- color={theme.colors.white}
406
- size={13}
407
- // style={styles.starIcon}
477
+ {!error && (
478
+ <ScrollView
479
+ ref={scrollViewRef}
480
+ contentContainerStyle={{ paddingBottom: 80 }}
481
+ stickyHeaderIndices={[2]}
482
+ onScroll={handleScroll}
483
+ >
484
+ <WrapHeader onLayout={(event: any) => setHeaderRefHeight(event.nativeEvent.layout?.height)}>
485
+ {loading && !product ? (
486
+ <View style={styles.productHeaderSkeleton}>
487
+ <Placeholder Animation={Fade}>
488
+ <PlaceholderLine
489
+ height={258}
490
+ style={{ borderRadius: 0 }}
491
+ width={windowWidth}
492
+ />
493
+ </Placeholder>
494
+ </View>
495
+ ) : (
496
+ <>
497
+ <Swiper
498
+ loop={false}
499
+ ref={swiperRef}
500
+ showsButtons={true}
501
+ style={styles.mainSwiper}
502
+ showsPagination={false}
503
+ onIndexChanged={(index) => handleChangeMainIndex(index)}
504
+ prevButton={
505
+ <View style={styles.swiperButton}>
506
+ <IconAntDesign
507
+ name="caretleft"
508
+ color={theme.colors.white}
509
+ size={13}
510
+ // style={styles.starIcon}
511
+ />
512
+ </View>
513
+ }
514
+ nextButton={
515
+ <View style={styles.swiperButton}>
516
+ <IconAntDesign
517
+ name="caretright"
518
+ color={theme.colors.white}
519
+ size={13}
520
+ // style={styles.starIcon}
521
+ />
522
+ </View>
523
+ }
524
+ >
525
+ {gallery && gallery.length > 0 && gallery.map((img, i) => (
526
+ <View
527
+ style={styles.slide1}
528
+ key={i}
529
+ >
530
+ {img.includes('image') ? (
531
+ <FastImage
532
+ style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1 }}
533
+ source={{
534
+ uri: optimizeImage(img, 'h_1024,c_limit'),
535
+ priority: FastImage.priority.normal,
536
+ }}
408
537
  />
409
- </View>
410
- }
411
- >
412
- {gallery && gallery.length > 0 && gallery.map((img, i) => (
538
+ ) : (
539
+ <>
540
+ <YoutubePlayer
541
+ height={300}
542
+ play={playing}
543
+ videoId={img}
544
+ onChangeState={onStateChange}
545
+ />
546
+ <Button title={playing ? "pause" : "play"} onPress={togglePlaying} />
547
+ </>
548
+ )}
549
+ </View>
550
+ ))}
551
+ </Swiper>
552
+ <ScrollView
553
+ horizontal
554
+ contentContainerStyle={{
555
+ paddingHorizontal: 30,
556
+ paddingVertical: 15
557
+ }}
558
+ >
559
+ {gallery.length > 0 && gallery.map((img, index) => (
560
+ <TouchableOpacity
561
+ key={index}
562
+ onPress={() => handleClickThumb(index)}
563
+ >
413
564
  <View
414
- style={styles.slide1}
415
- key={i}
565
+ style={{
566
+ height: 56,
567
+ borderRadius: 8,
568
+ margin: 8,
569
+ opacity: index === thumbsSwiper ? 1 : 0.8
570
+ }}
416
571
  >
417
572
  {img.includes('image') ? (
418
- <FastImage
419
- style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1 }}
420
- source={{
421
- uri: optimizeImage(img, 'h_1024,c_limit'),
422
- priority: FastImage.priority.normal,
573
+ <OIcon
574
+ url={img}
575
+ style={{
576
+ borderColor: theme.colors.lightGray,
577
+ borderRadius: 8,
578
+ minHeight: '100%',
579
+ opacity: isSoldOut ? 0.5 : 1
423
580
  }}
581
+ width={56}
582
+ height={56}
583
+ cover
424
584
  />
425
585
  ) : (
426
- <>
427
- <YoutubePlayer
428
- height={300}
429
- play={playing}
430
- videoId={img}
431
- onChangeState={onStateChange}
432
- />
433
- <Button title={playing ? "pause" : "play"} onPress={togglePlaying} />
434
- </>
586
+ <OIcon
587
+ url={'http://img.youtube.com/vi/' + img + '/0.jpg'}
588
+ style={{
589
+ borderColor: theme.colors.lightGray,
590
+ borderRadius: 8,
591
+ minHeight: '100%',
592
+ opacity: isSoldOut ? 0.5 : 1
593
+ }}
594
+ width={56}
595
+ height={56}
596
+ cover
597
+ />
435
598
  )}
436
599
  </View>
437
- ))}
438
- </Swiper>
439
- <ScrollView
440
- horizontal
441
- contentContainerStyle={{
442
- paddingHorizontal: 30,
443
- paddingVertical: 15
444
- }}
445
- >
446
- {gallery.length > 0 && gallery.map((img, index) => (
447
- <TouchableOpacity
448
- key={index}
449
- onPress={() => handleClickThumb(index)}
450
- >
451
- <View
452
- style={{
453
- height: 56,
454
- borderRadius: 8,
455
- margin: 8,
456
- opacity: index === thumbsSwiper ? 1 : 0.8
457
- }}
458
- >
459
- {img.includes('image') ? (
460
- <OIcon
461
- url={img}
462
- style={{
463
- borderColor: theme.colors.lightGray,
464
- borderRadius: 8,
465
- minHeight: '100%',
466
- opacity: isSoldOut ? 0.5 : 1
467
- }}
468
- width={56}
469
- height={56}
470
- cover
471
- />
472
- ) : (
473
- <OIcon
474
- url={'http://img.youtube.com/vi/' + img + '/0.jpg'}
475
- style={{
476
- borderColor: theme.colors.lightGray,
477
- borderRadius: 8,
478
- minHeight: '100%',
479
- opacity: isSoldOut ? 0.5 : 1
480
- }}
481
- width={56}
482
- height={56}
483
- cover
484
- />
485
- )}
486
- </View>
487
- </TouchableOpacity>
600
+ </TouchableOpacity>
488
601
 
489
- ))}
490
- </ScrollView>
602
+ ))}
603
+ </ScrollView>
604
+ </>
605
+ )}
606
+ </WrapHeader>
607
+ <ProductSummary onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}>
608
+ <ProductTitle>
609
+ {loading && !product ? (
610
+ <Placeholder Animation={Fade}>
611
+ <View
612
+ style={{
613
+ flexDirection: 'row',
614
+ justifyContent: 'space-between',
615
+ }}>
616
+ <PlaceholderLine width={40} height={20} />
617
+ <PlaceholderLine width={30} height={20} />
618
+ </View>
619
+ </Placeholder>
620
+ ) : (
621
+ <>
622
+ <View style={{ flexDirection: 'row' }}>
623
+ <OText
624
+ size={20}
625
+ lineHeight={30}
626
+ weight={'600'}
627
+ style={{ flex: 1, marginBottom: 10 }}>
628
+ {product?.name || productCart.name}
629
+ </OText>
630
+ {!!product?.calories && (
631
+ <OText size={16} style={{ color: '#808080' }}>{product?.calories} cal
632
+ </OText>
633
+ )}
634
+ </View>
635
+ {((!!product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (!!product?.estimated_person)) && (
636
+ <OText size={14} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={'#909BA9'} mBottom={7}>
637
+ {
638
+ ((product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (productCart?.sku && productCart?.sku !== '-1' && productCart?.sku !== '1'))
639
+ && <>{t('SKU', 'Sku')}{' '}{product?.sku || productCart?.sku}</>
640
+ }
641
+ {product?.sku && product?.sku !== '-1' && product?.sku !== '1' && product?.estimated_person && (
642
+ <>&nbsp;&#183;&nbsp;</>
643
+ )}
644
+ {product?.estimated_person
645
+ && <>{product?.estimated_person}{' '}{t('ESTIMATED_PERSONS', 'persons')}</>
646
+ }
647
+ </OText>
648
+ )}
649
+ {isHaveWeight ? (
650
+ <OText size={16} lineHeight={24} color={theme.colors.primary}>{parsePrice(pricePerWeightUnit)} / {product?.weight_unit}</OText>
651
+ ) : (
652
+ <View style={{ flexDirection: 'row', marginBottom: 10 }}>
653
+ <OText size={16} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={theme.colors.primary}>{productCart.price ? parsePrice(productCart.price) : ''}</OText>
654
+ {product?.offer_price !== null && product?.in_offer && (
655
+ <OText style={{
656
+ fontSize: 14,
657
+ color: '#808080',
658
+ textDecorationLine: 'line-through',
659
+ marginLeft: 7,
660
+ marginRight: 7
661
+ }}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
662
+ )}
663
+ </View>
664
+ )}
491
665
  </>
492
666
  )}
493
- </WrapHeader>
494
- <WrapContent>
495
- <ProductSummary onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}>
496
- <ProductTitle>
497
- {loading && !product ? (
498
- <Placeholder Animation={Fade}>
499
- <View
500
- style={{
501
- flexDirection: 'row',
502
- justifyContent: 'space-between',
503
- }}>
504
- <PlaceholderLine width={40} height={20} />
505
- <PlaceholderLine width={30} height={20} />
506
- </View>
507
- </Placeholder>
667
+ </ProductTitle>
668
+ <ProductDescription>
669
+ <OText color={theme.colors.textSecondary} size={12} lineHeight={18}>
670
+ {product?.description || productCart?.description}
671
+ </OText>
672
+ </ProductDescription>
673
+ <ScrollView
674
+ horizontal
675
+ showsHorizontalScrollIndicator={false}
676
+ contentContainerStyle={{ paddingBottom: 30 }}
677
+ >
678
+ {product?.tags?.map((tag: any) => (
679
+ <View
680
+ key={tag.id}
681
+ style={styles.productTagWrapper}
682
+ >
683
+ {!!tag?.image ? (
684
+ <OIcon
685
+ url={optimizeImage(tag?.image, 'h_40,c_limit')}
686
+ style={styles.productTagImageStyle}
687
+ />
508
688
  ) : (
509
- <>
510
- <View style={{ flexDirection: 'row' }}>
511
- <OText
512
- size={20}
513
- lineHeight={30}
514
- weight={'600'}
515
- style={{ flex: 1, marginBottom: 10 }}>
516
- {product?.name || productCart.name}
517
- </OText>
518
- {!!product?.calories && (
519
- <OText size={16} style={{ color: '#808080' }}>{product?.calories} cal
520
- </OText>
521
- )}
522
- </View>
523
- {((!!product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (!!product?.estimated_person)) && (
524
- <OText size={14} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={'#909BA9'} mBottom={7}>
525
- {
526
- ((product?.sku && product?.sku !== '-1' && product?.sku !== '1') || (productCart?.sku && productCart?.sku !== '-1' && productCart?.sku !== '1'))
527
- && <>{t('SKU', 'Sku')}{' '}{product?.sku || productCart?.sku}</>
528
- }
529
- {product?.sku && product?.sku !== '-1' && product?.sku !== '1' && product?.estimated_person && (
530
- <>&nbsp;&#183;&nbsp;</>
531
- )}
532
- {product?.estimated_person
533
- && <>{product?.estimated_person}{' '}{t('ESTIMATED_PERSONS', 'persons')}</>
534
- }
535
- </OText>
536
- )}
537
- {isHaveWeight ? (
538
- <OText size={16} lineHeight={24} color={theme.colors.primary}>{parsePrice(pricePerWeightUnit)} / {product?.weight_unit}</OText>
539
- ) : (
540
- <View style={{ flexDirection: 'row', marginBottom: 10 }}>
541
- <OText size={16} style={{ flex: I18nManager.isRTL ? 1 : 0 }} color={theme.colors.primary}>{productCart.price ? parsePrice(productCart.price) : ''}</OText>
542
- {product?.offer_price !== null && product?.in_offer && (
543
- <OText style={{
544
- fontSize: 14,
545
- color: '#808080',
546
- textDecorationLine: 'line-through',
547
- marginLeft: 7,
548
- marginRight: 7
549
- }}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
550
- )}
551
- </View>
552
- )}
553
- </>
689
+ <OIcon
690
+ src={theme.images?.dummies?.product}
691
+ style={styles.productTagImageStyle}
692
+ />
554
693
  )}
555
- </ProductTitle>
556
- <ProductDescription>
557
- <OText color={theme.colors.textSecondary} size={12} lineHeight={18}>
558
- {product?.description || productCart?.description}
694
+ <OText color={theme.colors.textSecondary} size={12} style={styles.productTagNameStyle}>{tag.name}</OText>
695
+ </View>
696
+ ))}
697
+ </ScrollView>
698
+ </ProductSummary>
699
+ {(!loading && product) && (
700
+ <ExtraOptionWrap
701
+ horizontal
702
+ showsHorizontalScrollIndicator={false}
703
+ style={{ marginBottom: 20 }}
704
+ contentContainerStyle={{ paddingHorizontal: 33, backgroundColor: theme.colors.white }}
705
+ >
706
+ <TouchableOpacity
707
+ key={`eopt_key_00`}
708
+ onPress={() => setSelectedOpt(-1)}
709
+ style={[
710
+ styles.extraItem,
711
+ {
712
+ borderBottomColor: selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
713
+ },
714
+ ]}>
715
+ <OText
716
+ color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
717
+ size={selOpt == -1 ? 14 : 12}
718
+ weight={selOpt == -1 ? '600' : 'normal'}>
719
+ {t('ALL', 'All')}
720
+ </OText>
721
+ </TouchableOpacity>
722
+ {product?.ingredients.length > 0 && (
723
+ <TouchableOpacity
724
+ key={`eopt_key_01`}
725
+ onPress={() => setSelectedOpt(0)}
726
+ style={[
727
+ styles.extraItem,
728
+ {
729
+ borderBottomColor:
730
+ selOpt == 0 ? theme.colors.textNormal : theme.colors.border,
731
+ },
732
+ ]}>
733
+ <OText
734
+ color={selOpt == 0 ? theme.colors.textNormal : theme.colors.textSecondary}
735
+ size={selOpt == 0 ? 14 : 12}
736
+ weight={selOpt == 0 ? '600' : 'normal'}>
737
+ {t('INGREDIENTS', 'Ingredients')}
559
738
  </OText>
560
- </ProductDescription>
561
- <ScrollView
562
- horizontal
563
- showsHorizontalScrollIndicator={false}
564
- contentContainerStyle={{ paddingBottom: 30 }}
565
- >
566
- {product?.tags?.map((tag: any) => (
739
+ </TouchableOpacity>
740
+ )}
741
+ {product?.extras.map((extra: any) =>
742
+ <ExtraOptions key={extra.id} options={extra.options} />
743
+ )}
744
+ </ExtraOptionWrap>
745
+ )}
746
+ {loading && !product ? (
747
+ <>
748
+ {[...Array(2)].map((item, i) => (
749
+ <Placeholder
750
+ key={i}
751
+ style={{ marginBottom: 20 }}
752
+ Animation={Fade}>
753
+ <PlaceholderLine
754
+ height={40}
755
+ style={{ flex: 1, marginTop: 10 }}
756
+ />
757
+ {[...Array(3)].map((item, i) => (
567
758
  <View
568
- key={tag.id}
569
- style={styles.productTagWrapper}
570
- >
571
- {!!tag?.image ? (
572
- <OIcon
573
- url={optimizeImage(tag?.image, 'h_40,c_limit')}
574
- style={styles.productTagImageStyle}
575
- />
576
- ) : (
577
- <OIcon
578
- src={theme.images?.dummies?.product}
579
- style={styles.productTagImageStyle}
580
- />
581
- )}
582
- <OText color={theme.colors.textSecondary} size={12} style={styles.productTagNameStyle}>{tag.name}</OText>
759
+ key={'place_key_' + i}
760
+ style={{
761
+ flexDirection: 'row',
762
+ justifyContent: 'space-between',
763
+ }}>
764
+ <PlaceholderLine
765
+ height={30}
766
+ width={10}
767
+ style={{ marginBottom: 20 }}
768
+ />
769
+ <PlaceholderLine
770
+ height={30}
771
+ width={50}
772
+ style={{ marginBottom: 20 }}
773
+ />
774
+ <PlaceholderLine
775
+ height={30}
776
+ width={30}
777
+ style={{ marginBottom: 20 }}
778
+ />
583
779
  </View>
584
780
  ))}
585
- </ScrollView>
586
- </ProductSummary>
587
- {loading && !product ? (
781
+ </Placeholder>
782
+ ))}
783
+ </>
784
+ ) : (
785
+ <ProductEditions>
786
+ {selOpt === -1 ? (
588
787
  <>
589
- {[...Array(2)].map((item, i) => (
590
- <Placeholder
591
- key={i}
592
- style={{ marginBottom: 20 }}
593
- Animation={Fade}>
594
- <PlaceholderLine
595
- height={40}
596
- style={{ flex: 1, marginTop: 10 }}
597
- />
598
- {[...Array(3)].map((item, i) => (
599
- <View
600
- key={'place_key_' + i}
601
- style={{
602
- flexDirection: 'row',
603
- justifyContent: 'space-between',
604
- }}>
605
- <PlaceholderLine
606
- height={30}
607
- width={10}
608
- style={{ marginBottom: 20 }}
609
- />
610
- <PlaceholderLine
611
- height={30}
612
- width={50}
613
- style={{ marginBottom: 20 }}
614
- />
615
- <PlaceholderLine
616
- height={30}
617
- width={30}
618
- style={{ marginBottom: 20 }}
788
+ {product?.ingredients.length > 0 && (
789
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0)}>
790
+ <SectionTitle>
791
+ <OText size={16}>
792
+ {t('INGREDIENTS', 'Ingredients')}
793
+ </OText>
794
+ </SectionTitle>
795
+ <WrapperIngredients>
796
+ {product?.ingredients.map((ingredient: any) => (
797
+ <ProductIngredient
798
+ key={ingredient.id}
799
+ ingredient={ingredient}
800
+ state={
801
+ productCart.ingredients[`id:${ingredient.id}`]
802
+ }
803
+ onChange={handleChangeIngredientState}
804
+ isSoldOut={isSoldOut}
619
805
  />
620
- </View>
621
- ))}
622
- </Placeholder>
623
- ))}
806
+ ))}
807
+ </WrapperIngredients>
808
+ </View>
809
+ )}
810
+ {product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
811
+ extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
812
+ const currentState =
813
+ productCart.options[`id:${option.id}`] || {};
814
+ return (
815
+ <React.Fragment key={`popt_${option.id}`}>
816
+ {showOption(option) && (
817
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, option?.id)}>
818
+ <ProductOption
819
+ option={option}
820
+ currentState={currentState}
821
+ error={errors[`id:${option.id}`]}>
822
+ <WrapperSubOption
823
+ style={{
824
+ backgroundColor: isError(option.id),
825
+ borderRadius: 7.6
826
+ }}>
827
+ {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
828
+ (suboption: any) => {
829
+ const currentState =
830
+ productCart.options[
831
+ `id:${option.id}`
832
+ ]?.suboptions[
833
+ `id:${suboption.id}`
834
+ ] || {};
835
+ const balance =
836
+ productCart.options[
837
+ `id:${option.id}`
838
+ ]?.balance || 0;
839
+ return (
840
+ <ProductOptionSubOption
841
+ key={suboption.id}
842
+ isSoldOut={isSoldOut}
843
+ onChange={
844
+ handleChangeSuboptionState
845
+ }
846
+ balance={balance}
847
+ option={option}
848
+ suboption={suboption}
849
+ state={currentState}
850
+ disabled={
851
+ isSoldOut ||
852
+ maxProductQuantity <= 0
853
+ }
854
+ setIsScrollAvailable={setIsScrollAvailable}
855
+ error={errors[`id:${option.id}`]}
856
+ />
857
+ );
858
+ },
859
+ )}
860
+ </WrapperSubOption>
861
+ </ProductOption>
862
+ </View>
863
+ )}
864
+ </React.Fragment>
865
+ );
866
+ }),
867
+ )}
624
868
  </>
625
869
  ) : (
626
- <ProductEditions>
627
- <ExtraOptionWrap
628
- horizontal
629
- showsHorizontalScrollIndicator={false}
630
- style={{ marginBottom: 20 }}
631
- contentContainerStyle={{ paddingHorizontal: 33 }}
632
- >
633
- <TouchableOpacity
634
- key={`eopt_all_0`}
635
- onPress={() => setSelectedOpt(0)}
636
- style={[
637
- styles.extraItem,
638
- {
639
- borderBottomColor: selOpt == 0 ? theme.colors.textNormal : theme.colors.border,
640
- },
641
- ]}>
642
- <OText
643
- color={selOpt == 0 ? theme.colors.textNormal : theme.colors.textSecondary}
644
- size={selOpt == 0 ? 14 : 12}
645
- weight={selOpt == 0 ? '600' : 'normal'}>
646
- {t('ALL', 'All')}
647
- </OText>
648
- </TouchableOpacity>
649
- {product?.ingredients.length > 0 && (
650
- <TouchableOpacity
651
- key={`eopt_all_00`}
652
- onPress={() => setSelectedOpt(-1)}
653
- style={[
654
- styles.extraItem,
655
- {
656
- borderBottomColor:
657
- selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
658
- },
659
- ]}>
660
- <OText
661
- color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
662
- size={selOpt == -1 ? 14 : 12}
663
- weight={selOpt == -1 ? '600' : 'normal'}>
870
+ <>
871
+ {selOpt === 0 ? (
872
+ <View style={styles.optionContainer}>
873
+ <SectionTitle>
874
+ <OText size={16}>
664
875
  {t('INGREDIENTS', 'Ingredients')}
665
876
  </OText>
666
- </TouchableOpacity>
667
- )}
668
- {product?.extras.map((extra: any) =>
669
- <ExtraOptions key={extra.id} options={extra.options} />
670
- )}
671
- </ExtraOptionWrap>
672
-
673
- {selOpt == 0 ? (
877
+ </SectionTitle>
878
+ <WrapperIngredients>
879
+ {product?.ingredients.map((ingredient: any) => (
880
+ <ProductIngredient
881
+ key={ingredient.id}
882
+ ingredient={ingredient}
883
+ state={
884
+ productCart.ingredients[`id:${ingredient.id}`]
885
+ }
886
+ onChange={handleChangeIngredientState}
887
+ isSoldOut={isSoldOut}
888
+ />
889
+ ))}
890
+ </WrapperIngredients>
891
+ </View>
892
+ ) : (
674
893
  <>
675
- {product?.ingredients.length > 0 && (
676
- <View style={styles.optionContainer}>
677
- <SectionTitle>
678
- <OText size={16}>
679
- {t('INGREDIENTS', 'Ingredients')}
680
- </OText>
681
- </SectionTitle>
682
- <WrapperIngredients>
683
- {product?.ingredients.map((ingredient: any) => (
684
- <ProductIngredient
685
- key={ingredient.id}
686
- ingredient={ingredient}
687
- state={
688
- productCart.ingredients[`id:${ingredient.id}`]
689
- }
690
- onChange={handleChangeIngredientState}
691
- isSoldOut={isSoldOut}
692
- />
693
- ))}
694
- </WrapperIngredients>
695
- </View>
696
- )}
697
- {product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
894
+ {product?.extras.map((extra: any) =>
698
895
  extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
699
- const currentState =
700
- productCart.options[`id:${option.id}`] || {};
701
- return (
702
- <React.Fragment key={`popt_${option.id}`}>
703
- {showOption(option) && (
704
- <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, option?.id)}>
705
- <ProductOption
706
- option={option}
707
- currentState={currentState}
708
- error={errors[`id:${option.id}`]}>
709
- <WrapperSubOption
710
- style={{
711
- backgroundColor: isError(option.id),
712
- borderRadius: 7.6
713
- }}>
714
- {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
715
- (suboption: any) => {
716
- const currentState =
717
- productCart.options[
718
- `id:${option.id}`
719
- ]?.suboptions[
720
- `id:${suboption.id}`
721
- ] || {};
722
- const balance =
723
- productCart.options[
724
- `id:${option.id}`
725
- ]?.balance || 0;
726
- return (
727
- <ProductOptionSubOption
728
- key={suboption.id}
729
- isSoldOut={isSoldOut}
730
- onChange={
731
- handleChangeSuboptionState
732
- }
733
- balance={balance}
734
- option={option}
735
- suboption={suboption}
736
- state={currentState}
737
- disabled={
738
- isSoldOut ||
739
- maxProductQuantity <= 0
740
- }
741
- scrollDown={scrollDown}
742
- error={errors[`id:${option.id}`]}
743
- />
744
- );
745
- },
746
- )}
747
- </WrapperSubOption>
748
- </ProductOption>
749
- </View>
750
- )}
751
- </React.Fragment>
752
- );
896
+ if (
897
+ option.id == selOpt ||
898
+ (hasRespected(
899
+ extra.options,
900
+ option.respect_to,
901
+ ) &&
902
+ showOption(option))
903
+ ) {
904
+ const currentState =
905
+ productCart.options[`id:${option.id}`] || {};
906
+ return (
907
+ <React.Fragment key={option.id}>
908
+ {showOption(option) && (
909
+ <View style={styles.optionContainer}>
910
+ <ProductOption
911
+ option={option}
912
+ currentState={currentState}
913
+ error={errors[`id:${option.id}`]}>
914
+ <WrapperSubOption
915
+ style={{
916
+ backgroundColor: isError(
917
+ option.id,
918
+ ),
919
+ }}>
920
+ {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
921
+ (suboption: any) => {
922
+ const currentState =
923
+ productCart.options[
924
+ `id:${option.id}`
925
+ ]?.suboptions[
926
+ `id:${suboption.id}`
927
+ ] || {};
928
+ const balance =
929
+ productCart.options[
930
+ `id:${option.id}`
931
+ ]?.balance || 0;
932
+ return (
933
+ <ProductOptionSubOption
934
+ key={suboption.id}
935
+ onChange={
936
+ handleChangeSuboptionState
937
+ }
938
+ balance={balance}
939
+ option={option}
940
+ suboption={suboption}
941
+ state={currentState}
942
+ disabled={
943
+ isSoldOut ||
944
+ maxProductQuantity <= 0
945
+ }
946
+ />
947
+ );
948
+ },
949
+ )}
950
+ </WrapperSubOption>
951
+ </ProductOption>
952
+ </View>
953
+ )}
954
+ </React.Fragment>
955
+ );
956
+ }
753
957
  }),
754
958
  )}
755
959
  </>
756
- ) : (
757
- <>
758
- {selOpt == -1 ? (
759
- <View style={styles.optionContainer}>
760
- <SectionTitle>
761
- <OText size={16}>
762
- {t('INGREDIENTS', 'Ingredients')}
763
- </OText>
764
- </SectionTitle>
765
- <WrapperIngredients>
766
- {product?.ingredients.map((ingredient: any) => (
767
- <ProductIngredient
768
- key={ingredient.id}
769
- ingredient={ingredient}
770
- state={
771
- productCart.ingredients[`id:${ingredient.id}`]
772
- }
773
- onChange={handleChangeIngredientState}
774
- isSoldOut={isSoldOut}
775
- />
776
- ))}
777
- </WrapperIngredients>
778
- </View>
779
- ) : (
780
- <>
781
- {product?.extras.map((extra: any) =>
782
- extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
783
- if (
784
- option.id == selOpt ||
785
- (hasRespected(
786
- extra.options,
787
- option.respect_to,
788
- ) &&
789
- showOption(option))
790
- ) {
791
- const currentState =
792
- productCart.options[`id:${option.id}`] || {};
793
- return (
794
- <React.Fragment key={option.id}>
795
- {showOption(option) && (
796
- <View style={styles.optionContainer}>
797
- <ProductOption
798
- option={option}
799
- currentState={currentState}
800
- error={errors[`id:${option.id}`]}>
801
- <WrapperSubOption
802
- style={{
803
- backgroundColor: isError(
804
- option.id,
805
- ),
806
- }}>
807
- {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
808
- (suboption: any) => {
809
- const currentState =
810
- productCart.options[
811
- `id:${option.id}`
812
- ]?.suboptions[
813
- `id:${suboption.id}`
814
- ] || {};
815
- const balance =
816
- productCart.options[
817
- `id:${option.id}`
818
- ]?.balance || 0;
819
- return (
820
- <ProductOptionSubOption
821
- key={suboption.id}
822
- onChange={
823
- handleChangeSuboptionState
824
- }
825
- balance={balance}
826
- option={option}
827
- suboption={suboption}
828
- state={currentState}
829
- disabled={
830
- isSoldOut ||
831
- maxProductQuantity <= 0
832
- }
833
- />
834
- );
835
- },
836
- )}
837
- </WrapperSubOption>
838
- </ProductOption>
839
- </View>
840
- )}
841
- </React.Fragment>
842
- );
843
- }
844
- }),
845
- )}
846
- </>
847
- )}
848
- </>
849
- )}
850
- {!product?.hide_special_instructions && (
851
- <ProductComment>
852
- <SectionTitle>
853
- <OText size={16} weight={'600'} lineHeight={24}>
854
- {t('SPECIAL_COMMENT', 'Special comment')}
855
- </OText>
856
- </SectionTitle>
857
- <OInput
858
- multiline
859
- placeholder={t('SPECIAL_COMMENT', 'Special comment')}
860
- value={productCart.comment}
861
- onChange={(val: string) =>
862
- handleChangeCommentState({ target: { value: val } })
863
- }
864
- isDisabled={
865
- !(productCart && !isSoldOut && maxProductQuantity)
866
- }
867
- style={styles.comment}
868
- />
869
- </ProductComment>
870
960
  )}
871
- </ProductEditions>
872
- )}
873
- </WrapContent>
874
- </View>
875
- )}
876
- {!!error && error.length > 0 && (
877
- <NotFoundSource content={error[0]?.message || error[0]} />
878
- )}
879
- </ScrollView>
880
- {!loading && !error && product && (
881
- <ProductActions ios={Platform?.OS === 'ios'}>
882
- <View>
883
- <OText size={16} lineHeight={24} weight={'600'}>
884
- {productCart.total ? parsePrice(productCart?.total) : ''}
885
- </OText>
886
- {product?.minimum_per_order && productCart?.quantity < product?.minimum_per_order && <OText size={12} color={theme.colors?.red}>{t('MOBILE_MINIMUM_TO_ORDER', 'Min. _number_ ').replace('_number_', product?.minimum_per_order)}</OText>}
887
- {product?.maximum_per_order && productCart?.quantity > product?.maximum_per_order && <OText size={12} color={theme.colors?.red}>{t('MOBILE_MAXIMUM_TO_ORDER', 'Max. _number_'.replace('_number_', product?.maximum_per_order))}</OText>}
888
- </View>
889
- {productCart && !isSoldOut && maxProductQuantity > 0 && (
890
- <View style={styles.quantityControl}>
891
- <TouchableOpacity
892
- onPress={decrement}
893
- disabled={productCart.quantity === 1 || isSoldOut}>
894
- <OIcon
895
- src={theme.images.general.minus}
896
- width={16}
897
- color={
898
- productCart.quantity === 1 || isSoldOut
899
- ? theme.colors.backgroundGray
900
- : theme.colors.backgroundDark
901
- }
902
- />
903
- </TouchableOpacity>
904
- {qtyBy?.pieces && (
905
- <TextInput
906
- keyboardType='numeric'
907
- value={`${productCart?.quantity > 0 ? productCart?.quantity : ''}`}
908
- onChangeText={(val: any) => onChangeProductCartQuantity(parseInt(val))}
909
- editable={!orderState.loading}
910
- style={{
911
- borderWidth: 1,
912
- textAlign: 'center',
913
- minWidth: 60,
914
- borderRadius: 8,
915
- borderColor: theme.colors.inputBorderColor,
916
- height: 44,
917
- marginHorizontal: 10
918
- }}
919
- />
961
+ </>
920
962
  )}
921
- {qtyBy?.weight_unit && (
922
- <OText
923
- size={12}
924
- lineHeight={18}
925
- style={{ minWidth: 40, textAlign: 'center' }}
926
- >
927
- {productCart.quantity * product?.weight}
928
- </OText>
963
+ {!product?.hide_special_instructions && (
964
+ <ProductComment>
965
+ <SectionTitle>
966
+ <OText size={16} weight={'600'} lineHeight={24}>
967
+ {t('SPECIAL_COMMENT', 'Special comment')}
968
+ </OText>
969
+ </SectionTitle>
970
+ <OInput
971
+ multiline
972
+ placeholder={t('SPECIAL_COMMENT', 'Special comment')}
973
+ value={productCart.comment}
974
+ onChange={(val: string) =>
975
+ handleChangeCommentState({ target: { value: val } })
976
+ }
977
+ isDisabled={
978
+ !(productCart && !isSoldOut && maxProductQuantity)
979
+ }
980
+ style={styles.comment}
981
+ />
982
+ </ProductComment>
929
983
  )}
930
- <TouchableOpacity
931
- onPress={increment}
932
- disabled={
933
- maxProductQuantity <= 0 ||
934
- productCart.quantity >= maxProductQuantity ||
935
- isSoldOut
936
- }>
937
- <OIcon
938
- src={theme.images.general.plus}
939
- width={16}
940
- color={
941
- maxProductQuantity <= 0 ||
984
+ </ProductEditions>
985
+ )}
986
+ {!!error && error.length > 0 && (
987
+ <NotFoundSource content={error[0]?.message || error[0]} />
988
+ )}
989
+ </ScrollView>
990
+ )}
991
+ {!loading && !error && product && (
992
+ <ProductActions ios={Platform?.OS === 'ios'} isColumn={isHaveWeight}>
993
+ <View style={styles.actionContainer}>
994
+ <View>
995
+ <OText size={16} lineHeight={24} weight={'600'}>
996
+ {productCart.total ? parsePrice(productCart?.total) : ''}
997
+ </OText>
998
+ {product?.minimum_per_order && productCart?.quantity <= product?.minimum_per_order && productCart?.quantity !== 1 && <OText size={12} color={theme.colors?.red}>{t('MOBILE_MINIMUM_TO_ORDER', 'Min. _number_ ').replace('_number_', product?.minimum_per_order)}</OText>}
999
+ {product?.maximum_per_order && productCart?.quantity >= product?.maximum_per_order && <OText size={12} color={theme.colors?.red}>{t('MOBILE_MAXIMUM_TO_ORDER', 'Max. _number_'.replace('_number_', product?.maximum_per_order))}</OText>}
1000
+ </View>
1001
+ {productCart && !isSoldOut && maxProductQuantity > 0 && (
1002
+ <>
1003
+ <View style={styles.quantityControl}>
1004
+ <TouchableOpacity
1005
+ onPress={decrement}
1006
+ disabled={productCart.quantity === 1 || !productCart.quantity || isSoldOut || (productCart?.quantity <= product?.minimum_per_order)}>
1007
+ <OIcon
1008
+ src={theme.images.general.minus}
1009
+ width={16}
1010
+ color={
1011
+ productCart.quantity === 1 || isSoldOut
1012
+ ? theme.colors.backgroundGray
1013
+ : theme.colors.backgroundDark
1014
+ }
1015
+ />
1016
+ </TouchableOpacity>
1017
+ {qtyBy?.pieces && (
1018
+ <TextInput
1019
+ keyboardType='numeric'
1020
+ value={`${productCart?.quantity > 0 ? productCart?.quantity : ''}`}
1021
+ onChangeText={(val: any) => onChangeProductCartQuantity(parseInt(val))}
1022
+ editable={!orderState.loading}
1023
+ style={{
1024
+ borderWidth: 1,
1025
+ textAlign: 'center',
1026
+ minWidth: 60,
1027
+ borderRadius: 8,
1028
+ borderColor: theme.colors.inputBorderColor,
1029
+ height: 44,
1030
+ marginHorizontal: 10
1031
+ }}
1032
+ />
1033
+ )}
1034
+ {qtyBy?.weight_unit && (
1035
+ <OText
1036
+ size={12}
1037
+ lineHeight={18}
1038
+ style={{ minWidth: 40, textAlign: 'center' }}
1039
+ >
1040
+ {productCart.quantity * product?.weight}
1041
+ </OText>
1042
+ )}
1043
+ <TouchableOpacity
1044
+ onPress={increment}
1045
+ disabled={
1046
+ maxProductQuantity <= 0 ||
942
1047
  productCart.quantity >= maxProductQuantity ||
1048
+ (productCart.quantity >= product?.maximum_per_order && product?.maximum_per_order) ||
943
1049
  isSoldOut
944
- ? theme.colors.backgroundGray
945
- : theme.colors.backgroundDark
946
- }
947
- />
948
- </TouchableOpacity>
949
- {isHaveWeight && (
950
- <WeightUnitSwitch>
951
- <TouchableOpacity
952
- onPress={() => handleSwitchQtyUnit('pieces')}
953
- >
954
- <WeightUnitItem active={qtyBy?.pieces}>
955
- <OText
956
- size={12}
957
- lineHeight={18}
958
- color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
959
- >
960
- {t('PIECES', 'pcs')}
961
- </OText>
962
- </WeightUnitItem>
1050
+ }>
1051
+ <OIcon
1052
+ src={theme.images.general.plus}
1053
+ width={16}
1054
+ color={
1055
+ maxProductQuantity <= 0 ||
1056
+ productCart.quantity >= maxProductQuantity ||
1057
+ (productCart.quantity >= product?.maximum_per_order && product?.maximum_per_order) ||
1058
+ isSoldOut
1059
+ ? theme.colors.backgroundGray
1060
+ : theme.colors.backgroundDark
1061
+ }
1062
+ />
963
1063
  </TouchableOpacity>
964
- <View style={{ alignItems: 'flex-start' }}>
1064
+ </View>
1065
+ {isHaveWeight && (
1066
+ <WeightUnitSwitch>
965
1067
  <TouchableOpacity
966
- onPress={() => handleSwitchQtyUnit('weight_unit')}
1068
+ onPress={() => handleSwitchQtyUnit('pieces')}
967
1069
  >
968
- <WeightUnitItem active={qtyBy?.weight_unit}>
1070
+ <WeightUnitItem active={qtyBy?.pieces}>
969
1071
  <OText
970
1072
  size={12}
971
1073
  lineHeight={18}
972
- color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
1074
+ color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
973
1075
  >
974
- {product?.weight_unit}
1076
+ {t('PIECES', 'pcs')}
975
1077
  </OText>
976
1078
  </WeightUnitItem>
977
1079
  </TouchableOpacity>
978
- </View>
979
- </WeightUnitSwitch>
980
- )}
981
- </View>
982
- )}
983
- <View
984
- style={{
985
- width: isSoldOut || maxProductQuantity <= 0 ? '60%' : '40%',
986
- }}>
987
- {((productCart &&
988
- auth &&
989
- orderState.options?.address_id) || (isSoldOut || maxProductQuantity <= 0)) && (
990
- <OButton
991
- onClick={() => handleSaveProduct()}
992
- imgRightSrc=""
993
- text={`${orderState.loading
994
- ? t('LOADING', 'Loading')
995
- : (isSoldOut || maxProductQuantity <= 0)
996
- ? t('SOLD_OUT', 'Sold out')
997
- : editMode
998
- ? t('UPDATE', 'Update')
999
- : t('ADD', 'Add')
1000
- }`}
1001
- isDisabled={isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order))}
1002
- textStyle={{
1003
- color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
1004
- fontSize: orderState.loading || editMode ? 10 : 14
1005
- }}
1006
- style={{
1007
- backgroundColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order)) ? theme.colors.lightGray : theme.colors.primary,
1008
- borderColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order)) ? theme.colors.white : theme.colors.primary,
1009
- opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
1010
- borderRadius: 7.6,
1011
- height: 44,
1012
- shadowOpacity: 0,
1013
- borderWidth: 1,
1014
- }}
1015
- />
1016
- )}
1017
- {auth &&
1018
- !orderState.options?.address_id &&
1019
- (orderState.loading ? (
1020
- <OButton
1021
- isDisabled
1022
- text={t('LOADING', 'Loading')}
1023
- imgRightSrc=""
1024
- textStyle={{ fontSize: 10 }}
1025
- />
1026
- ) : (
1027
- <OButton onClick={navigation.navigate('AddressList')} />
1028
- ))}
1029
- {!auth && (
1030
- <OButton
1031
- isDisabled={isSoldOut || maxProductQuantity <= 0}
1032
- onClick={() => handleRedirectLogin()}
1033
- text={
1034
- isSoldOut || maxProductQuantity <= 0
1035
- ? t('SOLD_OUT', 'Sold out')
1036
- : t('LOGIN_SIGNUP', 'Login / Sign Up')
1037
- }
1038
- imgRightSrc=""
1039
- textStyle={{ color: theme.colors.primary, fontSize: 14 }}
1040
- style={{
1041
- height: 44,
1042
- borderColor: theme.colors.primary,
1043
- backgroundColor: theme.colors.white,
1044
- }}
1045
- />
1080
+ <View style={{ alignItems: 'flex-start' }}>
1081
+ <TouchableOpacity
1082
+ onPress={() => handleSwitchQtyUnit('weight_unit')}
1083
+ >
1084
+ <WeightUnitItem active={qtyBy?.weight_unit}>
1085
+ <OText
1086
+ size={12}
1087
+ lineHeight={18}
1088
+ color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
1089
+ >
1090
+ {product?.weight_unit}
1091
+ </OText>
1092
+ </WeightUnitItem>
1093
+ </TouchableOpacity>
1094
+ </View>
1095
+ </WeightUnitSwitch>
1096
+ )}
1097
+ </>
1046
1098
  )}
1099
+ {!isHaveWeight && <ActionButton />}
1047
1100
  </View>
1101
+ {isHaveWeight && <ActionButton />}
1048
1102
  </ProductActions>
1049
1103
  )}
1050
1104
  </SafeAreaView>
@@ -1055,6 +1109,7 @@ export const ProductOptionsUI = (props: any) => {
1055
1109
  export const ProductForm = (props: any) => {
1056
1110
  const productOptionsProps = {
1057
1111
  ...props,
1112
+ productCart: { quantity: props?.product?.maximum_per_order || props?.product?.minimum_per_order || 1 },
1058
1113
  UIComponent: ProductOptionsUI,
1059
1114
  };
1060
1115