ordering-ui-react-native 0.15.69 → 0.15.70-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 (220) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +1 -1
  5. package/src/components/AddressForm/index.tsx +18 -2
  6. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  7. package/src/components/BusinessController/index.tsx +16 -8
  8. package/src/components/BusinessInformation/index.tsx +14 -0
  9. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  10. package/src/components/BusinessesListing/index.tsx +1 -1
  11. package/src/components/Checkout/index.tsx +23 -2
  12. package/src/components/DriverTips/index.tsx +11 -6
  13. package/src/components/LanguageSelector/index.tsx +6 -2
  14. package/src/components/LoginForm/index.tsx +120 -30
  15. package/src/components/LoginForm/styles.tsx +6 -0
  16. package/src/components/NotificationSetting/index.tsx +85 -0
  17. package/src/components/OrderDetails/index.tsx +7 -21
  18. package/src/components/PaymentOptions/index.tsx +67 -50
  19. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  20. package/src/components/ReviewDriver/index.tsx +1 -1
  21. package/src/components/ReviewOrder/index.tsx +2 -1
  22. package/src/components/ReviewProducts/index.tsx +11 -0
  23. package/src/components/SignupForm/index.tsx +145 -61
  24. package/src/components/SingleProductCard/index.tsx +16 -4
  25. package/src/components/SingleProductReview/index.tsx +1 -1
  26. package/src/components/StripeMethodForm/index.tsx +22 -24
  27. package/src/components/UpsellingProducts/index.tsx +1 -1
  28. package/src/components/UserProfileForm/index.tsx +63 -6
  29. package/src/components/UserProfileForm/styles.tsx +8 -0
  30. package/src/components/VerifyPhone/styles.tsx +1 -2
  31. package/src/components/shared/OBottomPopup.tsx +6 -2
  32. package/src/components/shared/OModal.tsx +1 -1
  33. package/src/hooks/useCountdownTimer.tsx +26 -0
  34. package/src/index.tsx +2 -0
  35. package/src/navigators/CheckoutNavigator.tsx +6 -0
  36. package/src/navigators/HomeNavigator.tsx +12 -0
  37. package/src/pages/BusinessesListing.tsx +7 -6
  38. package/src/pages/MultiCheckout.tsx +31 -0
  39. package/src/pages/MultiOrdersDetails.tsx +27 -0
  40. package/src/pages/OrderDetails.tsx +1 -1
  41. package/src/pages/ReviewDriver.tsx +2 -2
  42. package/src/pages/ReviewOrder.tsx +2 -2
  43. package/src/pages/Sessions.tsx +22 -0
  44. package/src/theme.json +0 -1
  45. package/src/types/index.tsx +18 -11
  46. package/src/utils/index.tsx +68 -2
  47. package/themes/business/index.tsx +4 -0
  48. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  49. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  50. package/themes/business/src/components/Chat/index.tsx +51 -91
  51. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  52. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  53. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  54. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  55. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  56. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  57. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  58. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  59. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  60. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +14 -7
  61. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  62. package/themes/business/src/components/OrdersListManager/index.tsx +11 -4
  63. package/themes/business/src/components/OrdersOption/index.tsx +16 -4
  64. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  65. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  66. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  67. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  68. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  69. package/themes/business/src/components/shared/OModal.tsx +41 -38
  70. package/themes/business/src/types/index.tsx +14 -7
  71. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  72. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  73. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  74. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  75. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  76. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  77. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  78. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  79. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  80. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  81. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  82. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  83. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  84. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  85. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  86. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  87. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  88. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  89. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  90. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  91. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  92. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  93. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  94. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  95. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  96. package/themes/kiosk/src/types/index.d.ts +1 -0
  97. package/themes/original/index.tsx +24 -0
  98. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  99. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  100. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  101. package/themes/original/src/components/AddressList/index.tsx +30 -18
  102. package/themes/original/src/components/AppleLogin/index.tsx +6 -8
  103. package/themes/original/src/components/BusinessBasicInformation/index.tsx +304 -158
  104. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  105. package/themes/original/src/components/BusinessController/index.tsx +201 -96
  106. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  107. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  108. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  109. package/themes/original/src/components/BusinessListingSearch/index.tsx +231 -63
  110. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  111. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  112. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  113. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  114. package/themes/original/src/components/BusinessProductsList/index.tsx +70 -52
  115. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  116. package/themes/original/src/components/BusinessProductsListing/index.tsx +342 -154
  117. package/themes/original/src/components/BusinessProductsListing/styles.tsx +33 -0
  118. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  119. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -39
  120. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  121. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +560 -0
  122. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  123. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +671 -0
  124. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  125. package/themes/original/src/components/BusinessesListing/index.tsx +104 -458
  126. package/themes/original/src/components/Cart/index.tsx +93 -43
  127. package/themes/original/src/components/Cart/styles.tsx +4 -0
  128. package/themes/original/src/components/Checkout/index.tsx +90 -39
  129. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  130. package/themes/original/src/components/Favorite/index.tsx +92 -0
  131. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  132. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  133. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  134. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  135. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  136. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  137. package/themes/original/src/components/Help/index.tsx +21 -4
  138. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  139. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  140. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  141. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  142. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  143. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  144. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  145. package/themes/original/src/components/Messages/index.tsx +1 -1
  146. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  147. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  148. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  149. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  150. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  151. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  152. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  153. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  154. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  155. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  156. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  157. package/themes/original/src/components/NavBar/index.tsx +4 -4
  158. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  159. package/themes/original/src/components/OrderDetails/index.tsx +148 -63
  160. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  161. package/themes/original/src/components/OrderItAgain/index.tsx +72 -0
  162. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  163. package/themes/original/src/components/OrderSummary/index.tsx +5 -5
  164. package/themes/original/src/components/OrderTypeSelector/index.tsx +79 -35
  165. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  166. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  167. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  168. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  169. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  170. package/themes/original/src/components/OrdersOption/index.tsx +137 -38
  171. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  172. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  173. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  174. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  175. package/themes/original/src/components/PaymentOptions/index.tsx +58 -37
  176. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  177. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  178. package/themes/original/src/components/ProductForm/index.tsx +718 -679
  179. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  180. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  181. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  182. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  183. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  184. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  185. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  186. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  187. package/themes/original/src/components/Promotions/index.tsx +151 -133
  188. package/themes/original/src/components/Promotions/styles.tsx +2 -1
  189. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  190. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  191. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  192. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  193. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  194. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  195. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  196. package/themes/original/src/components/Sessions/index.tsx +160 -0
  197. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  198. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  199. package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
  200. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  201. package/themes/original/src/components/SingleProductCard/index.tsx +214 -90
  202. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  203. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  204. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  205. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  206. package/themes/original/src/components/UserDetails/index.tsx +32 -18
  207. package/themes/original/src/components/UserFormDetails/index.tsx +102 -66
  208. package/themes/original/src/components/UserProfile/index.tsx +10 -1
  209. package/themes/original/src/components/UserProfileForm/index.tsx +32 -25
  210. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  211. package/themes/original/src/components/Wallets/index.tsx +25 -12
  212. package/themes/original/src/components/shared/OBottomPopup.tsx +44 -13
  213. package/themes/original/src/components/shared/OButton.tsx +2 -0
  214. package/themes/original/src/components/shared/OInput.tsx +3 -2
  215. package/themes/original/src/components/shared/OModal.tsx +4 -2
  216. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  217. package/themes/original/src/types/index.tsx +203 -35
  218. package/themes/original/src/utils/index.tsx +94 -1
  219. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  220. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,29 +1,48 @@
1
- import React from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import {
3
3
  useLanguage,
4
4
  useConfig,
5
5
  useOrder,
6
6
  useUtils,
7
+ useSession,
8
+ SingleProductCard as SingleProductCardController
7
9
  } from 'ordering-components/native';
8
10
  import { useTheme } from 'styled-components/native';
9
11
  import { SingleProductCardParams } from '../../types';
10
12
  import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper } from './styles';
11
- import { StyleSheet } from 'react-native';
12
- import { OText, OIcon } from '../shared';
13
+ import { StyleSheet, View, TouchableOpacity, Image, Animated } from 'react-native';
14
+ import { InView } from 'react-native-intersection-observer'
15
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
16
+ import { OButton, OText } from '../shared';
13
17
  import FastImage from 'react-native-fast-image'
18
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
14
19
  import { shape } from '../../utils';
15
20
 
16
- export const SingleProductCard = (props: SingleProductCardParams) => {
21
+ function SingleProductCardPropsAreEqual(prevProps: any, nextProps: any) {
22
+ return JSON.stringify(prevProps.product) === JSON.stringify(nextProps.product) &&
23
+ prevProps.isSoldOut === nextProps.isSoldOut &&
24
+ prevProps.productAddedToCartLength === nextProps.productAddedToCartLength &&
25
+ prevProps.categoryState === nextProps.categoryState
26
+ }
27
+
28
+ const SingleProductCardUI = React.memo((props: SingleProductCardParams) => {
17
29
  const {
18
- businessId,
19
30
  product,
20
31
  isSoldOut,
21
32
  onProductClick,
22
33
  productAddedToCartLength,
23
- style
34
+ style,
35
+ handleFavoriteProduct,
36
+ enableIntersection,
37
+ navigation,
38
+ businessId,
39
+ isPreviously
24
40
  } = props;
25
41
 
26
42
  const theme = useTheme();
43
+ const hideAddButton = theme?.business_view?.components?.products?.components?.add_to_cart_button?.hidden ?? true
44
+
45
+ const fadeAnim = useRef(new Animated.Value(0)).current;
27
46
 
28
47
  const styles = StyleSheet.create({
29
48
  container: {
@@ -31,6 +50,12 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
31
50
  borderRadius: 7.6,
32
51
  borderColor: theme.colors.border,
33
52
  marginBottom: 28,
53
+ minHeight: 165
54
+ },
55
+ titleWrapper: {
56
+ flexDirection: 'row',
57
+ alignItems: 'center',
58
+ justifyContent: 'space-between'
34
59
  },
35
60
  line18: {
36
61
  lineHeight: 18,
@@ -68,11 +93,12 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
68
93
  }
69
94
  });
70
95
 
71
-
72
96
  const [, t] = useLanguage();
73
97
  const [stateConfig] = useConfig();
74
- const [{ parsePrice, optimizeImage }] = useUtils();
75
- const [orderState] = useOrder();
98
+ const [{ auth }] = useSession()
99
+ const [{ parsePrice, optimizeImage, parseDate }] = useUtils();
100
+ const [orderState] = useOrder()
101
+ const [isIntersectionObserver, setIsIntersectionObserver] = useState(!enableIntersection)
76
102
 
77
103
  const editMode = typeof product?.code !== 'undefined';
78
104
 
@@ -97,88 +123,186 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
97
123
  maxCartProductConfig,
98
124
  maxCartProductInventory,
99
125
  );
126
+
127
+ const fadeIn = () => {
128
+ Animated.timing(fadeAnim, {
129
+ toValue: 1,
130
+ duration: 500,
131
+ useNativeDriver: true
132
+ }).start();
133
+ };
134
+
135
+ const handleChangeFavorite = () => {
136
+ if (auth) {
137
+ handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
138
+ } else {
139
+ navigation && navigation.navigate('Login');
140
+ }
141
+ }
142
+
143
+ const handleChangeIntersection = () => {
144
+ setIsIntersectionObserver(true);
145
+ fadeIn();
146
+ }
147
+
148
+ useEffect(() => {
149
+ if (!enableIntersection) fadeIn()
150
+ }, [enableIntersection])
151
+
100
152
  return (
101
- <CardContainer
102
- style={[
103
- styles.container,
104
- (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
105
- (style && { ...style }),
106
- ]}
107
- onPress={() => onProductClick?.(product)}>
108
- {productAddedToCartLength > 0 && (
109
- <QuantityContainer style={[styles.quantityContainer, {
110
- transform: [{ translateX: 10 }, { translateY: -10 }],
111
- }]}>
112
- <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
113
- </QuantityContainer>
114
- )}
115
- <CardInfo>
116
- <OText
117
- size={12}
118
- weight={'500'}
119
- numberOfLines={1}
120
- ellipsizeMode="tail"
121
- style={styles.line18}>
122
- {product?.name}
123
- </OText>
124
- <PricesContainer>
125
- <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
126
- {product?.offer_price !== null && product?.in_offer && (
127
- <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
153
+ <InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
154
+ {isIntersectionObserver ? (
155
+ <CardContainer
156
+ showAddButton={!hideAddButton}
157
+ style={[
158
+ styles.container,
159
+ (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
160
+ (style && { ...style }),
161
+ ]}
162
+ onPress={() => onProductClick?.(product)}
163
+ >
164
+ <View style={{ flexDirection: 'row' }}>
165
+ {productAddedToCartLength > 0 && (
166
+ <QuantityContainer style={[styles.quantityContainer, {
167
+ transform: [{ translateX: 10 }, { translateY: -10 }],
168
+ }]}>
169
+ <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
170
+ </QuantityContainer>
171
+ )}
172
+ <CardInfo>
173
+ <View style={styles.titleWrapper}>
174
+ <OText
175
+ size={12}
176
+ weight={'500'}
177
+ numberOfLines={1}
178
+ ellipsizeMode="tail"
179
+ style={{ ...styles.line18, flex: 1 }}>
180
+ {product?.name}
181
+ </OText>
182
+ {!isPreviously && (
183
+ <TouchableOpacity
184
+ onPress={handleChangeFavorite}
185
+ >
186
+ <IconAntDesign
187
+ name={product?.favorite ? 'heart' : 'hearto'}
188
+ color={theme.colors.danger5}
189
+ size={18}
190
+ />
191
+ </TouchableOpacity>
192
+ )}
193
+ </View>
194
+ <PricesContainer>
195
+ <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
196
+ {product?.offer_price !== null && product?.in_offer && (
197
+ <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
198
+ )}
199
+ </PricesContainer>
200
+ <OText
201
+ size={10}
202
+ numberOfLines={!isPreviously ? 2 : 1}
203
+ ellipsizeMode="tail"
204
+ color={theme.colors.textSecondary}
205
+ style={styles.line15}>
206
+ {product?.description}
207
+ </OText>
208
+ {isPreviously && (
209
+ <OText
210
+ size={10}
211
+ numberOfLines={1}
212
+ ellipsizeMode="tail"
213
+ color={theme.colors.primary}
214
+ style={styles.line15}>
215
+ {t('LAST_ORDERED_ON', 'Last ordered on')} {parseDate(product?.last_ordered_date, { outputFormat: 'MMM DD, YYYY' })}
216
+ </OText>
217
+ )}
218
+ </CardInfo>
219
+ <LogoWrapper>
220
+ {product?.ribbon?.enabled && (
221
+ <RibbonBox
222
+ bgColor={product?.ribbon?.color}
223
+ isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
224
+ isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
225
+ >
226
+ <OText
227
+ size={10}
228
+ weight={'400'}
229
+ color={theme.colors.white}
230
+ numberOfLines={2}
231
+ ellipsizeMode='tail'
232
+ lineHeight={13}
233
+ >
234
+ {product?.ribbon?.text}
235
+ </OText>
236
+ </RibbonBox>
237
+ )}
238
+ {product?.images && (
239
+ <Animated.View
240
+ style={[
241
+ {
242
+ // Bind opacity to animated value
243
+ opacity: fadeAnim
244
+ }
245
+ ]}
246
+ >
247
+ <FastImage
248
+ style={styles.productStyle}
249
+ source={{
250
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
251
+ priority: FastImage.priority.normal,
252
+ }}
253
+ resizeMode={FastImage.resizeMode.cover}
254
+ />
255
+ </Animated.View>
256
+ )}
257
+ </LogoWrapper>
258
+
259
+ {(isSoldOut || maxProductQuantity <= 0) && (
260
+ <SoldOut>
261
+ <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
262
+ {t('SOLD_OUT', 'SOLD OUT')}
263
+ </OText>
264
+ </SoldOut>
265
+ )}
266
+ </View>
267
+ {!hideAddButton && (
268
+ <OButton
269
+ onClick={() => onProductClick?.(product)}
270
+ style={{
271
+ width: '100%',
272
+ borderRadius: 7.6,
273
+ marginTop: 10,
274
+
275
+ }}
276
+ bgColor={isSoldOut ? '#B8B8B8' : theme?.colors?.white}
277
+ borderColor={theme?.colors.primary}
278
+ textStyle={{ color: theme.colors.primary }}
279
+ text={t('ADD', 'Add')}
280
+ />
128
281
  )}
129
- </PricesContainer>
130
- <OText
131
- size={10}
132
- numberOfLines={2}
133
- ellipsizeMode="tail"
134
- color={theme.colors.textSecondary}
135
- style={styles.line15}>
136
- {product?.description}
137
- </OText>
138
- </CardInfo>
139
- <LogoWrapper>
140
- {product?.ribbon?.enabled && (
141
- <RibbonBox
142
- bgColor={product?.ribbon?.color}
143
- isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
144
- isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
145
- >
146
- <OText
147
- size={10}
148
- weight={'400'}
149
- color={theme.colors.white}
150
- numberOfLines={2}
151
- ellipsizeMode='tail'
152
- lineHeight={13}
153
- >
154
- {product?.ribbon?.text}
155
- </OText>
156
- </RibbonBox>
157
- )}
158
- {product?.images ? (
159
- <FastImage
160
- style={styles.productStyle}
161
- source={{
162
- uri: optimizeImage(product?.images, 'h_250,c_limit'),
163
- priority: FastImage.priority.normal,
164
- }}
165
- resizeMode={FastImage.resizeMode.cover}
166
- />
167
- ) : (
168
- <OIcon
169
- src={theme?.images?.dummies?.product}
170
- style={styles.productStyle}
171
- />
172
- )}
173
- </LogoWrapper>
174
-
175
- {(isSoldOut || maxProductQuantity <= 0) && (
176
- <SoldOut>
177
- <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
178
- {t('SOLD_OUT', 'SOLD OUT')}
179
- </OText>
180
- </SoldOut>
282
+ </CardContainer>
283
+ ) : (
284
+ <Placeholder style={{ padding: 5 }} Animation={Fade}>
285
+ <View style={{ flexDirection: 'row' }}>
286
+ <PlaceholderLine
287
+ width={24}
288
+ height={70}
289
+ style={{ marginRight: 10, marginBottom: 10 }}
290
+ />
291
+ <Placeholder style={{ paddingVertical: 10 }}>
292
+ <PlaceholderLine width={60} style={{ marginBottom: 25 }} />
293
+ <PlaceholderLine width={20} />
294
+ </Placeholder>
295
+ </View>
296
+ </Placeholder>
181
297
  )}
182
- </CardContainer>
298
+ </InView>
183
299
  );
184
- };
300
+ }, SingleProductCardPropsAreEqual);
301
+
302
+ export const SingleProductCard = (props: SingleProductCardParams) => {
303
+ const singleProductCardProps = {
304
+ ...props,
305
+ UIComponent: SingleProductCardUI
306
+ }
307
+ return <SingleProductCardController {...singleProductCardProps} />
308
+ }
@@ -2,7 +2,7 @@ import styled, { css } from 'styled-components/native'
2
2
 
3
3
  export const CardContainer = styled.TouchableOpacity`
4
4
  flex: 1;
5
- flex-direction: row;
5
+ flex-direction: ${(props : any) => props.showAddButton ? 'column' : 'row'};
6
6
  justify-content: space-between;
7
7
  align-items: center;
8
8
  padding: 12px;
@@ -23,7 +23,7 @@ export const SoldOut = styled.View`
23
23
  `
24
24
 
25
25
  export const QuantityContainer = styled.View`
26
- background: ${({ theme } : any) => theme.colors.primary};
26
+ background: ${({ theme }: any) => theme.colors.primary};
27
27
  align-items: center;
28
28
  justify-content: center;
29
29
  `
@@ -27,7 +27,8 @@ const StripeElementsFormUI = (props: any) => {
27
27
  paymethod,
28
28
  onCancel,
29
29
  cart,
30
- merchantId
30
+ merchantId,
31
+ businessIds
31
32
  } = props;
32
33
 
33
34
  const theme = useTheme();
@@ -60,13 +61,13 @@ const StripeElementsFormUI = (props: any) => {
60
61
  }
61
62
 
62
63
  if (user?.address) {
63
- billingDetails.addressLine1 = user?.address
64
+ billingDetails.address.line1 = user?.address
64
65
  }
65
66
 
66
67
  const createPayMethod = async () => {
67
- const params: any = { type: 'Card' }
68
+ const params: any = { paymentMethodType: 'Card', paymentMethodData: {} }
68
69
  if (Object.keys(billingDetails).length > 0) {
69
- params.billingDetails = billingDetails
70
+ params.paymentMethodData.billingDetails = {...billingDetails, token: card?.last4}
70
71
  }
71
72
  try {
72
73
  setCreatePmLoading(true)
@@ -93,22 +94,29 @@ const StripeElementsFormUI = (props: any) => {
93
94
  setErrors(error?.message || error?.toString());
94
95
  }
95
96
  }
96
-
97
+
97
98
  const handleSaveCard = async () => {
98
99
  setErrors('');
99
100
  if (!requirements) {
100
101
  createPayMethod();
101
102
  return
102
103
  }
103
- const params: any = { type: 'Card' }
104
+ const params: any = { paymentMethodType: 'Card', paymentMethodData: {} }
104
105
  if (Object.keys(billingDetails).length > 0) {
105
- params.billingDetails = billingDetails
106
+ params.paymentMethodData.billingDetails = {...billingDetails, token: card?.last4}
106
107
  }
107
108
  try {
108
109
  const { setupIntent, error } = await confirmSetupIntent(requirements, params);
109
110
 
110
111
  if (setupIntent?.status === 'Succeeded') {
111
- stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
112
+ if (businessIds) {
113
+ businessIds.forEach((_businessId: any, index: any) => {
114
+ const _isNewCard = index === 0
115
+ stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId, _isNewCard);
116
+ })
117
+ } else {
118
+ stripeTokenHandler(setupIntent?.paymentMethodId, user, businessId);
119
+ }
112
120
  }
113
121
 
114
122
  if (error) {
@@ -40,7 +40,7 @@ export const StripeElementsForm = (props: any) => {
40
40
  }
41
41
  }
42
42
 
43
- const stripeTokenHandler = async (tokenId: string, user: any, businessId: string) => {
43
+ const stripeTokenHandler = async (tokenId: string, user: any, businessId: string, isNewCard: any = true) => {
44
44
  try {
45
45
  setState({
46
46
  ...state,
@@ -60,7 +60,7 @@ export const StripeElementsForm = (props: any) => {
60
60
  })
61
61
  })
62
62
  const response = await result.json();
63
- props.onSelectCard && props.onSelectCard(response.result);
63
+ isNewCard && props.onSelectCard && props.onSelectCard(response.result);
64
64
  setState({
65
65
  ...state,
66
66
  loadingAdd: false
@@ -4,7 +4,7 @@ import {
4
4
  UpsellingPage as UpsellingPageController,
5
5
  useUtils,
6
6
  useLanguage,
7
- useOrder
7
+ useOrder
8
8
  } from 'ordering-components/native'
9
9
  import { useTheme } from 'styled-components/native';
10
10
  import { OText, OIcon, OBottomPopup, OButton } from '../shared'
@@ -62,7 +62,19 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
62
62
  borderRadius: 7.6,
63
63
  borderColor: theme.colors.textSecondary,
64
64
  height: 38
65
- }
65
+ },
66
+ headerItem: {
67
+ flexDirection: 'row',
68
+ alignItems: 'center',
69
+ marginVertical: 2,
70
+ marginHorizontal: 20,
71
+ },
72
+ btnBackArrow: {
73
+ borderWidth: 0,
74
+ backgroundColor: theme.colors.clear,
75
+ shadowColor: theme.colors.clear,
76
+ padding: 40,
77
+ },
66
78
  })
67
79
 
68
80
  const [modalIsOpen, setModalIsOpen] = useState(false)
@@ -77,11 +89,11 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
77
89
  ? cart?.products.map((product: any) => product.id)
78
90
  : []
79
91
 
80
- const productsList = !upsellingProducts.loading && !upsellingProducts.error
81
- ? upsellingProducts?.products?.length
82
- ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
83
- : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
84
- : []
92
+ const productsList = !upsellingProducts.loading && !upsellingProducts.error
93
+ ? upsellingProducts?.products?.length
94
+ ? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
95
+ : (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
96
+ : []
85
97
 
86
98
  useEffect(() => {
87
99
  if (!isCustomMode && !props.products) {
@@ -95,15 +107,11 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
95
107
  }
96
108
  }, [upsellingProducts.loading, upsellingProducts?.products.length])
97
109
 
98
- useEffect(() => {
99
- isCheckout && Object.keys(cart).length === 0 && onNavigationRedirect && onNavigationRedirect('MyOrders')
100
- }, [cart, isCheckout])
101
-
102
110
  const handleFormProduct = (product: any) => {
103
- onNavigationRedirect && onNavigationRedirect('ProductDetails', {
104
- product: product,
105
- businessId: product?.api?.businessId,
106
- businessSlug: business.slug,
111
+ onNavigationRedirect && onNavigationRedirect('ProductDetails', {
112
+ product: product,
113
+ businessId: product?.api?.businessId,
114
+ businessSlug: business.slug,
107
115
  })
108
116
  }
109
117
 
@@ -119,8 +127,8 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
119
127
  !upsellingProducts.loading && (
120
128
  <>
121
129
  {
122
- !upsellingProducts.error ? productsList.map((product: any) => (
123
- <Item key={product.id}>
130
+ !upsellingProducts.error ? productsList.map((product: any, i: number) => (
131
+ <Item key={`${product.id}_${i}`}>
124
132
  <View style={{ flexBasis: '57%' }}>
125
133
  <Details>
126
134
  <OText size={12} lineHeight={18} numberOfLines={1} ellipsizeMode='tail'>{product.name}</OText>
@@ -148,50 +156,54 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
148
156
  )
149
157
  }
150
158
 
151
- const UpsellingContent = () => {
152
- return (
153
- <>
154
- <TopBar style={{ paddingTop: Platform.OS == 'ios' ? 10 : 30 }}>
155
- <TopActions onPress={() => onGoBack()}>
156
- <OIcon src={theme.images.general.arrow_left} width={15} />
157
- </TopActions>
158
- </TopBar>
159
- <ScrollView style={{ marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
159
+ const UpsellingContent = () => {
160
+ return (
161
+ <>
162
+ <View style={{ ...styles.headerItem, flex: 1, marginTop: Platform.OS == 'ios' ? 35 : 70 }}>
163
+ <OButton
164
+ imgLeftSrc={theme.images.general.arrow_left}
165
+ imgRightSrc={null}
166
+ style={styles.btnBackArrow}
167
+ onClick={() => onGoBack()}
168
+ imgLeftStyle={{ tintColor: theme.colors.textNormal, width: 16 }}
169
+ />
170
+ </View>
171
+ <ScrollView style={{ marginTop: 10, marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
160
172
  {productsList.length > 0 &&
161
- <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
162
- <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
163
- <UpsellingLayout />
164
- </View>
165
- }
166
- <View style={{ paddingHorizontal: 40 }}>
167
- <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
168
- <OrderSummary
169
- cart={cart}
170
- isCartPending={cart?.status === 2}
171
- onNavigationRedirect={onNavigationRedirect}
172
- />
173
- </View>
174
- </ScrollView>
175
- <View
176
- style={{
177
- alignItems: 'center',
178
- bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
179
- }}
180
- >
181
- <OButton
182
- imgRightSrc=''
183
- text={t('CHECKOUT', 'Checkout')}
184
- style={{...styles.closeUpsellingButton}}
185
- textStyle={{ color: theme.colors.white, fontSize: 14 }}
186
- onClick={() => {
187
- handleUpsellingPage()
188
- setIsCheckout(true)
189
- }}
190
- />
191
- </View>
192
- </>
193
- )
194
- }
173
+ <View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
174
+ <OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
175
+ <UpsellingLayout />
176
+ </View>
177
+ }
178
+ <View style={{ paddingHorizontal: 40 }}>
179
+ <OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
180
+ <OrderSummary
181
+ cart={cart}
182
+ isCartPending={cart?.status === 2}
183
+ onNavigationRedirect={onNavigationRedirect}
184
+ />
185
+ </View>
186
+ </ScrollView>
187
+ <View
188
+ style={{
189
+ alignItems: 'center',
190
+ bottom: props.isPage ? Platform.OS === 'ios' ? 0 : 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
191
+ }}
192
+ >
193
+ <OButton
194
+ imgRightSrc=''
195
+ text={t('CHECKOUT', 'Checkout')}
196
+ style={{ ...styles.closeUpsellingButton }}
197
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
198
+ onClick={() => {
199
+ handleUpsellingPage()
200
+ setIsCheckout(true)
201
+ }}
202
+ />
203
+ </View>
204
+ </>
205
+ )
206
+ }
195
207
 
196
208
  return (
197
209
  <>
@@ -199,20 +211,20 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
199
211
  <UpsellingLayout />
200
212
  ) : (
201
213
  <>
202
- {props.isPage ? (
203
- <UpsellingContent />
204
- ) : (
205
- canOpenUpselling && !modalIsOpen && (
206
- <OBottomPopup
207
- title={''}
208
- open={openUpselling}
209
- onClose={() => handleUpsellingPage()}
210
- isStatusBar
211
- >
212
- <UpsellingContent />
213
- </OBottomPopup>
214
- )
215
- )}
214
+ {props.isPage ? (
215
+ <UpsellingContent />
216
+ ) : (
217
+ canOpenUpselling && !modalIsOpen && (
218
+ <OBottomPopup
219
+ title={''}
220
+ open={openUpselling}
221
+ onClose={() => handleUpsellingPage()}
222
+ isStatusBar
223
+ >
224
+ <UpsellingContent />
225
+ </OBottomPopup>
226
+ )
227
+ )}
216
228
  </>
217
229
  )}
218
230
  </>