ordering-ui-react-native 0.21.26 → 0.21.27-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 (238) hide show
  1. package/package.json +7 -6
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/PaymentOptionsWebView/index.tsx +1 -0
  5. package/src/components/StripeMethodForm/index.tsx +6 -4
  6. package/src/components/VerifyPhone/styles.tsx +1 -2
  7. package/src/types/index.tsx +3 -1
  8. package/src/utils/index.tsx +2 -2
  9. package/themes/business/index.tsx +4 -0
  10. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -2
  11. package/themes/business/src/components/BusinessController/index.tsx +19 -17
  12. package/themes/business/src/components/BusinessProductList/AccordionDropdown.tsx +63 -0
  13. package/themes/business/src/components/BusinessProductList/IterateCategories.tsx +108 -0
  14. package/themes/business/src/components/BusinessProductList/ProductList.tsx +196 -0
  15. package/themes/business/src/components/BusinessProductList/index.tsx +196 -0
  16. package/themes/business/src/components/BusinessProductList/styles.tsx +10 -0
  17. package/themes/business/src/components/Chat/index.tsx +23 -14
  18. package/themes/business/src/components/DriverMap/index.tsx +36 -23
  19. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  20. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  21. package/themes/business/src/components/Home/index.tsx +5 -1
  22. package/themes/business/src/components/LanguageSelector/index.tsx +1 -2
  23. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  24. package/themes/business/src/components/MapView/index.tsx +11 -7
  25. package/themes/business/src/components/MessagesOption/index.tsx +2 -1
  26. package/themes/business/src/components/NewOrderNotification/index.tsx +163 -118
  27. package/themes/business/src/components/OrderDetails/Business.tsx +50 -2
  28. package/themes/business/src/components/OrderDetails/Delivery.tsx +23 -11
  29. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +61 -54
  30. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +58 -24
  31. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +220 -0
  32. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
  33. package/themes/business/src/components/OrderSummary/index.tsx +240 -76
  34. package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
  35. package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
  36. package/themes/business/src/components/OrdersOption/index.tsx +125 -48
  37. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  38. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +36 -38
  39. package/themes/business/src/components/PreviousOrders/OrderList.tsx +18 -13
  40. package/themes/business/src/components/PreviousOrders/index.tsx +80 -66
  41. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  42. package/themes/business/src/components/PrinterSettings/index.tsx +279 -0
  43. package/themes/business/src/components/PrinterSettings/styles.tsx +17 -0
  44. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  45. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  46. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  47. package/themes/business/src/components/Sessions/index.tsx +187 -0
  48. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  49. package/themes/business/src/components/StoresList/index.tsx +5 -3
  50. package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
  51. package/themes/business/src/components/UserProfileForm/index.tsx +105 -47
  52. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  53. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  54. package/themes/business/src/components/shared/OInput.tsx +2 -0
  55. package/themes/business/src/hooks/useLocation.tsx +5 -4
  56. package/themes/business/src/types/index.tsx +15 -2
  57. package/themes/business/src/utils/index.tsx +5 -0
  58. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  59. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  60. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  61. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  62. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -4
  63. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  64. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  65. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  66. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  67. package/themes/original/index.tsx +9 -4
  68. package/themes/original/src/components/AddressDetails/index.tsx +20 -10
  69. package/themes/original/src/components/AddressForm/index.tsx +10 -6
  70. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  71. package/themes/original/src/components/AddressList/styles.tsx +4 -4
  72. package/themes/original/src/components/AnalyticsSegment/index.tsx +6 -6
  73. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  74. package/themes/original/src/components/BusinessBasicInformation/index.tsx +3 -3
  75. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
  76. package/themes/original/src/components/BusinessController/index.tsx +18 -10
  77. package/themes/original/src/components/BusinessController/styles.tsx +8 -7
  78. package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
  79. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -7
  80. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +317 -0
  81. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +96 -0
  82. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  83. package/themes/original/src/components/BusinessListingSearch/index.tsx +47 -358
  84. package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
  85. package/themes/original/src/components/BusinessPreorder/index.tsx +2 -3
  86. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
  87. package/themes/original/src/components/BusinessProductsList/index.tsx +3 -3
  88. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  89. package/themes/original/src/components/BusinessProductsListing/index.tsx +35 -19
  90. package/themes/original/src/components/BusinessProductsListing/styles.tsx +2 -2
  91. package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
  92. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  93. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
  94. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  95. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  96. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  97. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +24 -404
  98. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  99. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  100. package/themes/original/src/components/Cart/index.tsx +32 -9
  101. package/themes/original/src/components/CartContent/index.tsx +96 -58
  102. package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
  103. package/themes/original/src/components/Checkout/index.tsx +173 -66
  104. package/themes/original/src/components/Checkout/styles.tsx +17 -0
  105. package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
  106. package/themes/original/src/components/DatePicker/index.tsx +33 -0
  107. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  108. package/themes/original/src/components/Favorite/index.tsx +4 -9
  109. package/themes/original/src/components/Favorite/styles.tsx +0 -2
  110. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  111. package/themes/original/src/components/GPSButton/index.tsx +1 -1
  112. package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
  113. package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
  114. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  115. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +36 -3
  116. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
  117. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +67 -4
  118. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
  119. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +2 -2
  120. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
  121. package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
  122. package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
  123. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +83 -0
  124. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
  125. package/themes/original/src/components/GoogleMap/index.tsx +6 -5
  126. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
  127. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
  128. package/themes/original/src/components/Home/index.tsx +2 -1
  129. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  130. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  131. package/themes/original/src/components/LoginForm/Otp/index.tsx +4 -16
  132. package/themes/original/src/components/LoginForm/index.tsx +2 -2
  133. package/themes/original/src/components/Messages/index.tsx +2 -1
  134. package/themes/original/src/components/Messages/styles.tsx +1 -1
  135. package/themes/original/src/components/MomentOption/index.tsx +4 -3
  136. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  137. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +1 -0
  138. package/themes/original/src/components/MultiCheckout/index.tsx +208 -21
  139. package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
  140. package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -15
  141. package/themes/original/src/components/MyOrders/index.tsx +24 -29
  142. package/themes/original/src/components/NavBar/index.tsx +3 -1
  143. package/themes/original/src/components/NetworkError/index.tsx +2 -3
  144. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  145. package/themes/original/src/components/Notifications/index.tsx +4 -8
  146. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  147. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +1 -1
  148. package/themes/original/src/components/OrderDetails/index.tsx +706 -667
  149. package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
  150. package/themes/original/src/components/OrderProgress/index.tsx +28 -6
  151. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  152. package/themes/original/src/components/OrderSummary/index.tsx +3 -1
  153. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  154. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  155. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  156. package/themes/original/src/components/OrdersOption/index.tsx +3 -5
  157. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  158. package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
  159. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  160. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  161. package/themes/original/src/components/PaymentOptions/index.tsx +72 -6
  162. package/themes/original/src/components/ProductForm/ActionButton.tsx +120 -0
  163. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  164. package/themes/original/src/components/ProductForm/index.tsx +68 -156
  165. package/themes/original/src/components/ProductItemAccordion/index.tsx +54 -44
  166. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
  167. package/themes/original/src/components/ProductOptionSubOption/index.tsx +105 -91
  168. package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
  169. package/themes/original/src/components/Promotions/index.tsx +4 -4
  170. package/themes/original/src/components/Promotions/styles.tsx +0 -2
  171. package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
  172. package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
  173. package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
  174. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  175. package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
  176. package/themes/original/src/components/SignupForm/index.tsx +60 -58
  177. package/themes/original/src/components/SingleOrderCard/index.tsx +3 -2
  178. package/themes/original/src/components/SingleProductCard/index.tsx +2 -2
  179. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  180. package/themes/original/src/components/StripeCardsList/index.tsx +17 -36
  181. package/themes/original/src/components/StripeElementsForm/index.tsx +74 -59
  182. package/themes/original/src/components/StripeElementsForm/naked.tsx +47 -0
  183. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
  184. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +86 -0
  185. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
  186. package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
  187. package/themes/original/src/components/UserFormDetails/index.tsx +123 -75
  188. package/themes/original/src/components/UserFormDetails/styles.tsx +7 -0
  189. package/themes/original/src/components/UserProfile/index.tsx +3 -2
  190. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  191. package/themes/original/src/components/Wallets/index.tsx +3 -4
  192. package/themes/original/src/components/Wallets/styles.tsx +1 -1
  193. package/themes/original/src/components/WebsocketStatus/index.tsx +172 -0
  194. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  195. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  196. package/themes/original/src/components/shared/OButton.tsx +5 -5
  197. package/themes/original/src/components/shared/OInput.tsx +1 -4
  198. package/themes/original/src/components/shared/OModal.tsx +12 -14
  199. package/themes/original/src/layouts/Container.tsx +5 -3
  200. package/themes/original/src/types/index.tsx +1 -0
  201. package/themes/original/src/utils/index.tsx +125 -1
  202. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  203. package/src/navigators/BottomNavigator.tsx +0 -117
  204. package/src/navigators/CheckoutNavigator.tsx +0 -66
  205. package/src/navigators/HomeNavigator.tsx +0 -202
  206. package/src/navigators/NavigationRef.tsx +0 -7
  207. package/src/navigators/RootNavigator.tsx +0 -269
  208. package/src/pages/Account.tsx +0 -34
  209. package/src/pages/AddressForm.tsx +0 -62
  210. package/src/pages/AddressList.tsx +0 -24
  211. package/src/pages/BusinessProductsList.tsx +0 -81
  212. package/src/pages/BusinessesListing.tsx +0 -43
  213. package/src/pages/CartList.tsx +0 -49
  214. package/src/pages/Checkout.tsx +0 -101
  215. package/src/pages/ForgotPassword.tsx +0 -24
  216. package/src/pages/Help.tsx +0 -23
  217. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  218. package/src/pages/HelpGuide.tsx +0 -23
  219. package/src/pages/HelpOrder.tsx +0 -23
  220. package/src/pages/Home.tsx +0 -36
  221. package/src/pages/IntroductoryTutorial.tsx +0 -170
  222. package/src/pages/Login.tsx +0 -47
  223. package/src/pages/MomentOption.tsx +0 -30
  224. package/src/pages/MultiCheckout.tsx +0 -31
  225. package/src/pages/MultiOrdersDetails.tsx +0 -27
  226. package/src/pages/MyOrders.tsx +0 -40
  227. package/src/pages/NetworkError.tsx +0 -24
  228. package/src/pages/NotFound.tsx +0 -22
  229. package/src/pages/OrderDetails.tsx +0 -25
  230. package/src/pages/ProductDetails.tsx +0 -55
  231. package/src/pages/Profile.tsx +0 -36
  232. package/src/pages/ReviewDriver.tsx +0 -30
  233. package/src/pages/ReviewOrder.tsx +0 -32
  234. package/src/pages/ReviewProducts.tsx +0 -30
  235. package/src/pages/Sessions.tsx +0 -22
  236. package/src/pages/Signup.tsx +0 -53
  237. package/src/pages/SpinnerLoader.tsx +0 -10
  238. package/src/pages/Splash.tsx +0 -21
@@ -0,0 +1,120 @@
1
+ import React from 'react'
2
+ import { useSession, useOrder, useLanguage, useConfig } from 'ordering-components/native'
3
+ import { useTheme } from 'styled-components/native'
4
+ import { TouchableOpacity, View } from 'react-native'
5
+ import { OButton, OText } from '../shared';
6
+ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
7
+
8
+ export const ActionButton = (props : any) => {
9
+ const {
10
+ navigation,
11
+ isHaveWeight,
12
+ isSoldOut,
13
+ maxProductQuantity,
14
+ productCart,
15
+ handleSaveProduct,
16
+ editMode,
17
+ product,
18
+ errors,
19
+ productAddedToCartLength,
20
+ handleRedirectLogin,
21
+ guestCheckoutEnabled,
22
+ orderTypeEnabled,
23
+ handleUpdateGuest,
24
+ actionStatus
25
+ } = props
26
+ const [,t] = useLanguage()
27
+ const [{ auth }] = useSession()
28
+ const [orderState] = useOrder()
29
+ const theme = useTheme()
30
+ const [{ configs }] = useConfig()
31
+ const unaddressedTypes = configs?.unaddressed_order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
32
+ const isAllowUnaddressOrderType = unaddressedTypes.includes(orderState?.options?.type)
33
+
34
+ const saveErrors =
35
+ orderState.loading ||
36
+ maxProductQuantity === 0 ||
37
+ Object.keys(errors)?.length > 0;
38
+
39
+ return (
40
+ <View
41
+ style={{
42
+ width: isHaveWeight ? '100%' : ((isSoldOut || maxProductQuantity <= 0) ? '60%' : '40%'),
43
+ }}>
44
+ {((productCart &&
45
+ auth &&
46
+ (orderState.options?.address_id || isAllowUnaddressOrderType)) || (isSoldOut || maxProductQuantity <= 0)) && (
47
+ <OButton
48
+ onClick={() => handleSaveProduct()}
49
+ imgRightSrc=""
50
+ text={`${orderState.loading
51
+ ? t('LOADING', 'Loading')
52
+ : (isSoldOut || maxProductQuantity <= 0)
53
+ ? t('SOLD_OUT', 'Sold out')
54
+ : editMode
55
+ ? t('UPDATE', 'Update')
56
+ : t('ADD', 'Add')
57
+ }`}
58
+ 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))}
59
+ textStyle={{
60
+ color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
61
+ fontSize: orderState.loading || editMode ? 10 : 14
62
+ }}
63
+ style={{
64
+ 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,
65
+ 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,
66
+ opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
67
+ borderRadius: 7.6,
68
+ height: 44,
69
+ shadowOpacity: 0,
70
+ borderWidth: 1,
71
+ marginTop: isHaveWeight ? 10 : 0
72
+ }}
73
+ />
74
+ )}
75
+ {auth &&
76
+ !orderState.options?.address_id && !isAllowUnaddressOrderType &&
77
+ (orderState.loading ? (
78
+ <OButton
79
+ isDisabled
80
+ text={t('LOADING', 'Loading')}
81
+ imgRightSrc=""
82
+ textStyle={{ fontSize: 10 }}
83
+ />
84
+ ) : (
85
+ <OButton onClick={navigation.navigate('AddressList')} />
86
+ ))}
87
+ {!auth && (
88
+ <OButton
89
+ isDisabled={isSoldOut || maxProductQuantity <= 0}
90
+ onClick={() => handleRedirectLogin()}
91
+ text={
92
+ isSoldOut || maxProductQuantity <= 0
93
+ ? t('SOLD_OUT', 'Sold out')
94
+ : t('LOGIN_SIGNUP', 'Login / Sign Up')
95
+ }
96
+ imgRightSrc=""
97
+ textStyle={{ color: theme.colors.primary, fontSize: 13, textAlign: 'center' }}
98
+ style={{
99
+ height: 42,
100
+ borderColor: theme.colors.primary,
101
+ backgroundColor: theme.colors.white,
102
+ paddingLeft: 0,
103
+ paddingRight: 0
104
+ }}
105
+ />
106
+ )}
107
+ {!auth && guestCheckoutEnabled && orderTypeEnabled && (
108
+ <TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
109
+ {actionStatus?.loading ? (
110
+ <Placeholder Animation={Fade}>
111
+ <PlaceholderLine height={20} />
112
+ </Placeholder>
113
+ ) : (
114
+ <OText color={theme.colors.primary} size={13} style={{ textAlign: 'center' }}>{t('AS_GUEST_USER', 'As guest user')}</OText>
115
+ )}
116
+ </TouchableOpacity>
117
+ )}
118
+ </View>
119
+ )
120
+ }
@@ -0,0 +1,56 @@
1
+ import React from 'react'
2
+ import { TouchableOpacity } from 'react-native';
3
+ import { useTheme } from 'styled-components/native';
4
+ import { OText } from '../shared';
5
+
6
+ export const ExtraOptions = (props : any) => {
7
+ const {
8
+ options,
9
+ setSelectedOpt,
10
+ scrollViewRef,
11
+ optionLayout,
12
+ editionsLayoutY,
13
+ styles,
14
+ selOpt
15
+ } = props
16
+
17
+ const theme = useTheme()
18
+
19
+ return (
20
+ <>
21
+ {options.map(({ id, name, respect_to, suboptions }: any) => (
22
+ <React.Fragment key={`cont_key_${id}`}>
23
+ {respect_to == null && suboptions?.length > 0 && (
24
+ <TouchableOpacity
25
+ key={`eopt_key_${id}`}
26
+ onPress={() => {
27
+ setSelectedOpt(id)
28
+ scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
29
+ y: optionLayout[`id:${id}`]?.y + editionsLayoutY - 50,
30
+ animated: true
31
+ })
32
+ }}
33
+ style={[
34
+ styles.extraItem,
35
+ {
36
+ borderBottomColor:
37
+ selOpt == id ? theme.colors.textNormal : theme.colors.backgroundPage,
38
+ },
39
+ ]}>
40
+ <OText
41
+ color={
42
+ selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
43
+ }
44
+ size={12}
45
+ weight={selOpt == id ? '600' : 'normal'}
46
+ style={{ maxWidth: 150 }}
47
+ numberOfLines={1}>
48
+ {name}
49
+ </OText>
50
+ </TouchableOpacity>
51
+ )}
52
+ </React.Fragment>
53
+ ))}
54
+ </>
55
+ )
56
+ }
@@ -56,6 +56,10 @@ import { NotFoundSource } from '../NotFoundSource';
56
56
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
57
57
  import NavBar from '../NavBar';
58
58
  import { orderTypeList } from '../../utils';
59
+ import { ActionButton } from './ActionButton'
60
+ import { ExtraOptions } from './ExtraOptions'
61
+ import { IOScrollView } from 'react-native-intersection-observer';
62
+
59
63
  const windowWidth = Dimensions.get('window').width;
60
64
 
61
65
  export const ProductOptionsUI = (props: any) => {
@@ -79,11 +83,10 @@ export const ProductOptionsUI = (props: any) => {
79
83
  actionStatus,
80
84
  handleCreateGuestUser
81
85
  } = props;
82
-
83
86
  const theme = useTheme();
84
87
  const [, { showToast }] = useToast()
85
88
  const [events] = useEvent()
86
-
89
+ const commentRef = useRef()
87
90
  const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
88
91
 
89
92
  const styles = StyleSheet.create({
@@ -138,8 +141,7 @@ export const ProductOptionsUI = (props: any) => {
138
141
  slide1: {
139
142
  flex: 1,
140
143
  alignItems: 'center',
141
- width: '100%',
142
- marginLeft: 32
144
+ width: '100%'
143
145
  },
144
146
  mainSwiper: {
145
147
  height: 258,
@@ -178,7 +180,7 @@ export const ProductOptionsUI = (props: any) => {
178
180
  marginTop: 10
179
181
  },
180
182
  wrapperNavbar: {
181
- paddingHorizontal: 30,
183
+ paddingHorizontal: 20,
182
184
  paddingTop: 0,
183
185
  }
184
186
  });
@@ -209,7 +211,7 @@ export const ProductOptionsUI = (props: any) => {
209
211
  const [editionsLayoutY, setEditionsLayoutY] = useState(null)
210
212
  const [viewedProduct, setViewedProduct] = useState<any>(null)
211
213
  const [showTitle, setShowTitle] = useState(false)
212
-
214
+ const productOptionsMounted = useRef(false)
213
215
  const guestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
214
216
  const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
215
217
 
@@ -284,14 +286,14 @@ export const ProductOptionsUI = (props: any) => {
284
286
  setQtyBy({ [val]: true, [!val]: false })
285
287
  }
286
288
 
287
- const onStateChange = useCallback((state) => {
289
+ const onStateChange = useCallback((state : string) => {
288
290
  if (state === "ended") {
289
291
  setPlaying(false);
290
292
  }
291
293
  }, []);
292
294
 
293
295
  const togglePlaying = useCallback(() => {
294
- setPlaying((prev) => !prev);
296
+ setPlaying((prev : any) => !prev);
295
297
  }, []);
296
298
 
297
299
  const onChangeProductCartQuantity = (quantity: number) => {
@@ -322,57 +324,20 @@ export const ProductOptionsUI = (props: any) => {
322
324
  if (guestToken) handleCreateGuestUser({ guest_token: guestToken })
323
325
  }
324
326
 
325
- const handleOnLayout = (event: any, optionId: any) => {
326
- const _optionLayout = { ...optionLayout }
327
+ let _optionLayout: any = {}
328
+
329
+ const handleOnLayout = (event: any, optionId: any, lastMounts: boolean) => {
330
+ if (suboptionsLength >= 200) {
331
+ return
332
+ }
333
+ _optionLayout = { ..._optionLayout }
327
334
  const optionKey = 'id:' + optionId
328
335
  _optionLayout[optionKey] = { y: event.nativeEvent.layout?.y }
329
- setOptionLayout(_optionLayout)
336
+ if (lastMounts) {
337
+ setOptionLayout(_optionLayout)
338
+ }
330
339
  }
331
340
 
332
- const saveErrors =
333
- orderState.loading ||
334
- maxProductQuantity === 0 ||
335
- Object.keys(errors)?.length > 0;
336
-
337
-
338
- const ExtraOptions = ({ eID, options }: any) => (
339
- <>
340
- {options.map(({ id, name, respect_to, suboptions }: any) => (
341
- <React.Fragment key={`cont_key_${id}`}>
342
- {respect_to == null && suboptions?.length > 0 && (
343
- <TouchableOpacity
344
- key={`eopt_key_${id}`}
345
- onPress={() => {
346
- setSelectedOpt(id)
347
- scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
348
- y: optionLayout[`id:${id}`]?.y + editionsLayoutY - 50,
349
- animated: true
350
- })
351
- }}
352
- style={[
353
- styles.extraItem,
354
- {
355
- borderBottomColor:
356
- selOpt == id ? theme.colors.textNormal : theme.colors.backgroundPage,
357
- },
358
- ]}>
359
- <OText
360
- color={
361
- selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
362
- }
363
- size={12}
364
- weight={selOpt == id ? '600' : 'normal'}
365
- style={{ maxWidth: 150 }}
366
- numberOfLines={1}>
367
- {name}
368
- </OText>
369
- </TouchableOpacity>
370
- )}
371
- </React.Fragment>
372
- ))}
373
- </>
374
- );
375
-
376
341
  const handleScroll = ({ nativeEvent: { contentOffset } }: any) => {
377
342
  setShowTitle(contentOffset.y > 30)
378
343
  }
@@ -432,90 +397,6 @@ export const ProductOptionsUI = (props: any) => {
432
397
  }
433
398
  }, [product])
434
399
 
435
- const ActionButton = () => {
436
- return (
437
- <View
438
- style={{
439
- width: isHaveWeight ? '100%' : ((isSoldOut || maxProductQuantity <= 0) ? '60%' : '40%'),
440
- }}>
441
- {((productCart &&
442
- auth &&
443
- orderState.options?.address_id) || (isSoldOut || maxProductQuantity <= 0)) && (
444
- <OButton
445
- onClick={() => handleSaveProduct()}
446
- imgRightSrc=""
447
- text={`${orderState.loading
448
- ? t('LOADING', 'Loading')
449
- : (isSoldOut || maxProductQuantity <= 0)
450
- ? t('SOLD_OUT', 'Sold out')
451
- : editMode
452
- ? t('UPDATE', 'Update')
453
- : t('ADD', 'Add')
454
- }`}
455
- 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))}
456
- textStyle={{
457
- color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
458
- fontSize: orderState.loading || editMode ? 10 : 14
459
- }}
460
- style={{
461
- 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,
462
- 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,
463
- opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
464
- borderRadius: 7.6,
465
- height: 44,
466
- shadowOpacity: 0,
467
- borderWidth: 1,
468
- marginTop: isHaveWeight ? 10 : 0
469
- }}
470
- />
471
- )}
472
- {auth &&
473
- !orderState.options?.address_id &&
474
- (orderState.loading ? (
475
- <OButton
476
- isDisabled
477
- text={t('LOADING', 'Loading')}
478
- imgRightSrc=""
479
- textStyle={{ fontSize: 10 }}
480
- />
481
- ) : (
482
- <OButton onClick={navigation.navigate('AddressList')} />
483
- ))}
484
- {!auth && (
485
- <OButton
486
- isDisabled={isSoldOut || maxProductQuantity <= 0}
487
- onClick={() => handleRedirectLogin()}
488
- text={
489
- isSoldOut || maxProductQuantity <= 0
490
- ? t('SOLD_OUT', 'Sold out')
491
- : t('LOGIN_SIGNUP', 'Login / Sign Up')
492
- }
493
- imgRightSrc=""
494
- textStyle={{ color: theme.colors.primary, fontSize: 13, textAlign: 'center' }}
495
- style={{
496
- height: 42,
497
- borderColor: theme.colors.primary,
498
- backgroundColor: theme.colors.white,
499
- paddingLeft: 0,
500
- paddingRight: 0
501
- }}
502
- />
503
- )}
504
- {!auth && guestCheckoutEnabled && orderTypeEnabled && (
505
- <TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
506
- {actionStatus?.loading ? (
507
- <Placeholder Animation={Fade}>
508
- <PlaceholderLine width={60} height={20} />
509
- </Placeholder>
510
- ) : (
511
- <OText color={theme.colors.primary} size={13} style={{ textAlign: 'center' }}>{t('WITH_GUEST_USER', 'With Guest user')}</OText>
512
- )}
513
- </TouchableOpacity>
514
- )}
515
- </View>
516
- )
517
- }
518
-
519
400
  useEffect(() => {
520
401
  const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
521
402
  scrollViewRef.current.scrollToEnd({ animated: true })
@@ -531,6 +412,35 @@ export const ProductOptionsUI = (props: any) => {
531
412
  events.emit('product_viewed', product)
532
413
  }, [product?.id, viewedProduct])
533
414
 
415
+ const actionButtonProps = {
416
+ navigation,
417
+ isHaveWeight,
418
+ isSoldOut,
419
+ maxProductQuantity,
420
+ productCart,
421
+ handleSaveProduct,
422
+ editMode,
423
+ product,
424
+ errors,
425
+ productAddedToCartLength,
426
+ handleRedirectLogin,
427
+ guestCheckoutEnabled,
428
+ orderTypeEnabled,
429
+ handleUpdateGuest,
430
+ actionStatus
431
+ }
432
+
433
+ const extraOptionsProps = {
434
+ setSelectedOpt,
435
+ scrollViewRef,
436
+ optionLayout,
437
+ editionsLayoutY,
438
+ styles,
439
+ selOpt
440
+ }
441
+
442
+ const suboptionsLength = product?.extras?.reduce((acc : number, extras : any) => acc + extras?.options?.reduce((accSuboptions : number, options: any) => accSuboptions + options?.suboptions?.length, 0), 0)
443
+
534
444
  return (
535
445
  <SafeAreaView style={{ flex: 1 }}>
536
446
  <View style={styles.wrapperNavbar}>
@@ -557,7 +467,7 @@ export const ProductOptionsUI = (props: any) => {
557
467
  </TopHeader>
558
468
  </View>
559
469
  {!error && (
560
- <ScrollView
470
+ <IOScrollView
561
471
  ref={scrollViewRef}
562
472
  contentContainerStyle={{ paddingBottom: 80 }}
563
473
  stickyHeaderIndices={[2]}
@@ -583,7 +493,7 @@ export const ProductOptionsUI = (props: any) => {
583
493
  showsButtons={true}
584
494
  style={styles.mainSwiper}
585
495
  showsPagination={false}
586
- onIndexChanged={(index) => handleChangeMainIndex(index)}
496
+ onIndexChanged={(index : any) => handleChangeMainIndex(index)}
587
497
  prevButton={
588
498
  <View style={styles.swiperButton}>
589
499
  <IconAntDesign
@@ -605,7 +515,7 @@ export const ProductOptionsUI = (props: any) => {
605
515
  </View>
606
516
  }
607
517
  >
608
- {gallery && gallery?.length > 0 && gallery.map((img, i) => (
518
+ {gallery && gallery?.length > 0 && gallery.map((img : any, i: number) => (
609
519
  <View
610
520
  style={styles.slide1}
611
521
  key={i}
@@ -636,11 +546,11 @@ export const ProductOptionsUI = (props: any) => {
636
546
  <ScrollView
637
547
  horizontal
638
548
  contentContainerStyle={{
639
- paddingHorizontal: 30,
549
+ paddingHorizontal: 20,
640
550
  paddingVertical: 15
641
551
  }}
642
552
  >
643
- {gallery?.length > 1 && gallery.map((img, index) => (
553
+ {gallery?.length > 1 && gallery.map((img: any, index: number) => (
644
554
  <TouchableOpacity
645
555
  key={index}
646
556
  onPress={() => handleClickThumb(index)}
@@ -689,7 +599,7 @@ export const ProductOptionsUI = (props: any) => {
689
599
  )}
690
600
  </WrapHeader>
691
601
  <ProductSummary
692
- ph={isChewLayout ? 20 : 30}
602
+ ph={20}
693
603
  onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}
694
604
  >
695
605
  <ProductTitle>
@@ -822,8 +732,8 @@ export const ProductOptionsUI = (props: any) => {
822
732
  </OText>
823
733
  </TouchableOpacity>
824
734
  )}
825
- {product?.extras?.map((extra: any) =>
826
- <ExtraOptions key={extra.id} options={extra.options} />
735
+ {suboptionsLength < 200 && product?.extras?.map((extra: any) =>
736
+ <ExtraOptions key={extra.id} options={extra.options} {...extraOptionsProps} />
827
737
  )}
828
738
  </ExtraOptionWrap>
829
739
  )}
@@ -867,14 +777,14 @@ export const ProductOptionsUI = (props: any) => {
867
777
  </>
868
778
  ) : (
869
779
  <ProductEditions
870
- style={{ paddingHorizontal: isChewLayout ? 20 : 30 }}
780
+ style={{ paddingHorizontal: 20 }}
871
781
  onLayout={(event: any) => {
872
782
  setEditionsLayoutY(event.nativeEvent.layout?.y)
873
783
  }}
874
784
  >
875
785
  <>
876
786
  {product?.ingredients?.length > 0 && (
877
- <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0)}>
787
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0, true)}>
878
788
  <SectionTitle>
879
789
  <OText size={16}>
880
790
  {t('INGREDIENTS', 'Ingredients')}
@@ -896,13 +806,13 @@ export const ProductOptionsUI = (props: any) => {
896
806
  </View>
897
807
  )}
898
808
  {product?.extras?.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
899
- extra.options?.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
809
+ extra.options?.sort((a: any, b: any) => a.rank - b.rank).map((option: any, i: number) => {
900
810
  const currentState =
901
811
  productCart.options[`id:${option.id}`] || {};
902
812
  return (
903
813
  <React.Fragment key={`popt_${option.id}`}>
904
814
  {showOption(option) && (
905
- <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, option?.id)}>
815
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, option?.id, extra.options?.length <= i + 2)}>
906
816
  <ProductOption
907
817
  option={option}
908
818
  currentState={currentState}
@@ -929,7 +839,7 @@ export const ProductOptionsUI = (props: any) => {
929
839
  balance={balance}
930
840
  option={option}
931
841
  suboption={suboption}
932
- image={option.image}
842
+ image={suboption.image}
933
843
  state={currentState}
934
844
  disabled={
935
845
  isSoldOut ||
@@ -937,6 +847,7 @@ export const ProductOptionsUI = (props: any) => {
937
847
  }
938
848
  setIsScrollAvailable={setIsScrollAvailable}
939
849
  error={errors[`id:${option.id}`]}
850
+ enableIntersection={suboptionsLength >= 200}
940
851
  />
941
852
  );
942
853
  },
@@ -954,7 +865,7 @@ export const ProductOptionsUI = (props: any) => {
954
865
  <ProductComment>
955
866
  <SectionTitle>
956
867
  <OText size={16} weight={'600'} lineHeight={24}>
957
- {t('SPECIAL_COMMENT', 'Special comment')}
868
+ {t('COMMENTS', 'Special comment')}
958
869
  </OText>
959
870
  </SectionTitle>
960
871
  <OInput
@@ -968,6 +879,7 @@ export const ProductOptionsUI = (props: any) => {
968
879
  !(productCart && !isSoldOut && maxProductQuantity)
969
880
  }
970
881
  style={styles.comment}
882
+ forwardRef={commentRef}
971
883
  />
972
884
  </ProductComment>
973
885
  )}
@@ -976,7 +888,7 @@ export const ProductOptionsUI = (props: any) => {
976
888
  {!!error && error?.length > 0 && (
977
889
  <NotFoundSource content={error[0]?.message || error[0]} />
978
890
  )}
979
- </ScrollView>
891
+ </IOScrollView>
980
892
  )}
981
893
  {!loading && !error && product && (
982
894
  <ProductActions ios={Platform?.OS === 'ios'} isColumn={isHaveWeight}>
@@ -1087,9 +999,9 @@ export const ProductOptionsUI = (props: any) => {
1087
999
  )}
1088
1000
  </>
1089
1001
  )}
1090
- {!isHaveWeight && <ActionButton />}
1002
+ {!isHaveWeight && <ActionButton {...actionButtonProps} />}
1091
1003
  </View>
1092
- {isHaveWeight && <ActionButton />}
1004
+ {isHaveWeight && <ActionButton {...actionButtonProps} />}
1093
1005
  </ProductActions>
1094
1006
  )}
1095
1007
  </SafeAreaView>