ordering-ui-react-native 0.16.52 → 0.16.53-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 (209) hide show
  1. package/package.json +6 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  5. package/src/components/BusinessInformation/index.tsx +33 -4
  6. package/src/components/BusinessInformation/styles.tsx +2 -2
  7. package/src/components/BusinessProductsList/index.tsx +10 -10
  8. package/src/components/BusinessesListing/index.tsx +1 -1
  9. package/src/components/Checkout/index.tsx +2 -1
  10. package/src/components/LanguageSelector/index.tsx +21 -16
  11. package/src/components/Messages/index.tsx +2 -2
  12. package/src/components/NotificationSetting/index.tsx +85 -0
  13. package/src/components/OrdersOption/index.tsx +54 -56
  14. package/src/components/PaymentOptions/index.tsx +298 -345
  15. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  16. package/src/components/SingleProductReview/index.tsx +7 -4
  17. package/src/components/StripeElementsForm/index.tsx +25 -16
  18. package/src/components/VerifyPhone/styles.tsx +1 -2
  19. package/src/components/shared/OBottomPopup.tsx +6 -2
  20. package/src/components/shared/OToast.tsx +4 -4
  21. package/src/index.tsx +2 -0
  22. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  23. package/src/utils/index.tsx +2 -1
  24. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +260 -238
  25. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  26. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  27. package/themes/business/src/components/Chat/index.tsx +40 -32
  28. package/themes/business/src/components/DriverMap/index.tsx +7 -5
  29. package/themes/business/src/components/DriverSchedule/index.tsx +36 -19
  30. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  31. package/themes/business/src/components/MapView/index.tsx +12 -1
  32. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  33. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -41
  34. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +40 -30
  35. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
  36. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  37. package/themes/business/src/components/OrdersOption/index.tsx +76 -77
  38. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  39. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  40. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  41. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  42. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  43. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  44. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  45. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  46. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  47. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  48. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  49. package/themes/business/src/components/PreviousOrders/index.tsx +440 -245
  50. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  51. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  52. package/themes/business/src/components/ReviewCustomer/index.tsx +39 -15
  53. package/themes/business/src/components/ScheduleBlocked/index.tsx +2 -2
  54. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  55. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  56. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  57. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  58. package/themes/business/src/components/shared/OLink.tsx +24 -12
  59. package/themes/business/src/components/shared/OText.tsx +3 -2
  60. package/themes/business/src/types/index.tsx +25 -11
  61. package/themes/business/src/utils/index.tsx +10 -0
  62. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  63. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  64. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  65. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  66. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  67. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  68. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  69. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  70. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  71. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  72. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  73. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  74. package/themes/kiosk/src/types/index.d.ts +2 -0
  75. package/themes/original/index.tsx +8 -6
  76. package/themes/original/src/components/AddressDetails/index.tsx +10 -8
  77. package/themes/original/src/components/AddressForm/index.tsx +157 -140
  78. package/themes/original/src/components/AddressList/index.tsx +1 -1
  79. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  80. package/themes/original/src/components/BusinessBasicInformation/index.tsx +218 -147
  81. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +2 -2
  82. package/themes/original/src/components/BusinessController/index.tsx +192 -91
  83. package/themes/original/src/components/BusinessController/styles.tsx +14 -9
  84. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  85. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
  86. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  87. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  88. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  89. package/themes/original/src/components/BusinessListingSearch/index.tsx +85 -137
  90. package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
  91. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  92. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  93. package/themes/original/src/components/BusinessProductsList/index.tsx +59 -61
  94. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  95. package/themes/original/src/components/BusinessProductsListing/index.tsx +179 -83
  96. package/themes/original/src/components/BusinessProductsListing/styles.tsx +19 -12
  97. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
  98. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +28 -29
  99. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +299 -148
  100. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +47 -11
  101. package/themes/original/src/components/BusinessesListing/index.tsx +51 -71
  102. package/themes/original/src/components/Cart/index.tsx +82 -15
  103. package/themes/original/src/components/Cart/styles.tsx +4 -0
  104. package/themes/original/src/components/CartContent/index.tsx +27 -17
  105. package/themes/original/src/components/CartContent/styles.tsx +1 -1
  106. package/themes/original/src/components/Checkout/index.tsx +114 -118
  107. package/themes/original/src/components/Checkout/styles.tsx +4 -3
  108. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  109. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  110. package/themes/original/src/components/DriverTips/index.tsx +4 -4
  111. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  112. package/themes/original/src/components/FavoriteList/index.tsx +69 -45
  113. package/themes/original/src/components/FloatingButton/index.tsx +13 -11
  114. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  115. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  116. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  117. package/themes/original/src/components/GoogleMap/index.tsx +20 -12
  118. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +25 -10
  119. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +4 -0
  120. package/themes/original/src/components/HelpGuide/index.tsx +9 -8
  121. package/themes/original/src/components/HelpOrder/index.tsx +9 -8
  122. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  123. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  124. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  125. package/themes/original/src/components/LoginForm/index.tsx +98 -41
  126. package/themes/original/src/components/LottieAnimation/index.tsx +69 -0
  127. package/themes/original/src/components/Messages/index.tsx +35 -20
  128. package/themes/original/src/components/MomentOption/index.tsx +8 -6
  129. package/themes/original/src/components/MultiCart/index.tsx +63 -0
  130. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
  131. package/themes/original/src/components/MultiCheckout/index.tsx +10 -2
  132. package/themes/original/src/components/MultiOrdersDetails/index.tsx +34 -16
  133. package/themes/original/src/components/MyOrders/index.tsx +88 -24
  134. package/themes/original/src/components/NavBar/index.tsx +11 -5
  135. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  136. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  137. package/themes/original/src/components/Notifications/index.tsx +148 -0
  138. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  139. package/themes/original/src/components/OrderDetails/index.tsx +162 -50
  140. package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
  141. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  142. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  143. package/themes/original/src/components/OrderProgress/index.tsx +77 -66
  144. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  145. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  146. package/themes/original/src/components/OrderTypeSelector/index.tsx +85 -36
  147. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  148. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +94 -98
  149. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  150. package/themes/original/src/components/OrdersOption/index.tsx +91 -53
  151. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  152. package/themes/original/src/components/PaymentOptions/index.tsx +1 -2
  153. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  154. package/themes/original/src/components/PlaceSpot/index.tsx +249 -47
  155. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  156. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  157. package/themes/original/src/components/ProductForm/index.tsx +365 -384
  158. package/themes/original/src/components/ProductForm/styles.tsx +7 -12
  159. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  160. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  161. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  162. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +0 -1
  163. package/themes/original/src/components/ProfessionalFilter/index.tsx +2 -1
  164. package/themes/original/src/components/ProfessionalProfile/index.tsx +19 -8
  165. package/themes/original/src/components/Promotions/index.tsx +232 -219
  166. package/themes/original/src/components/Promotions/styles.tsx +7 -2
  167. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  168. package/themes/original/src/components/ReviewOrder/index.tsx +120 -108
  169. package/themes/original/src/components/ReviewOrder/styles.tsx +5 -7
  170. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  171. package/themes/original/src/components/ReviewTrigger/index.tsx +136 -0
  172. package/themes/original/src/components/{Reviews/ReviewOrder → ReviewTrigger}/styles.tsx +10 -22
  173. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  174. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  175. package/themes/original/src/components/ServiceForm/index.tsx +330 -266
  176. package/themes/original/src/components/SignupForm/index.tsx +134 -89
  177. package/themes/original/src/components/SingleOrderCard/index.tsx +219 -129
  178. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  179. package/themes/original/src/components/SingleProductCard/index.tsx +180 -104
  180. package/themes/original/src/components/SingleProductCard/styles.tsx +3 -10
  181. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  182. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  183. package/themes/original/src/components/StripeElementsForm/index.tsx +13 -2
  184. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -5
  185. package/themes/original/src/components/UserDetails/index.tsx +5 -3
  186. package/themes/original/src/components/UserFormDetails/index.tsx +6 -48
  187. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  188. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  189. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  190. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  191. package/themes/original/src/components/Wallets/index.tsx +176 -164
  192. package/themes/original/src/components/Wallets/styles.tsx +12 -8
  193. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  194. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  195. package/themes/original/src/components/shared/OBottomPopup.tsx +36 -22
  196. package/themes/original/src/components/shared/OButton.tsx +10 -3
  197. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  198. package/themes/original/src/components/shared/OInput.tsx +10 -1
  199. package/themes/original/src/layouts/Container.tsx +13 -9
  200. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  201. package/themes/original/src/types/index.tsx +65 -13
  202. package/themes/original/src/utils/index.tsx +103 -58
  203. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  204. package/themes/original/src/components/Reviews/ReviewDriver/index.tsx +0 -301
  205. package/themes/original/src/components/Reviews/ReviewDriver/styles.tsx +0 -39
  206. package/themes/original/src/components/Reviews/ReviewOrder/index.tsx +0 -326
  207. package/themes/original/src/components/Reviews/ReviewProducts/index.tsx +0 -101
  208. package/themes/original/src/components/Reviews/ReviewProducts/styles.tsx +0 -17
  209. package/themes/original/src/components/Reviews/index.tsx +0 -9
@@ -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) => {
@@ -66,11 +69,14 @@ export const ProductOptionsUI = (props: any) => {
66
69
  handleChangeSuboptionState,
67
70
  handleChangeCommentState,
68
71
  productObject,
72
+ productAddedToCartLength
69
73
  } = props;
70
74
 
71
75
  const theme = useTheme();
72
76
  const [, { showToast }] = useToast()
73
77
 
78
+ const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
79
+
74
80
  const styles = StyleSheet.create({
75
81
  mainContainer: {
76
82
 
@@ -122,6 +128,7 @@ export const ProductOptionsUI = (props: any) => {
122
128
  },
123
129
  slide1: {
124
130
  flex: 1,
131
+ alignItems: 'center'
125
132
  },
126
133
  mainSwiper: {
127
134
  height: 258,
@@ -151,6 +158,13 @@ export const ProductOptionsUI = (props: any) => {
151
158
  productTagNameStyle: {
152
159
  paddingHorizontal: 6,
153
160
  marginRight: 5
161
+ },
162
+ actionContainer: {
163
+ flexDirection: 'row',
164
+ alignItems: 'center',
165
+ justifyContent: 'space-between',
166
+ width: '100%',
167
+ marginTop: 10
154
168
  }
155
169
  });
156
170
 
@@ -162,7 +176,7 @@ export const ProductOptionsUI = (props: any) => {
162
176
  const [gallery, setGallery] = useState([])
163
177
  const [thumbsSwiper, setThumbsSwiper] = useState(0)
164
178
  const [indexGallery, setIndexGallery] = useState(0)
165
- const [selOpt, setSelectedOpt] = useState(0);
179
+ const [selOpt, setSelectedOpt] = useState(-1);
166
180
  const [isHaveWeight, setIsHaveWeight] = useState(false)
167
181
  const [playing, setPlaying] = useState(false);
168
182
  const [qtyBy, setQtyBy] = useState({
@@ -176,6 +190,7 @@ export const ProductOptionsUI = (props: any) => {
176
190
  const [headerRefHeight, setHeaderRefHeight] = useState(0)
177
191
  const [summaryRefHeight, setSummaryRefHeight] = useState(0)
178
192
  const [isScrollAvailable, setIsScrollAvailable] = useState(null)
193
+ const [editionsLayoutY, setEditionsLayoutY] = useState(null)
179
194
 
180
195
  const isError = (id: number) => {
181
196
  let bgColor = theme.colors.white;
@@ -284,6 +299,7 @@ export const ProductOptionsUI = (props: any) => {
284
299
  maxProductQuantity === 0 ||
285
300
  Object.keys(errors).length > 0;
286
301
 
302
+
287
303
  const ExtraOptions = ({ eID, options }: any) => (
288
304
  <>
289
305
  {options.map(({ id, name, respect_to, suboptions }: any) => (
@@ -291,20 +307,28 @@ export const ProductOptionsUI = (props: any) => {
291
307
  {respect_to == null && suboptions?.length > 0 && (
292
308
  <TouchableOpacity
293
309
  key={`eopt_key_${id}`}
294
- onPress={() => setSelectedOpt(id)}
310
+ onPress={() => {
311
+ setSelectedOpt(id)
312
+ scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
313
+ y: optionLayout[`id:${id}`]?.y + editionsLayoutY - 50,
314
+ animated: true
315
+ })
316
+ }}
295
317
  style={[
296
318
  styles.extraItem,
297
319
  {
298
320
  borderBottomColor:
299
- selOpt == id ? theme.colors.textNormal : theme.colors.border,
321
+ selOpt == id ? theme.colors.textNormal : theme.colors.backgroundPage,
300
322
  },
301
323
  ]}>
302
324
  <OText
303
325
  color={
304
326
  selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
305
327
  }
306
- size={selOpt == id ? 14 : 12}
307
- weight={selOpt == id ? '600' : 'normal'}>
328
+ size={12}
329
+ weight={selOpt == id ? '600' : 'normal'}
330
+ style={{ maxWidth: 150 }}
331
+ numberOfLines={1}>
308
332
  {name}
309
333
  </OText>
310
334
  </TouchableOpacity>
@@ -314,6 +338,14 @@ export const ProductOptionsUI = (props: any) => {
314
338
  </>
315
339
  );
316
340
 
341
+ const handleScroll = ({ nativeEvent: { contentOffset, layoutMeasurement } }: any) => {
342
+
343
+ const _topOption = Object.keys(optionLayout).find(((option: any) => Math.abs(contentOffset?.y - layoutMeasurement?.height - optionLayout[option]?.y) < 20))
344
+ if (_topOption) {
345
+ const _topOptionId = Number(_topOption.replace('id:', ''))
346
+ }
347
+ }
348
+
317
349
  const handleGoBack = navigation?.canGoBack()
318
350
  ? () => navigation.goBack()
319
351
  : () => navigation.navigate('Business', { store: props.businessSlug })
@@ -328,7 +360,10 @@ export const ProductOptionsUI = (props: any) => {
328
360
  useEffect(() => {
329
361
  const imageList: any = []
330
362
  const videoList: any = []
331
- product?.images && imageList.push(product.images)
363
+ imageList.push(product?.images?.length > 0
364
+ ? product.images
365
+ : theme?.images?.dummies?.product)
366
+
332
367
  if (product?.gallery && product?.gallery.length > 0) {
333
368
  for (const img of product?.gallery) {
334
369
  if (img?.file) {
@@ -366,18 +401,101 @@ export const ProductOptionsUI = (props: any) => {
366
401
  }
367
402
  }, [product])
368
403
 
404
+ const ActionButton = () => {
405
+ return (
406
+ <View
407
+ style={{
408
+ width: isHaveWeight ? '100%' : ((isSoldOut || maxProductQuantity <= 0) ? '60%' : '40%'),
409
+ }}>
410
+ {((productCart &&
411
+ auth &&
412
+ orderState.options?.address_id) || (isSoldOut || maxProductQuantity <= 0)) && (
413
+ <OButton
414
+ onClick={() => handleSaveProduct()}
415
+ imgRightSrc=""
416
+ text={`${orderState.loading
417
+ ? t('LOADING', 'Loading')
418
+ : (isSoldOut || maxProductQuantity <= 0)
419
+ ? t('SOLD_OUT', 'Sold out')
420
+ : editMode
421
+ ? t('UPDATE', 'Update')
422
+ : t('ADD', 'Add')
423
+ }`}
424
+ isDisabled={isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && ((productCart?.quantity + productAddedToCartLength) < product?.minimum_per_order)) || (product?.maximum_per_order && ((productCart?.quantity + productAddedToCartLength) > product?.maximum_per_order))}
425
+ textStyle={{
426
+ color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
427
+ fontSize: orderState.loading || editMode ? 10 : 14
428
+ }}
429
+ style={{
430
+ backgroundColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && ((productCart?.quantity + productAddedToCartLength) < product?.minimum_per_order)) || (product?.maximum_per_order && ((productCart?.quantity + productAddedToCartLength) > product?.maximum_per_order)) ? theme.colors.lightGray : theme.colors.primary,
431
+ borderColor: saveErrors || isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && ((productCart?.quantity + productAddedToCartLength) < product?.minimum_per_order)) || (product?.maximum_per_order && ((productCart?.quantity + productAddedToCartLength) > product?.maximum_per_order)) ? theme.colors.white : theme.colors.primary,
432
+ opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
433
+ borderRadius: 7.6,
434
+ height: 44,
435
+ shadowOpacity: 0,
436
+ borderWidth: 1,
437
+ marginTop: isHaveWeight ? 10 : 0
438
+ }}
439
+ />
440
+ )}
441
+ {auth &&
442
+ !orderState.options?.address_id &&
443
+ (orderState.loading ? (
444
+ <OButton
445
+ isDisabled
446
+ text={t('LOADING', 'Loading')}
447
+ imgRightSrc=""
448
+ textStyle={{ fontSize: 10 }}
449
+ />
450
+ ) : (
451
+ <OButton onClick={navigation.navigate('AddressList')} />
452
+ ))}
453
+ {!auth && (
454
+ <OButton
455
+ isDisabled={isSoldOut || maxProductQuantity <= 0}
456
+ onClick={() => handleRedirectLogin()}
457
+ text={
458
+ isSoldOut || maxProductQuantity <= 0
459
+ ? t('SOLD_OUT', 'Sold out')
460
+ : t('LOGIN_SIGNUP', 'Login / Sign Up')
461
+ }
462
+ imgRightSrc=""
463
+ textStyle={{ color: theme.colors.primary, fontSize: 14 }}
464
+ style={{
465
+ height: 44,
466
+ borderColor: theme.colors.primary,
467
+ backgroundColor: theme.colors.white,
468
+ }}
469
+ />
470
+ )}
471
+ </View>
472
+ )
473
+ }
474
+
475
+ useEffect(() => {
476
+ const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
477
+ scrollViewRef.current.scrollToEnd({ animated: true })
478
+ })
479
+ return () => {
480
+ keyboardDidShowListener.remove()
481
+ }
482
+ }, [])
483
+
484
+
369
485
  return (
370
486
  <SafeAreaView style={{ flex: 1 }}>
371
487
  <TopHeader>
372
488
  <TopActions onPress={() => handleGoBack()}>
373
- <OIcon src={theme.images.general.arrow_left} width={30} />
489
+ <IconAntDesign name='arrowleft' size={26} />
374
490
  </TopActions>
375
491
  </TopHeader>
376
492
  {!error && (
377
493
  <ScrollView
378
494
  ref={scrollViewRef}
379
495
  contentContainerStyle={{ paddingBottom: 80 }}
380
- stickyHeaderIndices={[2]}>
496
+ stickyHeaderIndices={[2]}
497
+ onScroll={handleScroll}
498
+ >
381
499
  <WrapHeader onLayout={(event: any) => setHeaderRefHeight(event.nativeEvent.layout?.height)}>
382
500
  {loading && !product ? (
383
501
  <View style={styles.productHeaderSkeleton}>
@@ -424,18 +542,19 @@ export const ProductOptionsUI = (props: any) => {
424
542
  style={styles.slide1}
425
543
  key={i}
426
544
  >
427
- {img.includes('image') ? (
545
+ {(String(img).includes('http') || typeof img === 'number') ? (
428
546
  <FastImage
429
- style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1 }}
430
- source={{
547
+ style={{ height: '100%', opacity: isSoldOut ? 0.5 : 1, aspectRatio: 3 / 2 }}
548
+ source={typeof img !== 'number' ? {
431
549
  uri: optimizeImage(img, 'h_1024,c_limit'),
432
550
  priority: FastImage.priority.normal,
433
- }}
551
+ } : img}
434
552
  />
435
553
  ) : (
436
554
  <>
437
555
  <YoutubePlayer
438
- height={300}
556
+ height={'100%'}
557
+ width={'100%'}
439
558
  play={playing}
440
559
  videoId={img}
441
560
  onChangeState={onStateChange}
@@ -466,7 +585,7 @@ export const ProductOptionsUI = (props: any) => {
466
585
  opacity: index === thumbsSwiper ? 1 : 0.8
467
586
  }}
468
587
  >
469
- {img.includes('image') ? (
588
+ {String(img).includes('http') ? (
470
589
  <OIcon
471
590
  url={img}
472
591
  style={{
@@ -481,7 +600,7 @@ export const ProductOptionsUI = (props: any) => {
481
600
  />
482
601
  ) : (
483
602
  <OIcon
484
- url={'http://img.youtube.com/vi/' + img + '/0.jpg'}
603
+ url={'https://img.youtube.com/vi/' + img + '/0.jpg'}
485
604
  style={{
486
605
  borderColor: theme.colors.lightGray,
487
606
  borderRadius: 8,
@@ -501,7 +620,10 @@ export const ProductOptionsUI = (props: any) => {
501
620
  </>
502
621
  )}
503
622
  </WrapHeader>
504
- <ProductSummary onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}>
623
+ <ProductSummary
624
+ ph={isChewLayout ? 20 : 40}
625
+ onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}
626
+ >
505
627
  <ProductTitle>
506
628
  {loading && !product ? (
507
629
  <Placeholder Animation={Fade}>
@@ -597,40 +719,35 @@ export const ProductOptionsUI = (props: any) => {
597
719
  <ExtraOptionWrap
598
720
  horizontal
599
721
  showsHorizontalScrollIndicator={false}
600
- style={{ marginBottom: 20 }}
601
- contentContainerStyle={{ marginHorizontal: 40, paddingHorizontal: 33, backgroundColor: theme.colors.white }}
722
+ style={{
723
+ marginBottom: 20,
724
+ borderBottomWidth: 1,
725
+ borderBottomColor: theme.colors.border,
726
+ marginHorizontal: isChewLayout ? 20 : 30,
727
+ backgroundColor: theme.colors.backgroundPage,
728
+ }}
602
729
  >
603
- <TouchableOpacity
604
- key={`eopt_all_0`}
605
- onPress={() => setSelectedOpt(0)}
606
- style={[
607
- styles.extraItem,
608
- {
609
- borderBottomColor: selOpt == 0 ? theme.colors.textNormal : theme.colors.border,
610
- },
611
- ]}>
612
- <OText
613
- color={selOpt == 0 ? theme.colors.textNormal : theme.colors.textSecondary}
614
- size={selOpt == 0 ? 14 : 12}
615
- weight={selOpt == 0 ? '600' : 'normal'}>
616
- {t('ALL', 'All')}
617
- </OText>
618
- </TouchableOpacity>
619
730
  {product?.ingredients.length > 0 && (
620
731
  <TouchableOpacity
621
- key={`eopt_all_00`}
622
- onPress={() => setSelectedOpt(-1)}
732
+ key={`eopt_key_01`}
733
+ onPress={() => {
734
+ setSelectedOpt(0)
735
+ scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
736
+ y: optionLayout[`id:0`]?.y + editionsLayoutY - 50,
737
+ animated: true
738
+ })
739
+ }}
623
740
  style={[
624
741
  styles.extraItem,
625
742
  {
626
743
  borderBottomColor:
627
- selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
744
+ selOpt == 0 ? theme.colors.textNormal : theme.colors.backgroundPage,
628
745
  },
629
746
  ]}>
630
747
  <OText
631
- color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
632
- size={selOpt == -1 ? 14 : 12}
633
- weight={selOpt == -1 ? '600' : 'normal'}>
748
+ color={selOpt == 0 ? theme.colors.textNormal : theme.colors.textSecondary}
749
+ size={12}
750
+ weight={selOpt == 0 ? '600' : 'normal'}>
634
751
  {t('INGREDIENTS', 'Ingredients')}
635
752
  </OText>
636
753
  </TouchableOpacity>
@@ -679,184 +796,94 @@ export const ProductOptionsUI = (props: any) => {
679
796
  ))}
680
797
  </>
681
798
  ) : (
682
- <ProductEditions>
683
- {selOpt == 0 ? (
684
- <>
685
- {product?.ingredients.length > 0 && (
686
- <View style={styles.optionContainer}>
687
- <SectionTitle>
688
- <OText size={16}>
689
- {t('INGREDIENTS', 'Ingredients')}
690
- </OText>
691
- </SectionTitle>
692
- <WrapperIngredients>
693
- {product?.ingredients.map((ingredient: any) => (
694
- <ProductIngredient
695
- key={ingredient.id}
696
- ingredient={ingredient}
697
- state={
698
- productCart.ingredients[`id:${ingredient.id}`]
699
- }
700
- onChange={handleChangeIngredientState}
701
- isSoldOut={isSoldOut}
702
- />
703
- ))}
704
- </WrapperIngredients>
705
- </View>
706
- )}
707
- {product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
708
- extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
709
- const currentState =
710
- productCart.options[`id:${option.id}`] || {};
711
- return (
712
- <React.Fragment key={`popt_${option.id}`}>
713
- {showOption(option) && (
714
- <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, option?.id)}>
715
- <ProductOption
716
- option={option}
717
- currentState={currentState}
718
- error={errors[`id:${option.id}`]}>
719
- <WrapperSubOption
720
- style={{
721
- backgroundColor: isError(option.id),
722
- borderRadius: 7.6
723
- }}>
724
- {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
725
- (suboption: any) => {
726
- const currentState =
727
- productCart.options[
728
- `id:${option.id}`
729
- ]?.suboptions[
730
- `id:${suboption.id}`
731
- ] || {};
732
- const balance =
733
- productCart.options[
734
- `id:${option.id}`
735
- ]?.balance || 0;
736
- return (
737
- <ProductOptionSubOption
738
- key={suboption.id}
739
- isSoldOut={isSoldOut}
740
- onChange={
741
- handleChangeSuboptionState
742
- }
743
- balance={balance}
744
- option={option}
745
- suboption={suboption}
746
- state={currentState}
747
- disabled={
748
- isSoldOut ||
749
- maxProductQuantity <= 0
750
- }
751
- setIsScrollAvailable={setIsScrollAvailable}
752
- error={errors[`id:${option.id}`]}
753
- />
754
- );
755
- },
756
- )}
757
- </WrapperSubOption>
758
- </ProductOption>
759
- </View>
760
- )}
761
- </React.Fragment>
762
- );
763
- }),
764
- )}
765
- </>
766
- ) : (
767
- <>
768
- {selOpt == -1 ? (
769
- <View style={styles.optionContainer}>
770
- <SectionTitle>
771
- <OText size={16}>
772
- {t('INGREDIENTS', 'Ingredients')}
773
- </OText>
774
- </SectionTitle>
775
- <WrapperIngredients>
776
- {product?.ingredients.map((ingredient: any) => (
777
- <ProductIngredient
778
- key={ingredient.id}
779
- ingredient={ingredient}
780
- state={
781
- productCart.ingredients[`id:${ingredient.id}`]
782
- }
783
- onChange={handleChangeIngredientState}
784
- isSoldOut={isSoldOut}
785
- />
786
- ))}
787
- </WrapperIngredients>
788
- </View>
789
- ) : (
790
- <>
791
- {product?.extras.map((extra: any) =>
792
- extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
793
- if (
794
- option.id == selOpt ||
795
- (hasRespected(
796
- extra.options,
797
- option.respect_to,
798
- ) &&
799
- showOption(option))
800
- ) {
801
- const currentState =
802
- productCart.options[`id:${option.id}`] || {};
803
- return (
804
- <React.Fragment key={option.id}>
805
- {showOption(option) && (
806
- <View style={styles.optionContainer}>
807
- <ProductOption
808
- option={option}
809
- currentState={currentState}
810
- error={errors[`id:${option.id}`]}>
811
- <WrapperSubOption
812
- style={{
813
- backgroundColor: isError(
814
- option.id,
815
- ),
816
- }}>
817
- {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
818
- (suboption: any) => {
819
- const currentState =
820
- productCart.options[
821
- `id:${option.id}`
822
- ]?.suboptions[
823
- `id:${suboption.id}`
824
- ] || {};
825
- const balance =
826
- productCart.options[
827
- `id:${option.id}`
828
- ]?.balance || 0;
829
- return (
830
- <ProductOptionSubOption
831
- key={suboption.id}
832
- onChange={
833
- handleChangeSuboptionState
834
- }
835
- balance={balance}
836
- option={option}
837
- suboption={suboption}
838
- state={currentState}
839
- disabled={
840
- isSoldOut ||
841
- maxProductQuantity <= 0
842
- }
843
- />
844
- );
845
- },
846
- )}
847
- </WrapperSubOption>
848
- </ProductOption>
849
- </View>
850
- )}
851
- </React.Fragment>
852
- );
799
+ <ProductEditions
800
+ style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}
801
+ onLayout={(event: any) => {
802
+ setEditionsLayoutY(event.nativeEvent.layout?.y)
803
+ }}
804
+ >
805
+ <>
806
+ {product?.ingredients.length > 0 && (
807
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0)}>
808
+ <SectionTitle>
809
+ <OText size={16}>
810
+ {t('INGREDIENTS', 'Ingredients')}
811
+ </OText>
812
+ </SectionTitle>
813
+ <WrapperIngredients>
814
+ {product?.ingredients.map((ingredient: any) => (
815
+ <ProductIngredient
816
+ key={ingredient.id}
817
+ ingredient={ingredient}
818
+ state={
819
+ productCart.ingredients[`id:${ingredient.id}`]
853
820
  }
854
- }),
855
- )}
856
- </>
857
- )}
858
- </>
859
- )}
821
+ onChange={handleChangeIngredientState}
822
+ isSoldOut={isSoldOut}
823
+ />
824
+ ))}
825
+ </WrapperIngredients>
826
+ </View>
827
+ )}
828
+ {product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
829
+ extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
830
+ const currentState =
831
+ productCart.options[`id:${option.id}`] || {};
832
+ return (
833
+ <React.Fragment key={`popt_${option.id}`}>
834
+ {showOption(option) && (
835
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, option?.id)}>
836
+ <ProductOption
837
+ option={option}
838
+ currentState={currentState}
839
+ error={errors[`id:${option.id}`]}>
840
+ <WrapperSubOption
841
+ style={{
842
+ backgroundColor: isError(option.id),
843
+ borderRadius: 7.6
844
+ }}>
845
+ {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
846
+ (suboption: any) => {
847
+ const currentState =
848
+ productCart.options[
849
+ `id:${option.id}`
850
+ ]?.suboptions[
851
+ `id:${suboption.id}`
852
+ ] || {};
853
+ const balance =
854
+ productCart.options[
855
+ `id:${option.id}`
856
+ ]?.balance || 0;
857
+ return (
858
+ <ProductOptionSubOption
859
+ key={suboption.id}
860
+ isSoldOut={isSoldOut}
861
+ onChange={
862
+ handleChangeSuboptionState
863
+ }
864
+ balance={balance}
865
+ option={option}
866
+ suboption={suboption}
867
+ state={currentState}
868
+ disabled={
869
+ isSoldOut ||
870
+ maxProductQuantity <= 0
871
+ }
872
+ setIsScrollAvailable={setIsScrollAvailable}
873
+ error={errors[`id:${option.id}`]}
874
+ />
875
+ );
876
+ },
877
+ )}
878
+ </WrapperSubOption>
879
+ </ProductOption>
880
+ </View>
881
+ )}
882
+ </React.Fragment>
883
+ );
884
+ }),
885
+ )}
886
+ </>
860
887
  {!product?.hide_special_instructions && (
861
888
  <ProductComment>
862
889
  <SectionTitle>
@@ -886,173 +913,117 @@ export const ProductOptionsUI = (props: any) => {
886
913
  </ScrollView>
887
914
  )}
888
915
  {!loading && !error && product && (
889
- <ProductActions ios={Platform?.OS === 'ios'}>
890
- <View>
891
- <OText size={16} lineHeight={24} weight={'600'}>
892
- {productCart.total ? parsePrice(productCart?.total) : ''}
893
- </OText>
894
- {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>}
895
- {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>}
896
- </View>
897
- {productCart && !isSoldOut && maxProductQuantity > 0 && (
898
- <View style={styles.quantityControl}>
899
- <TouchableOpacity
900
- onPress={decrement}
901
- disabled={productCart.quantity === 1 || isSoldOut}>
902
- <OIcon
903
- src={theme.images.general.minus}
904
- width={16}
905
- color={
906
- productCart.quantity === 1 || isSoldOut
907
- ? theme.colors.backgroundGray
908
- : theme.colors.backgroundDark
909
- }
910
- />
911
- </TouchableOpacity>
912
- {qtyBy?.pieces && (
913
- <TextInput
914
- keyboardType='numeric'
915
- value={`${productCart?.quantity > 0 ? productCart?.quantity : ''}`}
916
- onChangeText={(val: any) => onChangeProductCartQuantity(parseInt(val))}
917
- editable={!orderState.loading}
918
- style={{
919
- borderWidth: 1,
920
- textAlign: 'center',
921
- minWidth: 60,
922
- borderRadius: 8,
923
- borderColor: theme.colors.inputBorderColor,
924
- height: 44,
925
- marginHorizontal: 10
926
- }}
927
- />
928
- )}
929
- {qtyBy?.weight_unit && (
930
- <OText
931
- size={12}
932
- lineHeight={18}
933
- style={{ minWidth: 40, textAlign: 'center' }}
934
- >
935
- {productCart.quantity * product?.weight}
936
- </OText>
937
- )}
938
- <TouchableOpacity
939
- onPress={increment}
940
- disabled={
941
- maxProductQuantity <= 0 ||
942
- productCart.quantity >= maxProductQuantity ||
943
- isSoldOut
944
- }>
945
- <OIcon
946
- src={theme.images.general.plus}
947
- width={16}
948
- color={
949
- maxProductQuantity <= 0 ||
950
- productCart.quantity >= maxProductQuantity ||
951
- isSoldOut
952
- ? theme.colors.backgroundGray
953
- : theme.colors.backgroundDark
954
- }
955
- />
956
- </TouchableOpacity>
957
- {isHaveWeight && (
958
- <WeightUnitSwitch>
916
+ <ProductActions ios={Platform?.OS === 'ios'} isColumn={isHaveWeight}>
917
+ <View style={styles.actionContainer}>
918
+ <View>
919
+ <OText size={16} lineHeight={24} weight={'600'}>
920
+ {productCart.total ? parsePrice(productCart?.total) : ''}
921
+ </OText>
922
+ {product?.minimum_per_order && (productCart?.quantity + productAddedToCartLength) <= 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>}
923
+ {product?.maximum_per_order && (productCart?.quantity + productAddedToCartLength) >= 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>}
924
+ </View>
925
+ {productCart && !isSoldOut && maxProductQuantity > 0 && (
926
+ <>
927
+ <View style={styles.quantityControl}>
959
928
  <TouchableOpacity
960
- onPress={() => handleSwitchQtyUnit('pieces')}
961
- >
962
- <WeightUnitItem active={qtyBy?.pieces}>
963
- <OText
964
- size={12}
965
- lineHeight={18}
966
- color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
967
- >
968
- {t('PIECES', 'pcs')}
969
- </OText>
970
- </WeightUnitItem>
929
+ onPress={decrement}
930
+ disabled={productCart.quantity === 1 || !productCart.quantity || isSoldOut || ((productCart?.quantity + productAddedToCartLength) <= product?.minimum_per_order)}>
931
+ <OIcon
932
+ src={theme.images.general.minus}
933
+ width={20}
934
+ color={
935
+ productCart.quantity === 1 || isSoldOut
936
+ ? theme.colors.backgroundGray
937
+ : theme.colors.backgroundDark
938
+ }
939
+ />
971
940
  </TouchableOpacity>
972
- <View style={{ alignItems: 'flex-start' }}>
941
+ {qtyBy?.pieces && (
942
+ <TextInput
943
+ keyboardType='numeric'
944
+ value={`${productCart?.quantity > 0 ? productCart?.quantity : ''}`}
945
+ onChangeText={(val: any) => onChangeProductCartQuantity(parseInt(val))}
946
+ editable={!orderState.loading}
947
+ style={{
948
+ borderWidth: 1,
949
+ textAlign: 'center',
950
+ minWidth: 60,
951
+ borderRadius: 8,
952
+ borderColor: theme.colors.inputBorderColor,
953
+ height: 44,
954
+ marginHorizontal: 10,
955
+ fontSize: 16
956
+ }}
957
+ />
958
+ )}
959
+ {qtyBy?.weight_unit && (
960
+ <OText
961
+ size={12}
962
+ lineHeight={18}
963
+ style={{ minWidth: 40, textAlign: 'center' }}
964
+ >
965
+ {productCart.quantity * product?.weight}
966
+ </OText>
967
+ )}
968
+ <TouchableOpacity
969
+ onPress={increment}
970
+ disabled={
971
+ maxProductQuantity <= 0 ||
972
+ (productCart?.quantity + productAddedToCartLength) >= maxProductQuantity ||
973
+ ((productCart?.quantity + productAddedToCartLength) >= product?.maximum_per_order && product?.maximum_per_order) ||
974
+ isSoldOut
975
+ }>
976
+ <OIcon
977
+ src={theme.images.general.plus}
978
+ width={20}
979
+ color={
980
+ maxProductQuantity <= 0 ||
981
+ (productCart?.quantity + productAddedToCartLength) >= maxProductQuantity ||
982
+ ((productCart?.quantity + productAddedToCartLength) >= product?.maximum_per_order && product?.maximum_per_order) ||
983
+ isSoldOut
984
+ ? theme.colors.backgroundGray
985
+ : theme.colors.backgroundDark
986
+ }
987
+ />
988
+ </TouchableOpacity>
989
+ </View>
990
+ {isHaveWeight && (
991
+ <WeightUnitSwitch>
973
992
  <TouchableOpacity
974
- onPress={() => handleSwitchQtyUnit('weight_unit')}
993
+ onPress={() => handleSwitchQtyUnit('pieces')}
975
994
  >
976
- <WeightUnitItem active={qtyBy?.weight_unit}>
995
+ <WeightUnitItem active={qtyBy?.pieces}>
977
996
  <OText
978
997
  size={12}
979
998
  lineHeight={18}
980
- color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
999
+ color={qtyBy?.pieces ? theme.colors.primary : theme.colors.textNormal}
981
1000
  >
982
- {product?.weight_unit}
1001
+ {t('PIECES', 'pcs')}
983
1002
  </OText>
984
1003
  </WeightUnitItem>
985
1004
  </TouchableOpacity>
986
- </View>
987
- </WeightUnitSwitch>
988
- )}
989
- </View>
990
- )}
991
- <View
992
- style={{
993
- width: isSoldOut || maxProductQuantity <= 0 ? '60%' : '40%',
994
- }}>
995
- {((productCart &&
996
- auth &&
997
- orderState.options?.address_id) || (isSoldOut || maxProductQuantity <= 0)) && (
998
- <OButton
999
- onClick={() => handleSaveProduct()}
1000
- imgRightSrc=""
1001
- text={`${orderState.loading
1002
- ? t('LOADING', 'Loading')
1003
- : (isSoldOut || maxProductQuantity <= 0)
1004
- ? t('SOLD_OUT', 'Sold out')
1005
- : editMode
1006
- ? t('UPDATE', 'Update')
1007
- : t('ADD', 'Add')
1008
- }`}
1009
- isDisabled={isSoldOut || maxProductQuantity <= 0 || (product?.minimum_per_order && (productCart?.quantity < product?.minimum_per_order)) || (product?.maximum_per_order && (productCart?.quantity > product?.maximum_per_order))}
1010
- textStyle={{
1011
- color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
1012
- fontSize: orderState.loading || editMode ? 10 : 14
1013
- }}
1014
- style={{
1015
- 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,
1016
- 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,
1017
- opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
1018
- borderRadius: 7.6,
1019
- height: 44,
1020
- shadowOpacity: 0,
1021
- borderWidth: 1,
1022
- }}
1023
- />
1024
- )}
1025
- {auth &&
1026
- !orderState.options?.address_id &&
1027
- (orderState.loading ? (
1028
- <OButton
1029
- isDisabled
1030
- text={t('LOADING', 'Loading')}
1031
- imgRightSrc=""
1032
- textStyle={{ fontSize: 10 }}
1033
- />
1034
- ) : (
1035
- <OButton onClick={navigation.navigate('AddressList')} />
1036
- ))}
1037
- {!auth && (
1038
- <OButton
1039
- isDisabled={isSoldOut || maxProductQuantity <= 0}
1040
- onClick={() => handleRedirectLogin()}
1041
- text={
1042
- isSoldOut || maxProductQuantity <= 0
1043
- ? t('SOLD_OUT', 'Sold out')
1044
- : t('LOGIN_SIGNUP', 'Login / Sign Up')
1045
- }
1046
- imgRightSrc=""
1047
- textStyle={{ color: theme.colors.primary, fontSize: 14 }}
1048
- style={{
1049
- height: 44,
1050
- borderColor: theme.colors.primary,
1051
- backgroundColor: theme.colors.white,
1052
- }}
1053
- />
1005
+ <View style={{ alignItems: 'flex-start' }}>
1006
+ <TouchableOpacity
1007
+ onPress={() => handleSwitchQtyUnit('weight_unit')}
1008
+ >
1009
+ <WeightUnitItem active={qtyBy?.weight_unit}>
1010
+ <OText
1011
+ size={12}
1012
+ lineHeight={18}
1013
+ color={qtyBy?.weight_unit ? theme.colors.primary : theme.colors.textNormal}
1014
+ >
1015
+ {product?.weight_unit}
1016
+ </OText>
1017
+ </WeightUnitItem>
1018
+ </TouchableOpacity>
1019
+ </View>
1020
+ </WeightUnitSwitch>
1021
+ )}
1022
+ </>
1054
1023
  )}
1024
+ {!isHaveWeight && <ActionButton />}
1055
1025
  </View>
1026
+ {isHaveWeight && <ActionButton />}
1056
1027
  </ProductActions>
1057
1028
  )}
1058
1029
  </SafeAreaView>
@@ -1063,8 +1034,18 @@ export const ProductOptionsUI = (props: any) => {
1063
1034
  export const ProductForm = (props: any) => {
1064
1035
  const productOptionsProps = {
1065
1036
  ...props,
1066
- UIComponent: ProductOptionsUI,
1067
- };
1037
+ productCart: {
1038
+ ...props.productCart,
1039
+ quantity: props.productCart?.code
1040
+ ? props.productCart?.quantity
1041
+ : props?.product?.minimum_per_order || 1
1042
+ },
1043
+ UIComponent: ProductOptionsUI
1044
+ }
1068
1045
 
1069
- return <ProductOptions {...productOptionsProps} />;
1046
+ return <ProductOptions {...productOptionsProps} />
1070
1047
  };
1048
+
1049
+ ProductForm.defaultProps = {
1050
+ productAddedToCartLength: 0
1051
+ }