ordering-ui-react-native 0.15.82 → 0.15.83-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 (216) 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 +24 -15
  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 +6 -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/theme.json +0 -1
  45. package/src/types/index.tsx +18 -11
  46. package/src/utils/index.tsx +28 -29
  47. package/themes/business/index.tsx +4 -0
  48. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +100 -60
  49. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -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/MapView/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 +17 -7
  61. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +26 -18
  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 +5 -4
  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 +13 -6
  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 +25 -26
  75. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  76. package/themes/kiosk/src/components/Cart/index.tsx +10 -11
  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 +14 -14
  86. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  87. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  88. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  89. package/themes/kiosk/src/components/PaymentOptions/index.tsx +55 -53
  90. package/themes/kiosk/src/components/ProductForm/index.tsx +6 -7
  91. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  92. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  93. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  94. package/themes/kiosk/src/types/index.d.ts +1 -0
  95. package/themes/original/index.tsx +22 -0
  96. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  97. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  98. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  99. package/themes/original/src/components/AddressList/index.tsx +1 -1
  100. package/themes/original/src/components/AppleLogin/index.tsx +6 -8
  101. package/themes/original/src/components/BusinessBasicInformation/index.tsx +291 -150
  102. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  103. package/themes/original/src/components/BusinessController/index.tsx +179 -96
  104. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  105. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  106. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  107. package/themes/original/src/components/BusinessListingSearch/index.tsx +234 -64
  108. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  109. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  110. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  111. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  112. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  113. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  114. package/themes/original/src/components/BusinessProductsList/index.tsx +65 -73
  115. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  116. package/themes/original/src/components/BusinessProductsListing/index.tsx +315 -176
  117. package/themes/original/src/components/BusinessProductsListing/styles.tsx +11 -0
  118. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  119. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -38
  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 +661 -0
  124. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  125. package/themes/original/src/components/BusinessesListing/index.tsx +104 -462
  126. package/themes/original/src/components/Cart/index.tsx +83 -38
  127. package/themes/original/src/components/Cart/styles.tsx +4 -0
  128. package/themes/original/src/components/Checkout/index.tsx +128 -67
  129. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  130. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  131. package/themes/original/src/components/Favorite/index.tsx +92 -0
  132. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  133. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  134. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  135. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  136. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  137. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  138. package/themes/original/src/components/Help/index.tsx +21 -4
  139. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  140. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  141. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  142. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  143. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  144. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  145. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  146. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  147. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  148. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  149. package/themes/original/src/components/MultiCheckout/index.tsx +304 -0
  150. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  151. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  152. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  153. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  154. package/themes/original/src/components/MyOrders/index.tsx +132 -27
  155. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  156. package/themes/original/src/components/NavBar/index.tsx +4 -4
  157. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  158. package/themes/original/src/components/OrderDetails/index.tsx +164 -64
  159. package/themes/original/src/components/OrderDetails/styles.tsx +5 -2
  160. package/themes/original/src/components/OrderItAgain/index.tsx +72 -0
  161. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  162. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  163. package/themes/original/src/components/OrderTypeSelector/index.tsx +77 -35
  164. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  165. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  166. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  167. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  168. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  169. package/themes/original/src/components/OrdersOption/index.tsx +139 -46
  170. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  171. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  172. package/themes/original/src/components/PaymentOptionWallet/index.tsx +15 -22
  173. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  174. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  175. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  176. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  177. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  178. package/themes/original/src/components/ProductForm/index.tsx +712 -673
  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 +13 -9
  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 +22 -6
  188. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  189. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  190. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  191. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  192. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  193. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  194. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  195. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  196. package/themes/original/src/components/SingleOrderCard/index.tsx +316 -0
  197. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  198. package/themes/original/src/components/SingleProductCard/index.tsx +196 -94
  199. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  200. package/themes/original/src/components/StripeElementsForm/index.tsx +25 -9
  201. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  202. package/themes/original/src/components/UpsellingProducts/index.tsx +0 -4
  203. package/themes/original/src/components/UserDetails/index.tsx +32 -18
  204. package/themes/original/src/components/UserFormDetails/index.tsx +108 -74
  205. package/themes/original/src/components/UserProfile/index.tsx +5 -1
  206. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  207. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  208. package/themes/original/src/components/Wallets/index.tsx +2 -2
  209. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  210. package/themes/original/src/components/shared/OButton.tsx +2 -0
  211. package/themes/original/src/components/shared/OInput.tsx +3 -2
  212. package/themes/original/src/components/shared/OModal.tsx +4 -2
  213. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  214. package/themes/original/src/types/index.tsx +208 -44
  215. package/themes/original/src/utils/index.tsx +94 -1
  216. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,34 +1,46 @@
1
- import React from 'react';
1
+ import React, { useState } 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
32
44
 
33
45
  const styles = StyleSheet.create({
34
46
  container: {
@@ -36,6 +48,12 @@ export const SingleProductCard = React.memo((props: SingleProductCardParams) =>
36
48
  borderRadius: 7.6,
37
49
  borderColor: theme.colors.border,
38
50
  marginBottom: 28,
51
+ minHeight: hideAddButton ? 100 : 165
52
+ },
53
+ titleWrapper: {
54
+ flexDirection: 'row',
55
+ alignItems: 'center',
56
+ justifyContent: 'space-between'
39
57
  },
40
58
  line18: {
41
59
  lineHeight: 18,
@@ -56,8 +74,8 @@ export const SingleProductCard = React.memo((props: SingleProductCardParams) =>
56
74
  },
57
75
  quantityContainer: {
58
76
  position: 'absolute',
59
- left: '100%',
60
- bottom: '100%',
77
+ right: 0,
78
+ top: 0,
61
79
  width: 25,
62
80
  height: 25,
63
81
  textAlign: 'center',
@@ -73,11 +91,12 @@ export const SingleProductCard = React.memo((props: SingleProductCardParams) =>
73
91
  }
74
92
  });
75
93
 
76
-
77
94
  const [, t] = useLanguage();
78
95
  const [stateConfig] = useConfig();
79
- const [{ parsePrice, optimizeImage }] = useUtils();
80
- const [orderState] = useOrder();
96
+ const [{ auth }] = useSession()
97
+ const [{ parsePrice, optimizeImage, parseDate }] = useUtils();
98
+ const [orderState] = useOrder()
99
+ const [isIntersectionObserver, setIsIntersectionObserver] = useState(!enableIntersection)
81
100
 
82
101
  const editMode = typeof product?.code !== 'undefined';
83
102
 
@@ -102,88 +121,171 @@ export const SingleProductCard = React.memo((props: SingleProductCardParams) =>
102
121
  maxCartProductConfig,
103
122
  maxCartProductInventory,
104
123
  );
124
+
125
+ const handleChangeFavorite = () => {
126
+ if (auth) {
127
+ handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
128
+ } else {
129
+ navigation && navigation.navigate('Login');
130
+ }
131
+ }
132
+
133
+ const handleChangeIntersection = () => {
134
+ if (enableIntersection) {
135
+ setIsIntersectionObserver(true);
136
+ }
137
+ }
138
+
105
139
  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>
140
+ <InView style={{ minHeight: hideAddButton ? 125 : 165 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
141
+ {isIntersectionObserver ? (
142
+ <CardContainer
143
+ showAddButton={!hideAddButton}
144
+ style={[
145
+ styles.container,
146
+ (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
147
+ (style && { ...style }),
148
+ ]}
149
+ onPress={() => onProductClick?.(product)}
150
+ >
151
+ <View style={{ flexDirection: 'row' }}>
152
+ {productAddedToCartLength > 0 && (
153
+ <QuantityContainer style={[styles.quantityContainer, {
154
+ transform: [{ translateX: 25 }, { translateY: hideAddButton ? -25 : -55 }],
155
+ }]}>
156
+ <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
157
+ </QuantityContainer>
158
+ )}
159
+ <CardInfo>
160
+ <View style={styles.titleWrapper}>
161
+ <OText
162
+ size={12}
163
+ weight={'500'}
164
+ numberOfLines={1}
165
+ ellipsizeMode="tail"
166
+ style={{ ...styles.line18, flex: 1 }}>
167
+ {product?.name}
168
+ </OText>
169
+ {!isPreviously && (
170
+ <TouchableOpacity
171
+ onPress={handleChangeFavorite}
172
+ >
173
+ <IconAntDesign
174
+ name={product?.favorite ? 'heart' : 'hearto'}
175
+ color={theme.colors.danger5}
176
+ size={18}
177
+ />
178
+ </TouchableOpacity>
179
+ )}
180
+ </View>
181
+ <PricesContainer>
182
+ <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
183
+ {product?.offer_price !== null && product?.in_offer && (
184
+ <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
185
+ )}
186
+ </PricesContainer>
187
+ <OText
188
+ size={10}
189
+ numberOfLines={!isPreviously ? 2 : 1}
190
+ ellipsizeMode="tail"
191
+ color={theme.colors.textSecondary}
192
+ style={styles.line15}>
193
+ {product?.description}
194
+ </OText>
195
+ {isPreviously && (
196
+ <OText
197
+ size={10}
198
+ numberOfLines={1}
199
+ ellipsizeMode="tail"
200
+ color={theme.colors.primary}
201
+ style={styles.line15}>
202
+ {t('LAST_ORDERED_ON', 'Last ordered on')} {parseDate(product?.last_ordered_date, { outputFormat: 'MMM DD, YYYY' })}
203
+ </OText>
204
+ )}
205
+ </CardInfo>
206
+ <LogoWrapper>
207
+ {product?.ribbon?.enabled && (
208
+ <RibbonBox
209
+ bgColor={product?.ribbon?.color}
210
+ isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
211
+ isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
212
+ >
213
+ <OText
214
+ size={10}
215
+ weight={'400'}
216
+ color={theme.colors.white}
217
+ numberOfLines={2}
218
+ ellipsizeMode='tail'
219
+ lineHeight={13}
220
+ >
221
+ {product?.ribbon?.text}
222
+ </OText>
223
+ </RibbonBox>
224
+ )}
225
+ {product?.images && (
226
+ <FastImage
227
+ style={styles.productStyle}
228
+ source={{
229
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
230
+ priority: FastImage.priority.normal,
231
+ }}
232
+ resizeMode={FastImage.resizeMode.cover}
233
+ />
234
+ )}
235
+ </LogoWrapper>
236
+
237
+ {(isSoldOut || maxProductQuantity <= 0) && (
238
+ <SoldOut>
239
+ <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
240
+ {t('SOLD_OUT', 'SOLD OUT')}
241
+ </OText>
242
+ </SoldOut>
243
+ )}
244
+ </View>
245
+ {!hideAddButton && (
246
+ <OButton
247
+ onClick={() => onProductClick?.(product)}
248
+ style={{
249
+ width: '100%',
250
+ borderRadius: 7.6,
251
+ marginTop: 10,
252
+
253
+ }}
254
+ bgColor={isSoldOut ? '#B8B8B8' : theme?.colors?.white}
255
+ borderColor={theme?.colors.primary}
256
+ textStyle={{ color: theme.colors.primary }}
257
+ text={t('ADD', 'Add')}
258
+ />
133
259
  )}
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>
260
+ </CardContainer>
261
+ ) : (
262
+ <View style={{ marginBottom: 28, padding: 12, height: hideAddButton ? 125 : 165 }}>
263
+ <Placeholder style={{ padding: 5 }} Animation={Fade}>
264
+ <View style={{ flexDirection: 'row' }}>
265
+ <Placeholder style={{ paddingVertical: 10, flex: 1 }}>
266
+ <PlaceholderLine width={60} style={{ marginBottom: 15 }} />
267
+ <PlaceholderLine width={20} />
268
+ </Placeholder>
269
+ <PlaceholderLine
270
+ width={24}
271
+ height={70}
272
+ style={{ marginLeft: 10, marginBottom: 10 }}
273
+ />
274
+ </View>
275
+ <PlaceholderLine
276
+ height={52}
277
+ />
278
+ </Placeholder>
279
+ </View>
186
280
  )}
187
- </CardContainer>
281
+ </InView>
188
282
  );
189
283
  }, SingleProductCardPropsAreEqual);
284
+
285
+ export const SingleProductCard = (props: SingleProductCardParams) => {
286
+ const singleProductCardProps = {
287
+ ...props,
288
+ UIComponent: SingleProductCardUI
289
+ }
290
+ return <SingleProductCardController {...singleProductCardProps} />
291
+ }
@@ -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,
@@ -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} />