ordering-ui-react-native 0.21.21 → 0.21.22-release

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/package.json +7 -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 +4 -4
  6. package/src/components/VerifyPhone/styles.tsx +1 -2
  7. package/src/types/index.tsx +2 -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 +4 -3
  19. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  20. package/themes/business/src/components/Home/index.tsx +5 -1
  21. package/themes/business/src/components/LanguageSelector/index.tsx +4 -2
  22. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  23. package/themes/business/src/components/MapView/index.tsx +11 -7
  24. package/themes/business/src/components/MessagesOption/index.tsx +2 -1
  25. package/themes/business/src/components/NewOrderNotification/index.tsx +163 -113
  26. package/themes/business/src/components/OrderDetails/Business.tsx +50 -2
  27. package/themes/business/src/components/OrderDetails/Delivery.tsx +23 -11
  28. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +60 -53
  29. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +54 -23
  30. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +220 -0
  31. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
  32. package/themes/business/src/components/OrderSummary/index.tsx +240 -76
  33. package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
  34. package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
  35. package/themes/business/src/components/OrdersOption/index.tsx +125 -48
  36. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  37. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +33 -36
  38. package/themes/business/src/components/PreviousOrders/OrderList.tsx +18 -13
  39. package/themes/business/src/components/PreviousOrders/index.tsx +80 -66
  40. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  41. package/themes/business/src/components/PrinterSettings/index.tsx +279 -0
  42. package/themes/business/src/components/PrinterSettings/styles.tsx +17 -0
  43. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  44. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  45. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  46. package/themes/business/src/components/Sessions/index.tsx +187 -0
  47. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  48. package/themes/business/src/components/StoresList/index.tsx +5 -3
  49. package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
  50. package/themes/business/src/components/UserProfileForm/index.tsx +98 -44
  51. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  52. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  53. package/themes/business/src/components/shared/OInput.tsx +2 -0
  54. package/themes/business/src/hooks/useLocation.tsx +5 -4
  55. package/themes/business/src/types/index.tsx +15 -2
  56. package/themes/business/src/utils/index.tsx +5 -0
  57. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  58. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  59. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  60. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  61. package/themes/kiosk/src/components/LoginForm/index.tsx +7 -4
  62. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  63. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  64. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  65. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  66. package/themes/original/index.tsx +9 -4
  67. package/themes/original/src/components/AddressDetails/index.tsx +20 -10
  68. package/themes/original/src/components/AddressForm/index.tsx +10 -6
  69. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  70. package/themes/original/src/components/AddressList/index.tsx +4 -7
  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 +4 -4
  75. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
  76. package/themes/original/src/components/BusinessController/index.tsx +20 -12
  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 +56 -361
  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 +51 -20
  90. package/themes/original/src/components/BusinessProductsListing/styles.tsx +3 -4
  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 +190 -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/Messages/index.tsx +9 -4
  133. package/themes/original/src/components/Messages/styles.tsx +1 -1
  134. package/themes/original/src/components/MomentOption/index.tsx +4 -3
  135. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  136. package/themes/original/src/components/MultiCheckout/index.tsx +208 -21
  137. package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
  138. package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -15
  139. package/themes/original/src/components/MyOrders/index.tsx +24 -29
  140. package/themes/original/src/components/NavBar/index.tsx +3 -1
  141. package/themes/original/src/components/NetworkError/index.tsx +2 -3
  142. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  143. package/themes/original/src/components/Notifications/index.tsx +4 -8
  144. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  145. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +1 -1
  146. package/themes/original/src/components/OrderDetails/index.tsx +716 -668
  147. package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
  148. package/themes/original/src/components/OrderProgress/index.tsx +28 -6
  149. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  150. package/themes/original/src/components/OrderSummary/index.tsx +3 -1
  151. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  152. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  153. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  154. package/themes/original/src/components/OrdersOption/index.tsx +3 -5
  155. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  156. package/themes/original/src/components/PageBanner/index.tsx +3 -0
  157. package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
  158. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  159. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  160. package/themes/original/src/components/PaymentOptions/index.tsx +72 -6
  161. package/themes/original/src/components/ProductForm/ActionButton.tsx +120 -0
  162. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  163. package/themes/original/src/components/ProductForm/index.tsx +74 -165
  164. package/themes/original/src/components/ProductItemAccordion/index.tsx +54 -44
  165. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
  166. package/themes/original/src/components/ProductOptionSubOption/index.tsx +123 -82
  167. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +6 -1
  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 +72 -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 +125 -77
  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/UserProfileForm/index.tsx +30 -36
  191. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  192. package/themes/original/src/components/Wallets/index.tsx +8 -9
  193. package/themes/original/src/components/Wallets/styles.tsx +1 -1
  194. package/themes/original/src/components/WebsocketStatus/index.tsx +172 -0
  195. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  196. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  197. package/themes/original/src/components/shared/OButton.tsx +5 -5
  198. package/themes/original/src/components/shared/OInput.tsx +1 -4
  199. package/themes/original/src/components/shared/OModal.tsx +12 -14
  200. package/themes/original/src/layouts/Container.tsx +5 -3
  201. package/themes/original/src/types/index.tsx +1 -0
  202. package/themes/original/src/utils/index.tsx +125 -1
  203. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  204. package/src/navigators/BottomNavigator.tsx +0 -117
  205. package/src/navigators/CheckoutNavigator.tsx +0 -66
  206. package/src/navigators/HomeNavigator.tsx +0 -202
  207. package/src/navigators/NavigationRef.tsx +0 -7
  208. package/src/navigators/RootNavigator.tsx +0 -269
  209. package/src/pages/Account.tsx +0 -34
  210. package/src/pages/AddressForm.tsx +0 -62
  211. package/src/pages/AddressList.tsx +0 -24
  212. package/src/pages/BusinessProductsList.tsx +0 -81
  213. package/src/pages/BusinessesListing.tsx +0 -43
  214. package/src/pages/CartList.tsx +0 -49
  215. package/src/pages/Checkout.tsx +0 -101
  216. package/src/pages/ForgotPassword.tsx +0 -24
  217. package/src/pages/Help.tsx +0 -23
  218. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  219. package/src/pages/HelpGuide.tsx +0 -23
  220. package/src/pages/HelpOrder.tsx +0 -23
  221. package/src/pages/Home.tsx +0 -36
  222. package/src/pages/IntroductoryTutorial.tsx +0 -170
  223. package/src/pages/Login.tsx +0 -47
  224. package/src/pages/MomentOption.tsx +0 -30
  225. package/src/pages/MultiCheckout.tsx +0 -31
  226. package/src/pages/MultiOrdersDetails.tsx +0 -27
  227. package/src/pages/MyOrders.tsx +0 -40
  228. package/src/pages/NetworkError.tsx +0 -24
  229. package/src/pages/NotFound.tsx +0 -22
  230. package/src/pages/OrderDetails.tsx +0 -25
  231. package/src/pages/ProductDetails.tsx +0 -55
  232. package/src/pages/Profile.tsx +0 -36
  233. package/src/pages/ReviewDriver.tsx +0 -30
  234. package/src/pages/ReviewOrder.tsx +0 -32
  235. package/src/pages/ReviewProducts.tsx +0 -30
  236. package/src/pages/Sessions.tsx +0 -22
  237. package/src/pages/Signup.tsx +0 -53
  238. package/src/pages/SpinnerLoader.tsx +0 -10
  239. 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({
@@ -137,7 +140,8 @@ export const ProductOptionsUI = (props: any) => {
137
140
  },
138
141
  slide1: {
139
142
  flex: 1,
140
- alignItems: 'center'
143
+ alignItems: 'center',
144
+ width: '100%'
141
145
  },
142
146
  mainSwiper: {
143
147
  height: 258,
@@ -176,7 +180,7 @@ export const ProductOptionsUI = (props: any) => {
176
180
  marginTop: 10
177
181
  },
178
182
  wrapperNavbar: {
179
- paddingHorizontal: 30,
183
+ paddingHorizontal: 20,
180
184
  paddingTop: 0,
181
185
  }
182
186
  });
@@ -207,7 +211,7 @@ export const ProductOptionsUI = (props: any) => {
207
211
  const [editionsLayoutY, setEditionsLayoutY] = useState(null)
208
212
  const [viewedProduct, setViewedProduct] = useState<any>(null)
209
213
  const [showTitle, setShowTitle] = useState(false)
210
-
214
+ const productOptionsMounted = useRef(false)
211
215
  const guestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
212
216
  const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
213
217
 
@@ -282,14 +286,14 @@ export const ProductOptionsUI = (props: any) => {
282
286
  setQtyBy({ [val]: true, [!val]: false })
283
287
  }
284
288
 
285
- const onStateChange = useCallback((state) => {
289
+ const onStateChange = useCallback((state : string) => {
286
290
  if (state === "ended") {
287
291
  setPlaying(false);
288
292
  }
289
293
  }, []);
290
294
 
291
295
  const togglePlaying = useCallback(() => {
292
- setPlaying((prev) => !prev);
296
+ setPlaying((prev : any) => !prev);
293
297
  }, []);
294
298
 
295
299
  const onChangeProductCartQuantity = (quantity: number) => {
@@ -320,63 +324,22 @@ export const ProductOptionsUI = (props: any) => {
320
324
  if (guestToken) handleCreateGuestUser({ guest_token: guestToken })
321
325
  }
322
326
 
323
- const handleOnLayout = (event: any, optionId: any) => {
324
- 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 }
325
334
  const optionKey = 'id:' + optionId
326
335
  _optionLayout[optionKey] = { y: event.nativeEvent.layout?.y }
327
- setOptionLayout(_optionLayout)
336
+ if (lastMounts) {
337
+ setOptionLayout(_optionLayout)
338
+ }
328
339
  }
329
340
 
330
- const saveErrors =
331
- orderState.loading ||
332
- maxProductQuantity === 0 ||
333
- Object.keys(errors)?.length > 0;
334
-
335
-
336
- const ExtraOptions = ({ eID, options }: any) => (
337
- <>
338
- {options.map(({ id, name, respect_to, suboptions }: any) => (
339
- <React.Fragment key={`cont_key_${id}`}>
340
- {respect_to == null && suboptions?.length > 0 && (
341
- <TouchableOpacity
342
- key={`eopt_key_${id}`}
343
- onPress={() => {
344
- setSelectedOpt(id)
345
- scrollViewRef?.current?.scrollTo && scrollViewRef.current.scrollTo({
346
- y: optionLayout[`id:${id}`]?.y + editionsLayoutY - 50,
347
- animated: true
348
- })
349
- }}
350
- style={[
351
- styles.extraItem,
352
- {
353
- borderBottomColor:
354
- selOpt == id ? theme.colors.textNormal : theme.colors.backgroundPage,
355
- },
356
- ]}>
357
- <OText
358
- color={
359
- selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
360
- }
361
- size={12}
362
- weight={selOpt == id ? '600' : 'normal'}
363
- style={{ maxWidth: 150 }}
364
- numberOfLines={1}>
365
- {name}
366
- </OText>
367
- </TouchableOpacity>
368
- )}
369
- </React.Fragment>
370
- ))}
371
- </>
372
- );
373
-
374
- const handleScroll = ({ nativeEvent: { contentOffset, layoutMeasurement } }: any) => {
341
+ const handleScroll = ({ nativeEvent: { contentOffset } }: any) => {
375
342
  setShowTitle(contentOffset.y > 30)
376
- const _topOption = Object.keys(optionLayout).find(((option: any) => Math.abs(contentOffset?.y - layoutMeasurement?.height - optionLayout[option]?.y) < 20))
377
- if (_topOption) {
378
- const _topOptionId = Number(_topOption.replace('id:', ''))
379
- }
380
343
  }
381
344
 
382
345
  const handleGoBack = navigation?.canGoBack()
@@ -434,90 +397,6 @@ export const ProductOptionsUI = (props: any) => {
434
397
  }
435
398
  }, [product])
436
399
 
437
- const ActionButton = () => {
438
- return (
439
- <View
440
- style={{
441
- width: isHaveWeight ? '100%' : ((isSoldOut || maxProductQuantity <= 0) ? '60%' : '40%'),
442
- }}>
443
- {((productCart &&
444
- auth &&
445
- orderState.options?.address_id) || (isSoldOut || maxProductQuantity <= 0)) && (
446
- <OButton
447
- onClick={() => handleSaveProduct()}
448
- imgRightSrc=""
449
- text={`${orderState.loading
450
- ? t('LOADING', 'Loading')
451
- : (isSoldOut || maxProductQuantity <= 0)
452
- ? t('SOLD_OUT', 'Sold out')
453
- : editMode
454
- ? t('UPDATE', 'Update')
455
- : t('ADD', 'Add')
456
- }`}
457
- 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))}
458
- textStyle={{
459
- color: saveErrors || isSoldOut || maxProductQuantity <= 0 ? theme.colors.primary : theme.colors.white,
460
- fontSize: orderState.loading || editMode ? 10 : 14
461
- }}
462
- style={{
463
- 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,
464
- 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,
465
- opacity: saveErrors || isSoldOut || maxProductQuantity <= 0 ? 0.3 : 1,
466
- borderRadius: 7.6,
467
- height: 44,
468
- shadowOpacity: 0,
469
- borderWidth: 1,
470
- marginTop: isHaveWeight ? 10 : 0
471
- }}
472
- />
473
- )}
474
- {auth &&
475
- !orderState.options?.address_id &&
476
- (orderState.loading ? (
477
- <OButton
478
- isDisabled
479
- text={t('LOADING', 'Loading')}
480
- imgRightSrc=""
481
- textStyle={{ fontSize: 10 }}
482
- />
483
- ) : (
484
- <OButton onClick={navigation.navigate('AddressList')} />
485
- ))}
486
- {!auth && (
487
- <OButton
488
- isDisabled={isSoldOut || maxProductQuantity <= 0}
489
- onClick={() => handleRedirectLogin()}
490
- text={
491
- isSoldOut || maxProductQuantity <= 0
492
- ? t('SOLD_OUT', 'Sold out')
493
- : t('LOGIN_SIGNUP', 'Login / Sign Up')
494
- }
495
- imgRightSrc=""
496
- textStyle={{ color: theme.colors.primary, fontSize: 13, textAlign: 'center' }}
497
- style={{
498
- height: 42,
499
- borderColor: theme.colors.primary,
500
- backgroundColor: theme.colors.white,
501
- paddingLeft: 0,
502
- paddingRight: 0
503
- }}
504
- />
505
- )}
506
- {!auth && guestCheckoutEnabled && orderTypeEnabled && (
507
- <TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
508
- {actionStatus?.loading ? (
509
- <Placeholder Animation={Fade}>
510
- <PlaceholderLine width={60} height={20} />
511
- </Placeholder>
512
- ) : (
513
- <OText color={theme.colors.primary} size={13} style={{ textAlign: 'center' }}>{t('WITH_GUEST_USER', 'With Guest user')}</OText>
514
- )}
515
- </TouchableOpacity>
516
- )}
517
- </View>
518
- )
519
- }
520
-
521
400
  useEffect(() => {
522
401
  const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
523
402
  scrollViewRef.current.scrollToEnd({ animated: true })
@@ -533,6 +412,35 @@ export const ProductOptionsUI = (props: any) => {
533
412
  events.emit('product_viewed', product)
534
413
  }, [product?.id, viewedProduct])
535
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
+
536
444
  return (
537
445
  <SafeAreaView style={{ flex: 1 }}>
538
446
  <View style={styles.wrapperNavbar}>
@@ -559,10 +467,11 @@ export const ProductOptionsUI = (props: any) => {
559
467
  </TopHeader>
560
468
  </View>
561
469
  {!error && (
562
- <ScrollView
470
+ <IOScrollView
563
471
  ref={scrollViewRef}
564
472
  contentContainerStyle={{ paddingBottom: 80 }}
565
473
  stickyHeaderIndices={[2]}
474
+ scrollEventThrottle={100}
566
475
  onScroll={handleScroll}
567
476
  >
568
477
  <WrapHeader onLayout={(event: any) => setHeaderRefHeight(event.nativeEvent.layout?.height)}>
@@ -584,7 +493,7 @@ export const ProductOptionsUI = (props: any) => {
584
493
  showsButtons={true}
585
494
  style={styles.mainSwiper}
586
495
  showsPagination={false}
587
- onIndexChanged={(index) => handleChangeMainIndex(index)}
496
+ onIndexChanged={(index : any) => handleChangeMainIndex(index)}
588
497
  prevButton={
589
498
  <View style={styles.swiperButton}>
590
499
  <IconAntDesign
@@ -606,7 +515,7 @@ export const ProductOptionsUI = (props: any) => {
606
515
  </View>
607
516
  }
608
517
  >
609
- {gallery && gallery?.length > 0 && gallery.map((img, i) => (
518
+ {gallery && gallery?.length > 0 && gallery.map((img : any, i: number) => (
610
519
  <View
611
520
  style={styles.slide1}
612
521
  key={i}
@@ -637,11 +546,11 @@ export const ProductOptionsUI = (props: any) => {
637
546
  <ScrollView
638
547
  horizontal
639
548
  contentContainerStyle={{
640
- paddingHorizontal: 30,
549
+ paddingHorizontal: 20,
641
550
  paddingVertical: 15
642
551
  }}
643
552
  >
644
- {gallery?.length > 1 && gallery.map((img, index) => (
553
+ {gallery?.length > 1 && gallery.map((img: any, index: number) => (
645
554
  <TouchableOpacity
646
555
  key={index}
647
556
  onPress={() => handleClickThumb(index)}
@@ -690,7 +599,7 @@ export const ProductOptionsUI = (props: any) => {
690
599
  )}
691
600
  </WrapHeader>
692
601
  <ProductSummary
693
- ph={isChewLayout ? 20 : 30}
602
+ ph={20}
694
603
  onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}
695
604
  >
696
605
  <ProductTitle>
@@ -760,6 +669,7 @@ export const ProductOptionsUI = (props: any) => {
760
669
  </ProductDescription>
761
670
  <ScrollView
762
671
  horizontal
672
+ scrollEventThrottle={100}
763
673
  showsHorizontalScrollIndicator={false}
764
674
  contentContainerStyle={{ paddingBottom: 30 }}
765
675
  >
@@ -787,6 +697,7 @@ export const ProductOptionsUI = (props: any) => {
787
697
  {(!loading && product) && (
788
698
  <ExtraOptionWrap
789
699
  horizontal
700
+ scrollEventThrottle={100}
790
701
  showsHorizontalScrollIndicator={false}
791
702
  style={{
792
703
  marginBottom: 20,
@@ -821,8 +732,8 @@ export const ProductOptionsUI = (props: any) => {
821
732
  </OText>
822
733
  </TouchableOpacity>
823
734
  )}
824
- {product?.extras?.map((extra: any) =>
825
- <ExtraOptions key={extra.id} options={extra.options} />
735
+ {suboptionsLength < 200 && product?.extras?.map((extra: any) =>
736
+ <ExtraOptions key={extra.id} options={extra.options} {...extraOptionsProps} />
826
737
  )}
827
738
  </ExtraOptionWrap>
828
739
  )}
@@ -866,14 +777,14 @@ export const ProductOptionsUI = (props: any) => {
866
777
  </>
867
778
  ) : (
868
779
  <ProductEditions
869
- style={{ paddingHorizontal: isChewLayout ? 20 : 30 }}
780
+ style={{ paddingHorizontal: 20 }}
870
781
  onLayout={(event: any) => {
871
782
  setEditionsLayoutY(event.nativeEvent.layout?.y)
872
783
  }}
873
784
  >
874
785
  <>
875
786
  {product?.ingredients?.length > 0 && (
876
- <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0)}>
787
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0, true)}>
877
788
  <SectionTitle>
878
789
  <OText size={16}>
879
790
  {t('INGREDIENTS', 'Ingredients')}
@@ -895,13 +806,13 @@ export const ProductOptionsUI = (props: any) => {
895
806
  </View>
896
807
  )}
897
808
  {product?.extras?.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
898
- 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) => {
899
810
  const currentState =
900
811
  productCart.options[`id:${option.id}`] || {};
901
812
  return (
902
813
  <React.Fragment key={`popt_${option.id}`}>
903
814
  {showOption(option) && (
904
- <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)}>
905
816
  <ProductOption
906
817
  option={option}
907
818
  currentState={currentState}
@@ -913,12 +824,7 @@ export const ProductOptionsUI = (props: any) => {
913
824
  }}>
914
825
  {option?.suboptions?.sort((a: any, b: any) => a.rank - b.rank).map(
915
826
  (suboption: any) => {
916
- const currentState =
917
- productCart.options[
918
- `id:${option.id}`
919
- ]?.suboptions[
920
- `id:${suboption.id}`
921
- ] || {};
827
+ const currentState = productCart.options[`id:${option.id}`]?.suboptions[`id:${suboption.id}`] || {};
922
828
  const balance =
923
829
  productCart.options[
924
830
  `id:${option.id}`
@@ -933,6 +839,7 @@ export const ProductOptionsUI = (props: any) => {
933
839
  balance={balance}
934
840
  option={option}
935
841
  suboption={suboption}
842
+ image={suboption.image}
936
843
  state={currentState}
937
844
  disabled={
938
845
  isSoldOut ||
@@ -940,6 +847,7 @@ export const ProductOptionsUI = (props: any) => {
940
847
  }
941
848
  setIsScrollAvailable={setIsScrollAvailable}
942
849
  error={errors[`id:${option.id}`]}
850
+ enableIntersection={suboptionsLength >= 200}
943
851
  />
944
852
  );
945
853
  },
@@ -957,7 +865,7 @@ export const ProductOptionsUI = (props: any) => {
957
865
  <ProductComment>
958
866
  <SectionTitle>
959
867
  <OText size={16} weight={'600'} lineHeight={24}>
960
- {t('SPECIAL_COMMENT', 'Special comment')}
868
+ {t('COMMENTS', 'Special comment')}
961
869
  </OText>
962
870
  </SectionTitle>
963
871
  <OInput
@@ -971,6 +879,7 @@ export const ProductOptionsUI = (props: any) => {
971
879
  !(productCart && !isSoldOut && maxProductQuantity)
972
880
  }
973
881
  style={styles.comment}
882
+ forwardRef={commentRef}
974
883
  />
975
884
  </ProductComment>
976
885
  )}
@@ -979,7 +888,7 @@ export const ProductOptionsUI = (props: any) => {
979
888
  {!!error && error?.length > 0 && (
980
889
  <NotFoundSource content={error[0]?.message || error[0]} />
981
890
  )}
982
- </ScrollView>
891
+ </IOScrollView>
983
892
  )}
984
893
  {!loading && !error && product && (
985
894
  <ProductActions ios={Platform?.OS === 'ios'} isColumn={isHaveWeight}>
@@ -1090,9 +999,9 @@ export const ProductOptionsUI = (props: any) => {
1090
999
  )}
1091
1000
  </>
1092
1001
  )}
1093
- {!isHaveWeight && <ActionButton />}
1002
+ {!isHaveWeight && <ActionButton {...actionButtonProps} />}
1094
1003
  </View>
1095
- {isHaveWeight && <ActionButton />}
1004
+ {isHaveWeight && <ActionButton {...actionButtonProps} />}
1096
1005
  </ProductActions>
1097
1006
  )}
1098
1007
  </SafeAreaView>