ordering-ui-react-native 0.15.65 → 0.15.66-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 (214) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  5. package/src/components/BusinessController/index.tsx +16 -8
  6. package/src/components/BusinessInformation/index.tsx +14 -0
  7. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  8. package/src/components/BusinessesListing/index.tsx +1 -1
  9. package/src/components/Checkout/index.tsx +23 -2
  10. package/src/components/DriverTips/index.tsx +11 -6
  11. package/src/components/LanguageSelector/index.tsx +6 -2
  12. package/src/components/LoginForm/index.tsx +120 -30
  13. package/src/components/LoginForm/styles.tsx +6 -0
  14. package/src/components/OrderDetails/index.tsx +7 -21
  15. package/src/components/PaymentOptions/index.tsx +67 -50
  16. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  17. package/src/components/ReviewDriver/index.tsx +1 -1
  18. package/src/components/ReviewOrder/index.tsx +2 -1
  19. package/src/components/ReviewProducts/index.tsx +11 -0
  20. package/src/components/SignupForm/index.tsx +145 -61
  21. package/src/components/SingleProductCard/index.tsx +16 -4
  22. package/src/components/SingleProductReview/index.tsx +1 -1
  23. package/src/components/StripeMethodForm/index.tsx +22 -24
  24. package/src/components/UpsellingProducts/index.tsx +1 -1
  25. package/src/components/UserProfileForm/index.tsx +63 -6
  26. package/src/components/UserProfileForm/styles.tsx +8 -0
  27. package/src/components/VerifyPhone/styles.tsx +1 -2
  28. package/src/components/shared/OModal.tsx +1 -1
  29. package/src/hooks/useCountdownTimer.tsx +26 -0
  30. package/src/navigators/CheckoutNavigator.tsx +6 -0
  31. package/src/navigators/HomeNavigator.tsx +12 -0
  32. package/src/pages/BusinessesListing.tsx +7 -6
  33. package/src/pages/MultiCheckout.tsx +31 -0
  34. package/src/pages/MultiOrdersDetails.tsx +27 -0
  35. package/src/pages/OrderDetails.tsx +1 -1
  36. package/src/pages/ReviewDriver.tsx +2 -2
  37. package/src/pages/ReviewOrder.tsx +2 -2
  38. package/src/pages/Sessions.tsx +22 -0
  39. package/src/theme.json +0 -1
  40. package/src/types/index.tsx +18 -11
  41. package/src/utils/index.tsx +68 -1
  42. package/themes/business/index.tsx +4 -0
  43. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  44. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  45. package/themes/business/src/components/Chat/index.tsx +42 -90
  46. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  47. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  48. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  49. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  50. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  51. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  52. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  53. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  54. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  55. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +14 -7
  56. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  57. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  58. package/themes/business/src/components/OrdersOption/index.tsx +8 -4
  59. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  60. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  61. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  62. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  63. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  64. package/themes/business/src/components/shared/OModal.tsx +41 -38
  65. package/themes/business/src/types/index.tsx +8 -2
  66. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  67. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  68. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  69. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  70. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  71. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  72. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  73. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  74. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  75. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  76. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  77. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  78. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  79. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  80. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  81. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  82. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  83. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  84. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  85. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  86. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  87. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  88. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  89. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  90. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  91. package/themes/kiosk/src/types/index.d.ts +1 -0
  92. package/themes/original/index.tsx +30 -8
  93. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  94. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  95. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  96. package/themes/original/src/components/AddressList/index.tsx +30 -18
  97. package/themes/original/src/components/AppleLogin/index.tsx +6 -8
  98. package/themes/original/src/components/BusinessBasicInformation/index.tsx +304 -158
  99. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  100. package/themes/original/src/components/BusinessController/index.tsx +168 -96
  101. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  102. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  103. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  104. package/themes/original/src/components/BusinessListingSearch/index.tsx +231 -63
  105. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  106. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  107. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  108. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  109. package/themes/original/src/components/BusinessProductsList/index.tsx +51 -52
  110. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  111. package/themes/original/src/components/BusinessProductsListing/index.tsx +318 -155
  112. package/themes/original/src/components/BusinessProductsListing/styles.tsx +32 -0
  113. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  114. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -39
  115. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  116. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +560 -0
  117. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  118. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +679 -0
  119. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  120. package/themes/original/src/components/BusinessesListing/index.tsx +99 -458
  121. package/themes/original/src/components/Cart/index.tsx +61 -42
  122. package/themes/original/src/components/Checkout/index.tsx +90 -39
  123. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  124. package/themes/original/src/components/Favorite/index.tsx +92 -0
  125. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  126. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  127. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  128. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  129. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  130. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  131. package/themes/original/src/components/Help/index.tsx +21 -4
  132. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  133. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  134. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  135. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  136. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  137. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  138. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  139. package/themes/original/src/components/Messages/index.tsx +1 -1
  140. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  141. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  142. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  143. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  144. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  145. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  146. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  147. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  148. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  149. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  150. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  151. package/themes/original/src/components/NavBar/index.tsx +4 -4
  152. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  153. package/themes/original/src/components/OrderDetails/index.tsx +150 -64
  154. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  155. package/themes/original/src/components/OrderSummary/index.tsx +6 -6
  156. package/themes/original/src/components/OrderTypeSelector/index.tsx +79 -35
  157. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  158. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  159. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  160. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  161. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  162. package/themes/original/src/components/OrdersOption/index.tsx +137 -38
  163. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  164. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  165. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  166. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  167. package/themes/original/src/components/PaymentOptions/index.tsx +58 -37
  168. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  169. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  170. package/themes/original/src/components/ProductForm/index.tsx +718 -679
  171. package/themes/original/src/components/ProductForm/styles.tsx +6 -2
  172. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  173. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  174. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  175. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  176. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  177. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  178. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  179. package/themes/original/src/components/Promotions/index.tsx +151 -133
  180. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  181. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  182. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  183. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  184. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  185. package/themes/original/src/components/SearchBar/index.tsx +13 -5
  186. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  187. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  188. package/themes/original/src/components/Sessions/index.tsx +160 -0
  189. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  190. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  191. package/themes/original/src/components/SingleOrderCard/index.tsx +275 -0
  192. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  193. package/themes/original/src/components/SingleProductCard/index.tsx +161 -88
  194. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  195. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  196. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  197. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  198. package/themes/original/src/components/UserDetails/index.tsx +15 -81
  199. package/themes/original/src/components/UserFormDetails/index.tsx +98 -66
  200. package/themes/original/src/components/UserProfile/index.tsx +11 -2
  201. package/themes/original/src/components/UserProfileForm/index.tsx +33 -22
  202. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  203. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  204. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  205. package/themes/original/src/components/Wallets/index.tsx +25 -12
  206. package/themes/original/src/components/shared/OBottomPopup.tsx +44 -13
  207. package/themes/original/src/components/shared/OButton.tsx +2 -0
  208. package/themes/original/src/components/shared/OInput.tsx +3 -2
  209. package/themes/original/src/components/shared/OModal.tsx +4 -2
  210. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  211. package/themes/original/src/types/index.tsx +187 -35
  212. package/themes/original/src/utils/index.tsx +96 -2
  213. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  214. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -0,0 +1,275 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ SingleOrderCard as SingleOrderCardController,
4
+ useUtils,
5
+ useLanguage
6
+ } from 'ordering-components/native';
7
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
8
+ import { useTheme } from 'styled-components/native';
9
+ import { OIcon, OText, OButton } from '../shared';
10
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
11
+ import { SingleOrderCardParams } from '../../types';
12
+
13
+ import {
14
+ Container,
15
+ InnerContainer,
16
+ Logo,
17
+ CardInfoWrapper,
18
+ ContentHeader,
19
+ ButtonWrapper,
20
+ ContentFooter,
21
+ UnreadMessageCounter,
22
+ Price
23
+ } from './styles';
24
+
25
+ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
26
+ const {
27
+ order,
28
+ reorderLoading,
29
+ handleReorder,
30
+ getOrderStatus,
31
+ handleFavoriteOrder,
32
+ onNavigationRedirect,
33
+ pastOrders,
34
+ isMessageView,
35
+ handleClickOrder
36
+ } = props;
37
+
38
+ const [{ parsePrice, optimizeImage, parseDate }] = useUtils();
39
+ const [, t] = useLanguage();
40
+ const theme = useTheme();
41
+
42
+ const [reorderSelected, setReorderSelected] = useState<number | null>(null);
43
+
44
+ const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12];
45
+
46
+ const styles = StyleSheet.create({
47
+ logo: {
48
+ borderRadius: 8,
49
+ width: 64,
50
+ height: 64
51
+ },
52
+ logoWrapper: {
53
+ overflow: 'hidden',
54
+ backgroundColor: 'white',
55
+ borderRadius: 8,
56
+ shadowColor: '#000000',
57
+ shadowOffset: { width: 1, height: 1 },
58
+ shadowOpacity: 0.1,
59
+ shadowRadius: 1,
60
+ elevation: 3
61
+ },
62
+ buttonText: {
63
+ color: theme.colors.primary,
64
+ fontSize: 10,
65
+ marginLeft: 2,
66
+ marginRight: 2,
67
+ },
68
+ reorderLoading: {
69
+ width: 80,
70
+ height: 40,
71
+ borderRadius: 10,
72
+ },
73
+ reorderbutton: {
74
+ height: 23,
75
+ paddingLeft: 10,
76
+ paddingRight: 10,
77
+ borderRadius: 23,
78
+ shadowOpacity: 0,
79
+ backgroundColor: theme.colors.primaryContrast,
80
+ borderWidth: 0,
81
+ },
82
+ reviewButton: {
83
+ height: 23,
84
+ maxHeight: 23,
85
+ backgroundColor: theme.colors.white,
86
+ alignItems: 'center',
87
+ justifyContent: 'center',
88
+ paddingHorizontal: 10,
89
+ borderRadius: 23,
90
+ borderWidth: 1,
91
+ borderColor: theme.colors.primaryContrast,
92
+ marginRight: 2
93
+ },
94
+ infoText: {
95
+ flexDirection: 'row',
96
+ alignItems: 'center'
97
+ }
98
+ });
99
+
100
+ const handleReorderClick = (id: number) => {
101
+ setReorderSelected(id);
102
+ handleReorder && handleReorder(id);
103
+ };
104
+
105
+ const handleClickOrderReview = (order: any) => {
106
+ if (pastOrders) {
107
+ onNavigationRedirect &&
108
+ onNavigationRedirect('ReviewOrder', {
109
+ order: {
110
+ id: order?.id,
111
+ business_id: order?.business_id,
112
+ logo: order?.business?.logo,
113
+ driver: order?.driver,
114
+ products: order?.products,
115
+ review: order?.review,
116
+ user_review: order?.user_review
117
+ },
118
+ });
119
+ return
120
+ }
121
+ if (isMessageView) {
122
+ handleClickOrder(order?.uuid)
123
+ return
124
+ }
125
+ onNavigationRedirect &&
126
+ onNavigationRedirect('OrderDetails', { orderId: order?.uuid });
127
+ };
128
+
129
+ const handleClickViewOrder = (uuid: string) => {
130
+ onNavigationRedirect &&
131
+ onNavigationRedirect('OrderDetails', { orderId: uuid });
132
+ };
133
+
134
+ const handleChangeFavorite = () => {
135
+ handleFavoriteOrder && handleFavoriteOrder(!order?.favorite)
136
+ };
137
+
138
+ return (
139
+ <Container
140
+ onPress={() => handleClickViewOrder(order?.uuid)}
141
+ activeOpacity={0.7}
142
+ >
143
+ <InnerContainer>
144
+ {!!order.business?.logo && (
145
+ <Logo style={styles.logoWrapper}>
146
+ <OIcon
147
+ url={optimizeImage(order.business?.logo, 'h_300,c_limit')}
148
+ style={styles.logo}
149
+ />
150
+ </Logo>
151
+ )}
152
+ <CardInfoWrapper>
153
+ <ContentHeader>
154
+ <View style={{ flex: 1 }}>
155
+ <OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
156
+ {order.business?.name}
157
+ </OText>
158
+ </View>
159
+ {!!!pastOrders && (
160
+ <>
161
+ {isMessageView ? (
162
+ <>
163
+ {order?.unread_count > 0 && (
164
+ <UnreadMessageCounter>
165
+ <OText size={12} color={theme.colors.primary} lineHeight={18} >
166
+ {order?.unread_count}
167
+ </OText>
168
+ </UnreadMessageCounter>
169
+ )}
170
+ </>
171
+ ) : (
172
+ <Price>
173
+ <OText size={12} lineHeight={18}>
174
+ {parsePrice(order?.summary?.total || order?.total)}
175
+ </OText>
176
+ </Price>
177
+ )}
178
+ </>
179
+ )}
180
+ {!!pastOrders && (
181
+ <ButtonWrapper>
182
+ {allowedOrderStatus.includes(parseInt(order?.status)) &&
183
+ !order.review && (
184
+ <TouchableOpacity
185
+ onPress={() => handleClickOrderReview(order)}
186
+ style={styles.reviewButton}>
187
+ <OText size={10} color={theme.colors.primary} numberOfLines={1}>
188
+ {t('REVIEW', 'Review')}
189
+ </OText>
190
+ </TouchableOpacity>
191
+ )}
192
+ {order.cart && (
193
+ <OButton
194
+ text={t('REORDER', 'Reorder')}
195
+ imgRightSrc={''}
196
+ textStyle={styles.buttonText}
197
+ style={
198
+ reorderLoading && order.id === reorderSelected
199
+ ? styles.reorderLoading
200
+ : styles.reorderbutton
201
+ }
202
+ onClick={() => handleReorderClick(order.id)}
203
+ isLoading={reorderLoading && order.id === reorderSelected}
204
+ />
205
+ )}
206
+ </ButtonWrapper>
207
+ )}
208
+ </ContentHeader>
209
+ <ContentFooter>
210
+ <View style={{ flex: 1 }}>
211
+ <View style={styles.infoText}>
212
+ {!!!pastOrders && (
213
+ <>
214
+ <OText
215
+ size={10}
216
+ space
217
+ color={theme.colors.textSecondary}
218
+ style={{ marginVertical: 3 }}
219
+ lineHeight={15}
220
+ numberOfLines={1}
221
+ >
222
+ {t('ORDER_NO', 'Order No') + '.'}
223
+ </OText>
224
+ <OText
225
+ size={10}
226
+ color={theme.colors.textSecondary}
227
+ style={{ marginVertical: 3 }}
228
+ lineHeight={15}
229
+ numberOfLines={1}
230
+ >
231
+ {order.id + ` \u2022 `}
232
+ </OText>
233
+ </>
234
+ )}
235
+ <OText
236
+ size={10}
237
+ lineHeight={15}
238
+ color={theme.colors.textSecondary}
239
+ style={{ marginVertical: 3 }}
240
+ numberOfLines={1}>
241
+ {order?.delivery_datetime_utc ? parseDate(order?.delivery_datetime_utc) : parseDate(order?.delivery_datetime, { utc: false })}
242
+ </OText>
243
+ </View>
244
+ <OText
245
+ color={theme.colors.primary}
246
+ size={10}
247
+ lineHeight={15}
248
+ numberOfLines={1}>
249
+ {getOrderStatus(order.status)?.value}
250
+ </OText>
251
+ </View>
252
+ <TouchableOpacity
253
+ onPress={handleChangeFavorite}
254
+ style={{ marginTop: 5 }}
255
+ >
256
+ <IconAntDesign
257
+ name={order?.favorite ? 'heart' : 'hearto'}
258
+ color={theme.colors.danger5}
259
+ size={16}
260
+ />
261
+ </TouchableOpacity>
262
+ </ContentFooter>
263
+ </CardInfoWrapper>
264
+ </InnerContainer>
265
+ </Container>
266
+ )
267
+ }
268
+
269
+ export const SingleOrderCard = (props: any) => {
270
+ const singleOrderCardProps = {
271
+ ...props,
272
+ UIComponent: SingleOrderCardUI
273
+ }
274
+ return <SingleOrderCardController {...singleOrderCardProps} />
275
+ }
@@ -0,0 +1,54 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.TouchableOpacity`
4
+ border-radius: 7.6px;
5
+ box-shadow: 0 1px 2px #0000001A;
6
+ margin-bottom: 10px;
7
+ padding-vertical: 5px;
8
+ `
9
+
10
+ export const InnerContainer = styled.View`
11
+ flex-direction: row;
12
+ width: 100%;
13
+ `
14
+
15
+ export const Logo = styled.View`
16
+ border-radius: 7.6px;
17
+ margin-right: 12px;
18
+ `
19
+
20
+ export const CardInfoWrapper = styled.View`
21
+ flex: 1;
22
+ `
23
+
24
+ export const ContentHeader = styled.View`
25
+ flex-direction: row;
26
+ justify-content: space-between;
27
+ `
28
+
29
+ export const ButtonWrapper = styled.View`
30
+ flex-direction: row;
31
+ align-items: center;
32
+ `
33
+
34
+ export const ContentFooter = styled.View`
35
+ flex-direction: row;
36
+ width: 100%;
37
+ `
38
+
39
+ export const UnreadMessageCounter = styled.View`
40
+ justify-content: center;
41
+ align-items: center;
42
+ margin-left: 10px;
43
+ width: 24px;
44
+ height: 24px;
45
+ border-radius: 7.6px;
46
+ background-color: ${(props: any) => props.theme.colors.primaryContrast};
47
+ `
48
+
49
+ export const Price = styled.View`
50
+ justify-content: space-between;
51
+ align-items: flex-end;
52
+ margin-left: 10px;
53
+ width: 30%;
54
+ `
@@ -1,29 +1,45 @@
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
+ useOrderingTheme,
9
+ SingleProductCard as SingleProductCardController
7
10
  } from 'ordering-components/native';
8
11
  import { useTheme } from 'styled-components/native';
9
12
  import { SingleProductCardParams } from '../../types';
10
13
  import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper } from './styles';
11
- import { StyleSheet } from 'react-native';
12
- import { OText, OIcon } from '../shared';
14
+ import { StyleSheet, View, TouchableOpacity, Image } from 'react-native';
15
+ import { InView } from 'react-native-intersection-observer'
16
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
17
+ import { OButton, OText } from '../shared';
13
18
  import FastImage from 'react-native-fast-image'
19
+ import IconAntDesign from 'react-native-vector-icons/AntDesign'
14
20
  import { shape } from '../../utils';
15
21
 
16
- export const SingleProductCard = (props: SingleProductCardParams) => {
22
+ function SingleProductCardPropsAreEqual(prevProps: any, nextProps: any) {
23
+ return JSON.stringify(prevProps.product) === JSON.stringify(nextProps.product) &&
24
+ prevProps.isSoldOut === nextProps.isSoldOut &&
25
+ prevProps.productAddedToCartLength === nextProps.productAddedToCartLength &&
26
+ prevProps.categoryState === nextProps.categoryState
27
+ }
28
+
29
+ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
17
30
  const {
18
- businessId,
19
31
  product,
20
32
  isSoldOut,
21
33
  onProductClick,
22
34
  productAddedToCartLength,
23
- style
35
+ style,
36
+ handleFavoriteProduct,
37
+ enableIntersection
24
38
  } = props;
25
39
 
26
40
  const theme = useTheme();
41
+ const [orderingTheme] = useOrderingTheme()
42
+ const hideAddButton = orderingTheme?.theme?.business_view?.components?.products?.components?.add_to_cart_button?.hidden
27
43
 
28
44
  const styles = StyleSheet.create({
29
45
  container: {
@@ -32,6 +48,11 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
32
48
  borderColor: theme.colors.border,
33
49
  marginBottom: 28,
34
50
  },
51
+ titleWrapper: {
52
+ flexDirection: 'row',
53
+ alignItems: 'center',
54
+ justifyContent: 'space-between'
55
+ },
35
56
  line18: {
36
57
  lineHeight: 18,
37
58
  },
@@ -72,7 +93,8 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
72
93
  const [, t] = useLanguage();
73
94
  const [stateConfig] = useConfig();
74
95
  const [{ parsePrice, optimizeImage }] = useUtils();
75
- const [orderState] = useOrder();
96
+ const [orderState] = useOrder()
97
+ const [isIntersectionObserver, setIsIntersectionObserver] = useState(!enableIntersection)
76
98
 
77
99
  const editMode = typeof product?.code !== 'undefined';
78
100
 
@@ -97,88 +119,139 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
97
119
  maxCartProductConfig,
98
120
  maxCartProductInventory,
99
121
  );
122
+
123
+ const handleChangeFavorite = () => {
124
+ handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
125
+ }
126
+
100
127
  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>
128
+ <InView style={{ minHeight: 140 }} triggerOnce={true} onChange={(inView: boolean) => setIsIntersectionObserver(true)}>
129
+ {isIntersectionObserver && (
130
+ <CardContainer
131
+ showAddButton={!hideAddButton}
132
+ style={[
133
+ styles.container,
134
+ (isSoldOut || maxProductQuantity <= 0) && styles.soldOutBackgroundStyle,
135
+ (style && { ...style }),
136
+ ]}
137
+ onPress={() => onProductClick?.(product)}
138
+ >
139
+ <View style={{ flexDirection: 'row' }}>
140
+ {productAddedToCartLength > 0 && (
141
+ <QuantityContainer style={[styles.quantityContainer, {
142
+ transform: [{ translateX: 10 }, { translateY: -10 }],
143
+ }]}>
144
+ <OText size={12} color={theme.colors.white}>{productAddedToCartLength.toString()}</OText>
145
+ </QuantityContainer>
146
+ )}
147
+ <CardInfo>
148
+ <View style={styles.titleWrapper}>
149
+ <OText
150
+ size={12}
151
+ weight={'500'}
152
+ numberOfLines={1}
153
+ ellipsizeMode="tail"
154
+ style={styles.line18}>
155
+ {product?.name}
156
+ </OText>
157
+ <TouchableOpacity
158
+ onPress={handleChangeFavorite}
159
+ >
160
+ <IconAntDesign
161
+ name={product?.favorite ? 'heart' : 'hearto'}
162
+ color={theme.colors.danger5}
163
+ size={18}
164
+ />
165
+ </TouchableOpacity>
166
+ </View>
167
+ <PricesContainer>
168
+ <OText color={theme.colors.primary}>{product?.price ? parsePrice(product?.price) : ''}</OText>
169
+ {product?.offer_price !== null && product?.in_offer && (
170
+ <OText style={styles.regularPriceStyle}>{product?.offer_price ? parsePrice(product?.offer_price) : ''}</OText>
171
+ )}
172
+ </PricesContainer>
173
+ <OText
174
+ size={10}
175
+ numberOfLines={2}
176
+ ellipsizeMode="tail"
177
+ color={theme.colors.textSecondary}
178
+ style={styles.line15}>
179
+ {product?.description}
180
+ </OText>
181
+ </CardInfo>
182
+ <LogoWrapper>
183
+ {product?.ribbon?.enabled && (
184
+ <RibbonBox
185
+ bgColor={product?.ribbon?.color}
186
+ isRoundRect={product?.ribbon?.shape === shape?.rectangleRound}
187
+ isCapsule={product?.ribbon?.shape === shape?.capsuleShape}
188
+ >
189
+ <OText
190
+ size={10}
191
+ weight={'400'}
192
+ color={theme.colors.white}
193
+ numberOfLines={2}
194
+ ellipsizeMode='tail'
195
+ lineHeight={13}
196
+ >
197
+ {product?.ribbon?.text}
198
+ </OText>
199
+ </RibbonBox>
200
+ )}
201
+ {product?.images ? (
202
+ <FastImage
203
+ style={styles.productStyle}
204
+ source={{
205
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
206
+ priority: FastImage.priority.normal,
207
+ }}
208
+ resizeMode={FastImage.resizeMode.cover}
209
+ />
210
+ ) : (
211
+ <FastImage
212
+ style={styles.productStyle}
213
+ source={{
214
+ uri: Image.resolveAssetSource(theme.images.dummies.product).uri,
215
+ priority: FastImage.priority.normal,
216
+ }}
217
+ resizeMode={FastImage.resizeMode.cover}
218
+ />
219
+ )}
220
+ </LogoWrapper>
221
+
222
+ {(isSoldOut || maxProductQuantity <= 0) && (
223
+ <SoldOut>
224
+ <OText size={12} weight="bold" color={theme.colors.textSecondary} style={styles.soldOutTextStyle}>
225
+ {t('SOLD_OUT', 'SOLD OUT')}
226
+ </OText>
227
+ </SoldOut>
228
+ )}
229
+ </View>
230
+ {!hideAddButton && (
231
+ <OButton
232
+ onClick={() => onProductClick?.(product)}
233
+ style={{
234
+ width: '100%',
235
+ borderRadius: 7.6,
236
+ marginTop: 10,
237
+
238
+ }}
239
+ bgColor={isSoldOut ? '#B8B8B8' : theme?.colors?.white}
240
+ borderColor={theme?.colors.primary}
241
+ textStyle={{ color: theme.colors.primary }}
242
+ text={t('ADD', 'Add')}
243
+ />
128
244
  )}
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>
245
+ </CardContainer>
181
246
  )}
182
- </CardContainer>
247
+ </InView>
183
248
  );
184
- };
249
+ }, SingleProductCardPropsAreEqual);
250
+
251
+ export const SingleProductCard = (props: SingleProductCardParams) => {
252
+ const singleProductCardProps = {
253
+ ...props,
254
+ UIComponent: SinguleProductCardUI
255
+ }
256
+ return <SingleProductCardController {...singleProductCardProps} />
257
+ }
@@ -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) {