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