ordering-ui-react-native 0.16.54 → 0.16.55-release

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