ordering-ui-react-native 0.19.2-testing → 0.19.3-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 (217) hide show
  1. package/package.json +6 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessInformation/index.tsx +10 -9
  4. package/src/components/BusinessesListing/index.tsx +1 -1
  5. package/src/components/VerifyPhone/styles.tsx +1 -2
  6. package/src/components/shared/OToast.tsx +3 -2
  7. package/src/utils/index.tsx +2 -2
  8. package/themes/business/index.tsx +2 -0
  9. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -2
  10. package/themes/business/src/components/BusinessController/index.tsx +19 -17
  11. package/themes/business/src/components/BusinessProductList/AccordionDropdown.tsx +63 -0
  12. package/themes/business/src/components/BusinessProductList/IterateCategories.tsx +108 -0
  13. package/themes/business/src/components/BusinessProductList/ProductList.tsx +196 -0
  14. package/themes/business/src/components/BusinessProductList/index.tsx +196 -0
  15. package/themes/business/src/components/BusinessProductList/styles.tsx +10 -0
  16. package/themes/business/src/components/Chat/index.tsx +41 -13
  17. package/themes/business/src/components/DriverMap/index.tsx +4 -2
  18. package/themes/business/src/components/DriverSchedule/index.tsx +5 -5
  19. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  20. package/themes/business/src/components/MapView/index.tsx +11 -7
  21. package/themes/business/src/components/MessagesOption/index.tsx +22 -94
  22. package/themes/business/src/components/NewOrderNotification/index.tsx +121 -103
  23. package/themes/business/src/components/OrderDetails/Delivery.tsx +19 -10
  24. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +88 -51
  25. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +26 -6
  26. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
  27. package/themes/business/src/components/OrderSummary/index.tsx +27 -13
  28. package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
  29. package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
  30. package/themes/business/src/components/OrdersOption/index.tsx +83 -37
  31. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  32. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  33. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +24 -31
  34. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  35. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  36. package/themes/business/src/components/PreviousOrders/index.tsx +192 -220
  37. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  38. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  39. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  40. package/themes/business/src/components/StoresList/index.tsx +5 -3
  41. package/themes/business/src/components/UserProfileForm/index.tsx +27 -10
  42. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  43. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  44. package/themes/business/src/types/index.tsx +10 -0
  45. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  46. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  47. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  48. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  49. package/themes/kiosk/src/components/LoginForm/index.tsx +124 -96
  50. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  51. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  52. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  53. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  54. package/themes/original/index.tsx +7 -3
  55. package/themes/original/src/components/AddressForm/index.tsx +2 -2
  56. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  57. package/themes/original/src/components/AddressList/index.tsx +4 -7
  58. package/themes/original/src/components/AddressList/styles.tsx +4 -4
  59. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  60. package/themes/original/src/components/BusinessBasicInformation/index.tsx +3 -3
  61. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
  62. package/themes/original/src/components/BusinessController/index.tsx +9 -6
  63. package/themes/original/src/components/BusinessController/styles.tsx +8 -7
  64. package/themes/original/src/components/BusinessInformation/index.tsx +35 -3
  65. package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
  66. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -7
  67. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +317 -0
  68. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +96 -0
  69. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  70. package/themes/original/src/components/BusinessListingSearch/index.tsx +56 -361
  71. package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
  72. package/themes/original/src/components/BusinessPreorder/index.tsx +3 -4
  73. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
  74. package/themes/original/src/components/BusinessProductsList/index.tsx +2 -2
  75. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  76. package/themes/original/src/components/BusinessProductsListing/index.tsx +43 -19
  77. package/themes/original/src/components/BusinessProductsListing/styles.tsx +3 -4
  78. package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
  79. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  80. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
  81. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  82. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  83. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  84. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +29 -402
  85. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  86. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  87. package/themes/original/src/components/Cart/index.tsx +27 -8
  88. package/themes/original/src/components/CartContent/index.tsx +61 -39
  89. package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
  90. package/themes/original/src/components/Checkout/index.tsx +199 -55
  91. package/themes/original/src/components/Checkout/styles.tsx +17 -0
  92. package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
  93. package/themes/original/src/components/DatePicker/index.tsx +17 -0
  94. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  95. package/themes/original/src/components/Favorite/index.tsx +4 -9
  96. package/themes/original/src/components/Favorite/styles.tsx +0 -2
  97. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  98. package/themes/original/src/components/GPSButton/index.tsx +1 -1
  99. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  100. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +36 -3
  101. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
  102. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +67 -4
  103. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
  104. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +2 -2
  105. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
  106. package/themes/original/src/components/GoogleMap/index.tsx +50 -5
  107. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
  108. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
  109. package/themes/original/src/components/Home/index.tsx +1 -1
  110. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  111. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  112. package/themes/original/src/components/LoginForm/Otp/index.tsx +53 -47
  113. package/themes/original/src/components/LoginForm/index.tsx +6 -1
  114. package/themes/original/src/components/Messages/index.tsx +9 -4
  115. package/themes/original/src/components/Messages/styles.tsx +1 -1
  116. package/themes/original/src/components/MomentOption/index.tsx +4 -4
  117. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  118. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  119. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +13 -4
  120. package/themes/original/src/components/MultiCheckout/index.tsx +184 -51
  121. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -1
  122. package/themes/original/src/components/MyOrders/index.tsx +5 -5
  123. package/themes/original/src/components/NavBar/index.tsx +3 -1
  124. package/themes/original/src/components/NetworkError/index.tsx +2 -3
  125. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  126. package/themes/original/src/components/Notifications/index.tsx +4 -8
  127. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  128. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +7 -3
  129. package/themes/original/src/components/OrderDetails/index.tsx +716 -667
  130. package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
  131. package/themes/original/src/components/OrderProgress/index.tsx +7 -7
  132. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  133. package/themes/original/src/components/OrderSummary/index.tsx +5 -3
  134. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  135. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  136. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  137. package/themes/original/src/components/OrdersOption/index.tsx +4 -3
  138. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  139. package/themes/original/src/components/PageBanner/index.tsx +3 -0
  140. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  141. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  142. package/themes/original/src/components/PaymentOptions/index.tsx +41 -32
  143. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -1
  144. package/themes/original/src/components/ProductForm/ActionButton.tsx +120 -0
  145. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  146. package/themes/original/src/components/ProductForm/index.tsx +81 -167
  147. package/themes/original/src/components/ProductForm/styles.tsx +1 -1
  148. package/themes/original/src/components/ProductItemAccordion/index.tsx +5 -0
  149. package/themes/original/src/components/ProductOptionSubOption/index.tsx +120 -79
  150. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
  151. package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
  152. package/themes/original/src/components/Promotions/index.tsx +4 -4
  153. package/themes/original/src/components/Promotions/styles.tsx +0 -2
  154. package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
  155. package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
  156. package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
  157. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  158. package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
  159. package/themes/original/src/components/SingleOrderCard/index.tsx +4 -3
  160. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  161. package/themes/original/src/components/StripeCardsList/index.tsx +53 -7
  162. package/themes/original/src/components/StripeElementsForm/index.tsx +1 -1
  163. package/themes/original/src/components/StripeElementsForm/naked.tsx +12 -1
  164. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
  165. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +86 -0
  166. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
  167. package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
  168. package/themes/original/src/components/UserFormDetails/index.tsx +53 -7
  169. package/themes/original/src/components/UserProfile/index.tsx +1 -1
  170. package/themes/original/src/components/UserProfileForm/index.tsx +30 -36
  171. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  172. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  173. package/themes/original/src/components/Wallets/index.tsx +8 -9
  174. package/themes/original/src/components/Wallets/styles.tsx +1 -1
  175. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  176. package/themes/original/src/components/shared/OInput.tsx +1 -4
  177. package/themes/original/src/components/shared/OModal.tsx +12 -14
  178. package/themes/original/src/layouts/Container.tsx +5 -3
  179. package/themes/original/src/types/index.tsx +10 -2
  180. package/themes/original/src/utils/index.tsx +124 -0
  181. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  182. package/src/navigators/BottomNavigator.tsx +0 -117
  183. package/src/navigators/CheckoutNavigator.tsx +0 -66
  184. package/src/navigators/HomeNavigator.tsx +0 -202
  185. package/src/navigators/NavigationRef.tsx +0 -7
  186. package/src/navigators/RootNavigator.tsx +0 -269
  187. package/src/pages/Account.tsx +0 -34
  188. package/src/pages/AddressForm.tsx +0 -62
  189. package/src/pages/AddressList.tsx +0 -24
  190. package/src/pages/BusinessProductsList.tsx +0 -81
  191. package/src/pages/BusinessesListing.tsx +0 -43
  192. package/src/pages/CartList.tsx +0 -49
  193. package/src/pages/Checkout.tsx +0 -101
  194. package/src/pages/ForgotPassword.tsx +0 -24
  195. package/src/pages/Help.tsx +0 -23
  196. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  197. package/src/pages/HelpGuide.tsx +0 -23
  198. package/src/pages/HelpOrder.tsx +0 -23
  199. package/src/pages/Home.tsx +0 -36
  200. package/src/pages/IntroductoryTutorial.tsx +0 -170
  201. package/src/pages/Login.tsx +0 -47
  202. package/src/pages/MomentOption.tsx +0 -30
  203. package/src/pages/MultiCheckout.tsx +0 -31
  204. package/src/pages/MultiOrdersDetails.tsx +0 -27
  205. package/src/pages/MyOrders.tsx +0 -40
  206. package/src/pages/NetworkError.tsx +0 -24
  207. package/src/pages/NotFound.tsx +0 -22
  208. package/src/pages/OrderDetails.tsx +0 -25
  209. package/src/pages/ProductDetails.tsx +0 -55
  210. package/src/pages/Profile.tsx +0 -36
  211. package/src/pages/ReviewDriver.tsx +0 -30
  212. package/src/pages/ReviewOrder.tsx +0 -32
  213. package/src/pages/ReviewProducts.tsx +0 -30
  214. package/src/pages/Sessions.tsx +0 -22
  215. package/src/pages/Signup.tsx +0 -53
  216. package/src/pages/SpinnerLoader.tsx +0 -10
  217. 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,8 +56,14 @@ 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
 
65
+
66
+
61
67
  export const ProductOptionsUI = (props: any) => {
62
68
  const {
63
69
  navigation,
@@ -79,11 +85,10 @@ export const ProductOptionsUI = (props: any) => {
79
85
  actionStatus,
80
86
  handleCreateGuestUser
81
87
  } = props;
82
-
83
88
  const theme = useTheme();
84
89
  const [, { showToast }] = useToast()
85
90
  const [events] = useEvent()
86
-
91
+ const commentRef = useRef()
87
92
  const isChewLayout = theme?.header?.components?.layout?.type?.toLowerCase() === 'chew'
88
93
 
89
94
  const styles = StyleSheet.create({
@@ -137,7 +142,8 @@ export const ProductOptionsUI = (props: any) => {
137
142
  },
138
143
  slide1: {
139
144
  flex: 1,
140
- alignItems: 'center'
145
+ alignItems: 'center',
146
+ width: '100%'
141
147
  },
142
148
  mainSwiper: {
143
149
  height: 258,
@@ -176,7 +182,7 @@ export const ProductOptionsUI = (props: any) => {
176
182
  marginTop: 10
177
183
  },
178
184
  wrapperNavbar: {
179
- paddingHorizontal: 40,
185
+ paddingHorizontal: 20,
180
186
  paddingTop: 0,
181
187
  }
182
188
  });
@@ -207,7 +213,7 @@ export const ProductOptionsUI = (props: any) => {
207
213
  const [editionsLayoutY, setEditionsLayoutY] = useState(null)
208
214
  const [viewedProduct, setViewedProduct] = useState<any>(null)
209
215
  const [showTitle, setShowTitle] = useState(false)
210
-
216
+ const productOptionsMounted = useRef(false)
211
217
  const guestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
212
218
  const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
213
219
 
@@ -282,14 +288,14 @@ export const ProductOptionsUI = (props: any) => {
282
288
  setQtyBy({ [val]: true, [!val]: false })
283
289
  }
284
290
 
285
- const onStateChange = useCallback((state) => {
291
+ const onStateChange = useCallback((state : string) => {
286
292
  if (state === "ended") {
287
293
  setPlaying(false);
288
294
  }
289
295
  }, []);
290
296
 
291
297
  const togglePlaying = useCallback(() => {
292
- setPlaying((prev) => !prev);
298
+ setPlaying((prev : any) => !prev);
293
299
  }, []);
294
300
 
295
301
  const onChangeProductCartQuantity = (quantity: number) => {
@@ -320,63 +326,22 @@ export const ProductOptionsUI = (props: any) => {
320
326
  if (guestToken) handleCreateGuestUser({ guest_token: guestToken })
321
327
  }
322
328
 
323
- const handleOnLayout = (event: any, optionId: any) => {
324
- const _optionLayout = { ...optionLayout }
329
+ let _optionLayout: any = {}
330
+
331
+ const handleOnLayout = (event: any, optionId: any, lastMounts: boolean) => {
332
+ if (suboptionsLength >= 200) {
333
+ return
334
+ }
335
+ _optionLayout = { ..._optionLayout }
325
336
  const optionKey = 'id:' + optionId
326
337
  _optionLayout[optionKey] = { y: event.nativeEvent.layout?.y }
327
- setOptionLayout(_optionLayout)
338
+ if (lastMounts) {
339
+ setOptionLayout(_optionLayout)
340
+ }
328
341
  }
329
342
 
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) => {
343
+ const handleScroll = ({ nativeEvent: { contentOffset } }: any) => {
375
344
  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
345
  }
381
346
 
382
347
  const handleGoBack = navigation?.canGoBack()
@@ -434,90 +399,6 @@ export const ProductOptionsUI = (props: any) => {
434
399
  }
435
400
  }, [product])
436
401
 
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
402
  useEffect(() => {
522
403
  const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
523
404
  scrollViewRef.current.scrollToEnd({ animated: true })
@@ -533,13 +414,45 @@ export const ProductOptionsUI = (props: any) => {
533
414
  events.emit('product_viewed', product)
534
415
  }, [product?.id, viewedProduct])
535
416
 
417
+ const actionButtonProps = {
418
+ navigation,
419
+ isHaveWeight,
420
+ isSoldOut,
421
+ maxProductQuantity,
422
+ productCart,
423
+ handleSaveProduct,
424
+ editMode,
425
+ product,
426
+ errors,
427
+ productAddedToCartLength,
428
+ handleRedirectLogin,
429
+ guestCheckoutEnabled,
430
+ orderTypeEnabled,
431
+ handleUpdateGuest,
432
+ actionStatus
433
+ }
434
+
435
+ const extraOptionsProps = {
436
+ setSelectedOpt,
437
+ scrollViewRef,
438
+ optionLayout,
439
+ editionsLayoutY,
440
+ styles,
441
+ selOpt
442
+ }
443
+
444
+ const suboptionsLength = product.extras.reduce((acc : number, extras : any) => acc + extras?.options?.reduce((accSuboptions : number, options: any) => accSuboptions + options?.suboptions?.length, 0), 0)
445
+
536
446
  return (
537
447
  <SafeAreaView style={{ flex: 1 }}>
538
448
  <View style={styles.wrapperNavbar}>
539
449
  <TopHeader>
540
450
  <>
541
451
  <TopActions onPress={() => handleGoBack()}>
542
- <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
452
+ <IconAntDesign
453
+ name='arrowleft'
454
+ size={26}
455
+ />
543
456
  </TopActions>
544
457
  {showTitle && (
545
458
  <OText
@@ -556,10 +469,11 @@ export const ProductOptionsUI = (props: any) => {
556
469
  </TopHeader>
557
470
  </View>
558
471
  {!error && (
559
- <ScrollView
472
+ <IOScrollView
560
473
  ref={scrollViewRef}
561
474
  contentContainerStyle={{ paddingBottom: 80 }}
562
475
  stickyHeaderIndices={[2]}
476
+ scrollEventThrottle={100}
563
477
  onScroll={handleScroll}
564
478
  >
565
479
  <WrapHeader onLayout={(event: any) => setHeaderRefHeight(event.nativeEvent.layout?.height)}>
@@ -581,7 +495,7 @@ export const ProductOptionsUI = (props: any) => {
581
495
  showsButtons={true}
582
496
  style={styles.mainSwiper}
583
497
  showsPagination={false}
584
- onIndexChanged={(index) => handleChangeMainIndex(index)}
498
+ onIndexChanged={(index : any) => handleChangeMainIndex(index)}
585
499
  prevButton={
586
500
  <View style={styles.swiperButton}>
587
501
  <IconAntDesign
@@ -603,7 +517,7 @@ export const ProductOptionsUI = (props: any) => {
603
517
  </View>
604
518
  }
605
519
  >
606
- {gallery && gallery?.length > 0 && gallery.map((img, i) => (
520
+ {gallery && gallery?.length > 0 && gallery.map((img : any, i: number) => (
607
521
  <View
608
522
  style={styles.slide1}
609
523
  key={i}
@@ -634,11 +548,11 @@ export const ProductOptionsUI = (props: any) => {
634
548
  <ScrollView
635
549
  horizontal
636
550
  contentContainerStyle={{
637
- paddingHorizontal: 30,
551
+ paddingHorizontal: 20,
638
552
  paddingVertical: 15
639
553
  }}
640
554
  >
641
- {gallery?.length > 1 && gallery.map((img, index) => (
555
+ {gallery?.length > 1 && gallery.map((img: any, index: number) => (
642
556
  <TouchableOpacity
643
557
  key={index}
644
558
  onPress={() => handleClickThumb(index)}
@@ -687,7 +601,7 @@ export const ProductOptionsUI = (props: any) => {
687
601
  )}
688
602
  </WrapHeader>
689
603
  <ProductSummary
690
- ph={isChewLayout ? 20 : 40}
604
+ ph={20}
691
605
  onLayout={(event: any) => setSummaryRefHeight(event.nativeEvent.layout?.height)}
692
606
  >
693
607
  <ProductTitle>
@@ -757,6 +671,7 @@ export const ProductOptionsUI = (props: any) => {
757
671
  </ProductDescription>
758
672
  <ScrollView
759
673
  horizontal
674
+ scrollEventThrottle={100}
760
675
  showsHorizontalScrollIndicator={false}
761
676
  contentContainerStyle={{ paddingBottom: 30 }}
762
677
  >
@@ -784,12 +699,13 @@ export const ProductOptionsUI = (props: any) => {
784
699
  {(!loading && product) && (
785
700
  <ExtraOptionWrap
786
701
  horizontal
702
+ scrollEventThrottle={100}
787
703
  showsHorizontalScrollIndicator={false}
788
704
  style={{
789
705
  marginBottom: 20,
790
706
  borderBottomWidth: 1,
791
707
  borderBottomColor: theme.colors.border,
792
- marginHorizontal: isChewLayout ? 20 : 30,
708
+ marginHorizontal: 20,
793
709
  backgroundColor: theme.colors.backgroundPage,
794
710
  }}
795
711
  >
@@ -818,8 +734,8 @@ export const ProductOptionsUI = (props: any) => {
818
734
  </OText>
819
735
  </TouchableOpacity>
820
736
  )}
821
- {product?.extras?.map((extra: any) =>
822
- <ExtraOptions key={extra.id} options={extra.options} />
737
+ {suboptionsLength < 200 && product?.extras?.map((extra: any) =>
738
+ <ExtraOptions key={extra.id} options={extra.options} {...extraOptionsProps} />
823
739
  )}
824
740
  </ExtraOptionWrap>
825
741
  )}
@@ -863,14 +779,14 @@ export const ProductOptionsUI = (props: any) => {
863
779
  </>
864
780
  ) : (
865
781
  <ProductEditions
866
- style={{ paddingHorizontal: isChewLayout ? 20 : 40 }}
782
+ style={{ paddingHorizontal: 20 }}
867
783
  onLayout={(event: any) => {
868
784
  setEditionsLayoutY(event.nativeEvent.layout?.y)
869
785
  }}
870
786
  >
871
787
  <>
872
788
  {product?.ingredients?.length > 0 && (
873
- <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0)}>
789
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, 0, true)}>
874
790
  <SectionTitle>
875
791
  <OText size={16}>
876
792
  {t('INGREDIENTS', 'Ingredients')}
@@ -892,13 +808,13 @@ export const ProductOptionsUI = (props: any) => {
892
808
  </View>
893
809
  )}
894
810
  {product?.extras?.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
895
- extra.options?.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
811
+ extra.options?.sort((a: any, b: any) => a.rank - b.rank).map((option: any, i: number) => {
896
812
  const currentState =
897
813
  productCart.options[`id:${option.id}`] || {};
898
814
  return (
899
815
  <React.Fragment key={`popt_${option.id}`}>
900
816
  {showOption(option) && (
901
- <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, option?.id)}>
817
+ <View style={styles.optionContainer} onLayout={(event: any) => handleOnLayout(event, option?.id, extra.options?.length <= i + 2)}>
902
818
  <ProductOption
903
819
  option={option}
904
820
  currentState={currentState}
@@ -910,12 +826,7 @@ export const ProductOptionsUI = (props: any) => {
910
826
  }}>
911
827
  {option?.suboptions?.sort((a: any, b: any) => a.rank - b.rank).map(
912
828
  (suboption: any) => {
913
- const currentState =
914
- productCart.options[
915
- `id:${option.id}`
916
- ]?.suboptions[
917
- `id:${suboption.id}`
918
- ] || {};
829
+ const currentState = productCart.options[`id:${option.id}`]?.suboptions[`id:${suboption.id}`] || {};
919
830
  const balance =
920
831
  productCart.options[
921
832
  `id:${option.id}`
@@ -930,6 +841,7 @@ export const ProductOptionsUI = (props: any) => {
930
841
  balance={balance}
931
842
  option={option}
932
843
  suboption={suboption}
844
+ image={suboption.image}
933
845
  state={currentState}
934
846
  disabled={
935
847
  isSoldOut ||
@@ -937,6 +849,7 @@ export const ProductOptionsUI = (props: any) => {
937
849
  }
938
850
  setIsScrollAvailable={setIsScrollAvailable}
939
851
  error={errors[`id:${option.id}`]}
852
+ enableIntersection={suboptionsLength >= 200}
940
853
  />
941
854
  );
942
855
  },
@@ -954,7 +867,7 @@ export const ProductOptionsUI = (props: any) => {
954
867
  <ProductComment>
955
868
  <SectionTitle>
956
869
  <OText size={16} weight={'600'} lineHeight={24}>
957
- {t('SPECIAL_COMMENT', 'Special comment')}
870
+ {t('COMMENTS', 'Special comment')}
958
871
  </OText>
959
872
  </SectionTitle>
960
873
  <OInput
@@ -968,6 +881,7 @@ export const ProductOptionsUI = (props: any) => {
968
881
  !(productCart && !isSoldOut && maxProductQuantity)
969
882
  }
970
883
  style={styles.comment}
884
+ forwardRef={commentRef}
971
885
  />
972
886
  </ProductComment>
973
887
  )}
@@ -976,7 +890,7 @@ export const ProductOptionsUI = (props: any) => {
976
890
  {!!error && error?.length > 0 && (
977
891
  <NotFoundSource content={error[0]?.message || error[0]} />
978
892
  )}
979
- </ScrollView>
893
+ </IOScrollView>
980
894
  )}
981
895
  {!loading && !error && product && (
982
896
  <ProductActions ios={Platform?.OS === 'ios'} isColumn={isHaveWeight}>
@@ -1087,9 +1001,9 @@ export const ProductOptionsUI = (props: any) => {
1087
1001
  )}
1088
1002
  </>
1089
1003
  )}
1090
- {!isHaveWeight && <ActionButton />}
1004
+ {!isHaveWeight && <ActionButton {...actionButtonProps} />}
1091
1005
  </View>
1092
- {isHaveWeight && <ActionButton />}
1006
+ {isHaveWeight && <ActionButton {...actionButtonProps} />}
1093
1007
  </ProductActions>
1094
1008
  )}
1095
1009
  </SafeAreaView>
@@ -70,7 +70,7 @@ export const ProductActions = styled.View`
70
70
  position: absolute;
71
71
  bottom: 0px;
72
72
  padding-top: ${(props: any) => props.ios ? '20px' : '0'};
73
- padding-horizontal: 40px;
73
+ padding-horizontal: 30px;
74
74
  padding-vertical: 20px;
75
75
  width: 100%;
76
76
  flex-direction: ${(props: any) => props.isColumn ? 'column' : 'row'};
@@ -215,6 +215,11 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
215
215
  style={pickerStyle}
216
216
  useNativeAndroidPickerStyle={false}
217
217
  placeholder={{}}
218
+ touchableWrapperProps={{
219
+ style: {
220
+ width: 40,
221
+ }
222
+ }}
218
223
  Icon={() => <View style={pickerStyle.icon}><OIcon src={theme.images.general.arrow_down} color={theme.colors.textNormal} width={8} /></View>}
219
224
  disabled={orderState.loading}
220
225
  />