ordering-ui-react-native 0.15.27 → 0.15.28-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.
- package/package.json +3 -2
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessController/index.tsx +8 -2
- package/src/components/BusinessTypeFilter/index.tsx +4 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +23 -3
- package/src/components/DriverTips/index.tsx +11 -6
- package/src/components/LanguageSelector/index.tsx +7 -2
- package/src/components/OrderDetails/index.tsx +2 -2
- package/src/components/PaymentOptions/index.tsx +9 -16
- package/src/components/PaymentOptionsWebView/index.tsx +123 -124
- package/src/components/SingleProductCard/index.tsx +16 -4
- package/src/components/StripeElementsForm/index.tsx +27 -48
- package/src/components/UpsellingProducts/index.tsx +1 -1
- package/src/components/UserProfileForm/index.tsx +63 -6
- package/src/components/UserProfileForm/styles.tsx +8 -0
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OModal.tsx +1 -1
- package/src/config.json +0 -2
- package/src/hooks/useCountdownTimer.tsx +26 -0
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/BusinessProductsList.tsx +1 -0
- package/src/pages/BusinessesListing.tsx +1 -1
- package/src/pages/Checkout.tsx +1 -1
- package/src/pages/Sessions.tsx +22 -0
- package/src/types/index.tsx +5 -11
- package/src/utils/index.tsx +68 -1
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
- package/themes/business/src/components/Chat/index.tsx +38 -86
- package/themes/business/src/components/DriverMap/index.tsx +6 -5
- package/themes/business/src/components/Home/index.tsx +128 -55
- package/themes/business/src/components/Home/styles.tsx +8 -1
- package/themes/business/src/components/LoginForm/index.tsx +89 -2
- package/themes/business/src/components/LoginForm/styles.tsx +6 -0
- package/themes/business/src/components/LogoutButton/index.tsx +1 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
- package/themes/business/src/components/OrderDetails/Business.tsx +2 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +151 -89
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
- package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
- package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
- package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
- package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
- package/themes/business/src/components/OrdersOption/index.tsx +58 -51
- package/themes/business/src/components/PreviousOrders/index.tsx +75 -22
- package/themes/business/src/components/shared/OModal.tsx +1 -1
- package/themes/business/src/types/index.tsx +5 -1
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/Cart/index.tsx +98 -24
- package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
- package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
- package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
- package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
- package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
- package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
- package/themes/kiosk/src/components/Intro/index.tsx +13 -13
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderDetails/index.tsx +136 -41
- package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
- package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
- package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
- package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
- package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +178 -1
- package/themes/original/src/components/AddressForm/index.tsx +15 -10
- package/themes/original/src/components/AddressList/index.tsx +56 -18
- package/themes/original/src/components/AppleLogin/index.tsx +117 -78
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
- package/themes/original/src/components/BusinessController/index.tsx +52 -22
- package/themes/original/src/components/BusinessController/styles.tsx +22 -0
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +121 -7
- package/themes/original/src/components/BusinessListingSearch/styles.tsx +14 -1
- package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
- package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
- package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
- package/themes/original/src/components/BusinessProductsList/index.tsx +132 -35
- package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +118 -37
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
- package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +53 -60
- package/themes/original/src/components/Cart/index.tsx +21 -17
- package/themes/original/src/components/CartContent/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +58 -45
- package/themes/original/src/components/DriverTips/index.tsx +17 -12
- package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
- package/themes/original/src/components/GoogleMap/index.tsx +1 -0
- package/themes/original/src/components/Help/index.tsx +21 -4
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LastOrders/index.tsx +12 -1
- package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
- package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
- package/themes/original/src/components/LoginForm/index.tsx +389 -156
- package/themes/original/src/components/LoginForm/styles.tsx +7 -4
- package/themes/original/src/components/LogoutButton/index.tsx +7 -1
- package/themes/original/src/components/MessageListing/index.tsx +10 -1
- package/themes/original/src/components/Messages/index.tsx +34 -25
- package/themes/original/src/components/Messages/styles.tsx +1 -3
- package/themes/original/src/components/MomentOption/index.tsx +10 -1
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +56 -33
- package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
- package/themes/original/src/components/OrderProgress/index.tsx +4 -4
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
- package/themes/original/src/components/OrderSummary/index.tsx +3 -3
- package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
- package/themes/original/src/components/OrdersOption/index.tsx +55 -58
- package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
- package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
- package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +9 -19
- package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
- package/themes/original/src/components/PreviousOrders/index.tsx +16 -14
- package/themes/original/src/components/ProductForm/index.tsx +76 -61
- package/themes/original/src/components/ProductForm/styles.tsx +2 -2
- package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
- package/themes/original/src/components/Promotions/index.tsx +250 -0
- package/themes/original/src/components/Promotions/styles.tsx +60 -0
- package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/SearchBar/index.tsx +4 -1
- package/themes/original/src/components/Sessions/index.tsx +160 -0
- package/themes/original/src/components/Sessions/styles.tsx +15 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
- package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
- package/themes/original/src/components/TaxInformation/index.tsx +10 -4
- package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
- package/themes/original/src/components/UserDetails/index.tsx +4 -95
- package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
- package/themes/original/src/components/UserProfile/index.tsx +62 -14
- package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
- package/themes/original/src/components/UserVerification/index.tsx +178 -192
- package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
- package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
- package/themes/original/src/components/Wallets/index.tsx +76 -9
- package/themes/original/src/components/Wallets/styles.tsx +21 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
- package/themes/original/src/components/shared/OModal.tsx +1 -1
- package/themes/original/src/components/shared/index.tsx +2 -0
- package/themes/original/src/config/constants.tsx +6 -6
- package/themes/original/src/types/index.tsx +68 -6
- package/themes/original/src/utils/index.tsx +28 -2
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/StripeMethodForm/index.tsx +0 -168
|
@@ -2,14 +2,14 @@ import React, { useState, useEffect } from 'react'
|
|
|
2
2
|
import { OrderList, useLanguage, useOrder, ToastType, useToast } from 'ordering-components/native'
|
|
3
3
|
import { useTheme } from 'styled-components/native';
|
|
4
4
|
import { useFocusEffect } from '@react-navigation/native'
|
|
5
|
-
import { OText
|
|
5
|
+
import { OText } from '../shared'
|
|
6
6
|
import { NotFoundSource } from '../NotFoundSource'
|
|
7
7
|
import { ActiveOrders } from '../ActiveOrders'
|
|
8
8
|
import { PreviousOrders } from '../PreviousOrders'
|
|
9
9
|
|
|
10
|
-
import { OptionTitle
|
|
10
|
+
import { OptionTitle } from './styles'
|
|
11
11
|
import { OrdersOptionParams } from '../../types'
|
|
12
|
-
|
|
12
|
+
import { _setStoreData } from '../../providers/StoreUtil';
|
|
13
13
|
import {
|
|
14
14
|
Placeholder,
|
|
15
15
|
PlaceholderLine,
|
|
@@ -33,13 +33,17 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
33
33
|
loadMoreOrders,
|
|
34
34
|
loadOrders,
|
|
35
35
|
setOrdersLength,
|
|
36
|
-
ordersLength
|
|
36
|
+
ordersLength,
|
|
37
|
+
refreshOrders,
|
|
38
|
+
setRefreshOrders,
|
|
39
|
+
reorderState,
|
|
40
|
+
handleReorder
|
|
37
41
|
} = props
|
|
38
42
|
|
|
39
43
|
const theme = useTheme();
|
|
40
44
|
|
|
41
45
|
const [, t] = useLanguage()
|
|
42
|
-
const [
|
|
46
|
+
const [{ carts }] = useOrder()
|
|
43
47
|
const { showToast } = useToast()
|
|
44
48
|
const { loading, error, orders: values } = orderList
|
|
45
49
|
|
|
@@ -49,26 +53,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
49
53
|
|
|
50
54
|
const orders = customArray || values || []
|
|
51
55
|
|
|
52
|
-
const [reorderLoading, setReorderLoading] = useState(false)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const handleReorder = async (orderId: number) => {
|
|
56
|
-
setReorderLoading(true)
|
|
57
|
-
try {
|
|
58
|
-
const { error, result } = await reorder(orderId)
|
|
59
|
-
if (!error) {
|
|
60
|
-
onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: result.uuid })
|
|
61
|
-
setReorderLoading(false)
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
setReorderLoading(false)
|
|
65
|
-
|
|
66
|
-
} catch (err: any) {
|
|
67
|
-
showToast(ToastType.Error, t('ERROR', err.message))
|
|
68
|
-
setReorderLoading(false)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
56
|
const getOrderStatus = (s: string) => {
|
|
73
57
|
const status = parseInt(s)
|
|
74
58
|
const orderStatus = [
|
|
@@ -95,7 +79,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
95
79
|
{ key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Customer almost arrived to business') },
|
|
96
80
|
{ key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Customer arrived to business') },
|
|
97
81
|
{ key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', 'Looking for driver') },
|
|
98
|
-
|
|
82
|
+
{ key: 23, value: t('ORDER_DRIVER_ON_WAY', 'Driver on way') }
|
|
99
83
|
]
|
|
100
84
|
|
|
101
85
|
const objectStatus = orderStatus.find((o) => o.key === status)
|
|
@@ -103,11 +87,34 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
103
87
|
return objectStatus && objectStatus
|
|
104
88
|
}
|
|
105
89
|
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const _businessId = 'businessId:' + reorderState?.result?.business_id
|
|
92
|
+
if (reorderState?.error) {
|
|
93
|
+
if (reorderState?.result?.business_id) {
|
|
94
|
+
_setStoreData('adjust-cart-products', JSON.stringify(_businessId))
|
|
95
|
+
navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!reorderState?.error && reorderState.loading === false && reorderState?.result?.business_id) {
|
|
99
|
+
const cartProducts = carts?.[_businessId]?.products
|
|
100
|
+
const available = cartProducts.every((product: any) => product.valid === true)
|
|
101
|
+
const orderProducts = orders.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
|
|
102
|
+
|
|
103
|
+
if (available && reorderState?.result?.uuid && (cartProducts?.length === orderProducts?.length)) {
|
|
104
|
+
onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
|
|
105
|
+
} else {
|
|
106
|
+
_setStoreData('adjust-cart-products', JSON.stringify(_businessId))
|
|
107
|
+
cartProducts?.length !== orderProducts?.length && _setStoreData('already-removed', JSON.stringify('removed'))
|
|
108
|
+
navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, [reorderState])
|
|
112
|
+
|
|
106
113
|
useFocusEffect(
|
|
107
114
|
React.useCallback(() => {
|
|
108
|
-
loadOrders()
|
|
115
|
+
loadOrders(false, false, false, true)
|
|
109
116
|
}, [navigation])
|
|
110
|
-
|
|
117
|
+
)
|
|
111
118
|
|
|
112
119
|
useEffect(() => {
|
|
113
120
|
const hasMore = pagination?.totalPages && pagination?.currentPage !== pagination?.totalPages
|
|
@@ -128,23 +135,16 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
128
135
|
}
|
|
129
136
|
}, [orders, activeOrders])
|
|
130
137
|
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if(refreshOrders){
|
|
140
|
+
loadOrders(false, false, false, true)
|
|
141
|
+
setRefreshOrders && setRefreshOrders(false)
|
|
142
|
+
}
|
|
143
|
+
}, [refreshOrders])
|
|
144
|
+
|
|
131
145
|
return (
|
|
132
146
|
<>
|
|
133
|
-
{
|
|
134
|
-
<NoOrdersWrapper>
|
|
135
|
-
<OText size={14} numberOfLines={1}>
|
|
136
|
-
{t('YOU_DONT_HAVE_ORDERS', 'You don\'t have any orders')}
|
|
137
|
-
</OText>
|
|
138
|
-
<OButton
|
|
139
|
-
text={t('ORDER_NOW', 'Order now')}
|
|
140
|
-
onClick={() => onNavigationRedirect && onNavigationRedirect('BusinessList')}
|
|
141
|
-
textStyle={{ color: 'white', fontSize: 14 }}
|
|
142
|
-
style={{ borderRadius: 7.6, marginBottom: 10, marginTop: 10, height: 44, paddingLeft: 10, paddingRight: 10 }}
|
|
143
|
-
/>
|
|
144
|
-
|
|
145
|
-
</NoOrdersWrapper>
|
|
146
|
-
)}
|
|
147
|
-
{(ordersLength.activeOrdersLength > 0 || ordersLength.previousOrdersLength > 0) && (
|
|
147
|
+
{(orders.length > 0) && (
|
|
148
148
|
<>
|
|
149
149
|
<OptionTitle>
|
|
150
150
|
<OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={10} >
|
|
@@ -155,18 +155,15 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
155
155
|
: t('PAST', 'Past'))}
|
|
156
156
|
</OText>
|
|
157
157
|
</OptionTitle>
|
|
158
|
-
{!(ordersLength.activeOrdersLength === 0 && ordersLength.previousOrdersLength === 0) &&
|
|
159
|
-
!loading &&
|
|
160
|
-
orders.filter((order: any) => orderStatus.includes(order.status)).length === 0 &&
|
|
161
|
-
(
|
|
162
|
-
<NotFoundSource
|
|
163
|
-
content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
|
|
164
|
-
image={imageFails}
|
|
165
|
-
conditioned
|
|
166
|
-
/>
|
|
167
|
-
)}
|
|
168
158
|
</>
|
|
169
159
|
)}
|
|
160
|
+
{!loading && orders.length === 0 && (
|
|
161
|
+
<NotFoundSource
|
|
162
|
+
content={t('NO_RESULTS_FOUND', 'Sorry, no results found')}
|
|
163
|
+
image={imageFails}
|
|
164
|
+
conditioned
|
|
165
|
+
/>
|
|
166
|
+
)}
|
|
170
167
|
{loading && (
|
|
171
168
|
<>
|
|
172
169
|
{!activeOrders ? (
|
|
@@ -204,7 +201,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
204
201
|
orders={orders.filter((order: any) => orderStatus.includes(order.status))}
|
|
205
202
|
pagination={pagination}
|
|
206
203
|
loadMoreOrders={loadMoreOrders}
|
|
207
|
-
reorderLoading={
|
|
204
|
+
reorderLoading={reorderState?.loading}
|
|
208
205
|
customArray={customArray}
|
|
209
206
|
getOrderStatus={getOrderStatus}
|
|
210
207
|
onNavigationRedirect={onNavigationRedirect}
|
|
@@ -213,14 +210,14 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
213
210
|
<ActiveOrders
|
|
214
211
|
orders={orders.filter((order: any) => orderStatus.includes(order.status))}
|
|
215
212
|
pagination={pagination}
|
|
216
|
-
reorderLoading={
|
|
213
|
+
reorderLoading={reorderState?.loading}
|
|
217
214
|
customArray={customArray}
|
|
218
215
|
getOrderStatus={getOrderStatus}
|
|
219
216
|
onNavigationRedirect={onNavigationRedirect}
|
|
220
217
|
/>
|
|
221
218
|
) : (
|
|
222
219
|
<PreviousOrders
|
|
223
|
-
reorderLoading={
|
|
220
|
+
reorderLoading={reorderState?.loading}
|
|
224
221
|
orders={orders.filter((order: any) => orderStatus.includes(order.status)).sort((a: any, b: any) => a?.id < b?.id)}
|
|
225
222
|
pagination={pagination}
|
|
226
223
|
loadMoreOrders={loadMoreOrders}
|
|
@@ -239,8 +236,8 @@ export const OrdersOption = (props: OrdersOptionParams) => {
|
|
|
239
236
|
...props,
|
|
240
237
|
UIComponent: OrdersOptionUI,
|
|
241
238
|
orderStatus: props.preOrders ? [13] : props.activeOrders
|
|
242
|
-
? [0, 3, 4, 7, 8, 9, 14,
|
|
243
|
-
: [1, 2, 5, 6, 10, 11, 12, 16, 17],
|
|
239
|
+
? [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23]
|
|
240
|
+
: [1, 2, 5, 6, 10, 11, 12, 15, 16, 17],
|
|
244
241
|
useDefualtSessionManager: true,
|
|
245
242
|
}
|
|
246
243
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { View } from 'react-native'
|
|
3
3
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
4
4
|
import { useTheme } from 'styled-components/native'
|
|
5
|
-
import
|
|
5
|
+
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
6
6
|
import {
|
|
7
7
|
PaymentOptionWallet as PaymentOptionWalletController,
|
|
8
8
|
useLanguage,
|
|
@@ -20,6 +20,7 @@ import { OText } from '../shared'
|
|
|
20
20
|
|
|
21
21
|
const PaymentOptionWalletUI = (props: any) => {
|
|
22
22
|
const {
|
|
23
|
+
businessConfigs,
|
|
23
24
|
businessId,
|
|
24
25
|
walletsState,
|
|
25
26
|
selectWallet,
|
|
@@ -37,12 +38,8 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
37
38
|
const isWalletCashEnabled = configs?.wallet_cash_enabled?.value === '1'
|
|
38
39
|
const isWalletPointsEnabled = configs?.wallet_credit_point_enabled?.value === '1'
|
|
39
40
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
width: 25,
|
|
43
|
-
height: 25,
|
|
44
|
-
}
|
|
45
|
-
});
|
|
41
|
+
const isBusinessWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
|
|
42
|
+
const isBusinessWalletPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
|
|
46
43
|
|
|
47
44
|
const [checkedState, setCheckedState] = useState(
|
|
48
45
|
new Array(walletsState.result?.length).fill(false)
|
|
@@ -53,11 +50,11 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
53
50
|
const walletName: any = {
|
|
54
51
|
cash: {
|
|
55
52
|
name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
|
|
56
|
-
isActive: isWalletCashEnabled
|
|
53
|
+
isActive: isWalletCashEnabled && isBusinessWalletCashEnabled
|
|
57
54
|
},
|
|
58
55
|
credit_point: {
|
|
59
56
|
name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
|
|
60
|
-
isActive: isWalletPointsEnabled
|
|
57
|
+
isActive: isWalletPointsEnabled && isBusinessWalletPointsEnabled
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
|
|
@@ -96,22 +93,23 @@ const PaymentOptionWalletUI = (props: any) => {
|
|
|
96
93
|
<Container
|
|
97
94
|
key={wallet.id}
|
|
98
95
|
isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
|
|
96
|
+
onPress={() => handleOnChange(idx, wallet)}
|
|
97
|
+
disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
|
|
99
98
|
>
|
|
100
99
|
<SectionLeft>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
/>
|
|
100
|
+
{checkedState[idx] ? (
|
|
101
|
+
<MaterialCommunityIcons
|
|
102
|
+
name="checkbox-marked"
|
|
103
|
+
size={25}
|
|
104
|
+
color={theme.colors.primary}
|
|
105
|
+
/>
|
|
106
|
+
) : (
|
|
107
|
+
<MaterialCommunityIcons
|
|
108
|
+
name="checkbox-blank-outline"
|
|
109
|
+
size={25}
|
|
110
|
+
color={theme.colors.disabled}
|
|
111
|
+
/>
|
|
112
|
+
)}
|
|
115
113
|
<View style={{ alignItems: 'baseline', marginLeft: 5 }}>
|
|
116
114
|
<View>
|
|
117
115
|
<OText
|
|
@@ -32,8 +32,6 @@ import {
|
|
|
32
32
|
import { getIconCard, flatArray } from '../../utils';
|
|
33
33
|
|
|
34
34
|
const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
|
|
35
|
-
const methodsPay = ['google_pay', 'apple_pay']
|
|
36
|
-
const stripeDirectMethods = ['stripe_direct', ...methodsPay]
|
|
37
35
|
// const stripeRedirectOptions = [
|
|
38
36
|
// { name: 'Bancontact', value: 'bancontact' },
|
|
39
37
|
// { name: 'Alipay', value: 'alipay' },
|
|
@@ -56,8 +54,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
56
54
|
handlePaymethodClick,
|
|
57
55
|
handlePaymethodDataChange,
|
|
58
56
|
isOpenMethod,
|
|
59
|
-
handlePaymentMethodClickCustom
|
|
60
|
-
handlePlaceOrder
|
|
57
|
+
handlePaymentMethodClickCustom
|
|
61
58
|
} = props
|
|
62
59
|
|
|
63
60
|
const theme = useTheme();
|
|
@@ -125,16 +122,12 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
125
122
|
|
|
126
123
|
useEffect(() => {
|
|
127
124
|
if (props.paySelected && props.paySelected?.data) {
|
|
128
|
-
|
|
125
|
+
requestAnimationFrame(() => {
|
|
126
|
+
setPaymethodData && setPaymethodData(props.paySelected?.data)
|
|
127
|
+
})
|
|
129
128
|
}
|
|
130
129
|
}, [props.paySelected])
|
|
131
130
|
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
|
|
134
|
-
handlePlaceOrder()
|
|
135
|
-
}
|
|
136
|
-
}, [paymethodData, paymethodSelected])
|
|
137
|
-
|
|
138
131
|
const renderPaymethods = ({ item }: any) => {
|
|
139
132
|
return (
|
|
140
133
|
<TouchableOpacity
|
|
@@ -163,7 +156,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
163
156
|
)
|
|
164
157
|
}
|
|
165
158
|
|
|
166
|
-
const excludeIds: any = [32]; //exclude paypal & connect & redirect
|
|
159
|
+
const excludeIds: any = [32, 66]; //exclude paypal & connect & redirect
|
|
167
160
|
|
|
168
161
|
return (
|
|
169
162
|
<PMContainer>
|
|
@@ -296,11 +289,11 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
296
289
|
</KeyboardAvoidingView>
|
|
297
290
|
</OModal>
|
|
298
291
|
|
|
299
|
-
{/* Stripe direct
|
|
292
|
+
{/* Stripe direct */}
|
|
300
293
|
<OModal
|
|
301
294
|
entireModal
|
|
302
295
|
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
303
|
-
open={
|
|
296
|
+
open={isOpenMethod?.paymethod?.gateway === 'stripe_direct' && !paymethodData?.id}
|
|
304
297
|
onClose={() => handlePaymethodClick(null)}
|
|
305
298
|
>
|
|
306
299
|
<KeyboardAvoidingView
|
|
@@ -309,13 +302,10 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
309
302
|
enabled={Platform.OS === 'ios' ? true : false}
|
|
310
303
|
>
|
|
311
304
|
<StripeElementsForm
|
|
312
|
-
cart={cart}
|
|
313
|
-
paymethod={isOpenMethod?.paymethod?.gateway}
|
|
314
|
-
methodsPay={methodsPay}
|
|
315
305
|
businessId={props.businessId}
|
|
316
|
-
publicKey={isOpenMethod?.paymethod?.credentials?.publishable
|
|
306
|
+
publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
|
|
317
307
|
handleSource={handlePaymethodDataChange}
|
|
318
|
-
onCancel={() => handlePaymethodClick(
|
|
308
|
+
onCancel={() => handlePaymethodClick(false)}
|
|
319
309
|
/>
|
|
320
310
|
</KeyboardAvoidingView>
|
|
321
311
|
</OModal>
|
|
@@ -58,7 +58,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
useEffect(() => {
|
|
61
|
-
if ((defaultValue && userphoneNumber) || defaultValue
|
|
61
|
+
if ((defaultValue && userphoneNumber) || !defaultValue) {
|
|
62
62
|
if (userphoneNumber) {
|
|
63
63
|
const checkValid = phoneInput.current?.isValidNumber(userphoneNumber);
|
|
64
64
|
const callingCode = phoneInput.current?.getCallingCode();
|
|
@@ -85,7 +85,7 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
|
|
|
85
85
|
order: {
|
|
86
86
|
id: order?.id,
|
|
87
87
|
business_id: order?.business_id,
|
|
88
|
-
logo: order
|
|
88
|
+
logo: order?.business?.logo,
|
|
89
89
|
driver: order?.driver,
|
|
90
90
|
products: order?.products,
|
|
91
91
|
review: order?.review,
|
|
@@ -100,7 +100,7 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
|
|
|
100
100
|
|
|
101
101
|
const handleReorderClick = (id: number) => {
|
|
102
102
|
setReorderSelected(id);
|
|
103
|
-
handleReorder(id);
|
|
103
|
+
handleReorder && handleReorder(id);
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
return (
|
|
@@ -143,18 +143,20 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
|
|
|
143
143
|
</OText>
|
|
144
144
|
</Information>
|
|
145
145
|
<Status>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
{order.cart && (
|
|
147
|
+
<OButton
|
|
148
|
+
text={t('REORDER', 'Reorder')}
|
|
149
|
+
imgRightSrc={''}
|
|
150
|
+
textStyle={styles.buttonText}
|
|
151
|
+
style={
|
|
152
|
+
reorderLoading && order.id === reorderSelected
|
|
153
|
+
? styles.reorderLoading
|
|
154
|
+
: styles.reorderbutton
|
|
155
|
+
}
|
|
156
|
+
onClick={() => handleReorderClick(order.id)}
|
|
157
|
+
isLoading={reorderLoading && order.id === reorderSelected}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
158
160
|
{allowedOrderStatus.includes(parseInt(order?.status)) &&
|
|
159
161
|
!order.review && (
|
|
160
162
|
<TouchableOpacity
|
|
@@ -46,7 +46,6 @@ import { ProductOptionSubOption } from '../ProductOptionSubOption';
|
|
|
46
46
|
import { NotFoundSource } from '../NotFoundSource';
|
|
47
47
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
48
48
|
import { useState } from 'react';
|
|
49
|
-
|
|
50
49
|
const windowHeight = Dimensions.get('window').height;
|
|
51
50
|
const windowWidth = Dimensions.get('window').width;
|
|
52
51
|
|
|
@@ -176,6 +175,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
176
175
|
const [optionLayout, setOptionLayout] = useState<any>({})
|
|
177
176
|
const [headerRefHeight, setHeaderRefHeight] = useState(0)
|
|
178
177
|
const [summaryRefHeight, setSummaryRefHeight] = useState(0)
|
|
178
|
+
const [isScrollAvailable, setIsScrollAvailable] = useState(null)
|
|
179
179
|
|
|
180
180
|
const isError = (id: number) => {
|
|
181
181
|
let bgColor = theme.colors.white;
|
|
@@ -279,39 +279,6 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
279
279
|
setOptionLayout(_optionLayout)
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
useEffect(() => {
|
|
283
|
-
const imageList: any = []
|
|
284
|
-
const videoList: any = []
|
|
285
|
-
product?.images && imageList.push(product.images)
|
|
286
|
-
if (product?.gallery && product?.gallery.length > 0) {
|
|
287
|
-
for (const img of product?.gallery) {
|
|
288
|
-
if (img?.file) {
|
|
289
|
-
imageList.push(img?.file)
|
|
290
|
-
}
|
|
291
|
-
if (img?.video) {
|
|
292
|
-
const keys = img?.video.split('/')
|
|
293
|
-
let _videoId = keys[keys.length - 1]
|
|
294
|
-
if (_videoId.includes('watch')) {
|
|
295
|
-
const __url = _videoId.split('=')[1]
|
|
296
|
-
_videoId = __url
|
|
297
|
-
}
|
|
298
|
-
if (_videoId.includes('?')) {
|
|
299
|
-
const __url = _videoId.split('?')[0]
|
|
300
|
-
_videoId = __url
|
|
301
|
-
}
|
|
302
|
-
videoList.push(_videoId)
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
const gallery = imageList.concat(videoList)
|
|
307
|
-
setGallery(gallery)
|
|
308
|
-
|
|
309
|
-
if (product?.weight && product?.weight_unit) {
|
|
310
|
-
setIsHaveWeight(true)
|
|
311
|
-
setPricePerWeightUnit(product?.price / product?.weight)
|
|
312
|
-
}
|
|
313
|
-
}, [product])
|
|
314
|
-
|
|
315
282
|
const saveErrors =
|
|
316
283
|
orderState.loading ||
|
|
317
284
|
maxProductQuantity === 0 ||
|
|
@@ -319,28 +286,9 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
319
286
|
|
|
320
287
|
const ExtraOptions = ({ eID, options }: any) => (
|
|
321
288
|
<>
|
|
322
|
-
{
|
|
323
|
-
<TouchableOpacity
|
|
324
|
-
key={`eopt_all_00`}
|
|
325
|
-
onPress={() => setSelectedOpt(-1)}
|
|
326
|
-
style={[
|
|
327
|
-
styles.extraItem,
|
|
328
|
-
{
|
|
329
|
-
borderBottomColor:
|
|
330
|
-
selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
|
|
331
|
-
},
|
|
332
|
-
]}>
|
|
333
|
-
<OText
|
|
334
|
-
color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
|
|
335
|
-
size={selOpt == -1 ? 14 : 12}
|
|
336
|
-
weight={selOpt == -1 ? '600' : 'normal'}>
|
|
337
|
-
{t('INGREDIENTS', 'Ingredients')}
|
|
338
|
-
</OText>
|
|
339
|
-
</TouchableOpacity>
|
|
340
|
-
)}
|
|
341
|
-
{options.map(({ id, name, respect_to }: any) => (
|
|
289
|
+
{options.map(({ id, name, respect_to, suboptions }: any) => (
|
|
342
290
|
<React.Fragment key={`cont_key_${id}`}>
|
|
343
|
-
{respect_to == null && (
|
|
291
|
+
{respect_to == null && suboptions?.length > 0 && (
|
|
344
292
|
<TouchableOpacity
|
|
345
293
|
key={`eopt_key_${id}`}
|
|
346
294
|
onPress={() => setSelectedOpt(id)}
|
|
@@ -370,6 +318,54 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
370
318
|
? () => navigation.goBack()
|
|
371
319
|
: () => navigation.navigate('Business', { store: props.businessSlug })
|
|
372
320
|
|
|
321
|
+
useEffect(() => {
|
|
322
|
+
if (isScrollAvailable) {
|
|
323
|
+
setIsScrollAvailable(null)
|
|
324
|
+
scrollDown(isScrollAvailable)
|
|
325
|
+
}
|
|
326
|
+
}, [errors])
|
|
327
|
+
|
|
328
|
+
useEffect(() => {
|
|
329
|
+
const imageList: any = []
|
|
330
|
+
const videoList: any = []
|
|
331
|
+
product?.images && imageList.push(product.images)
|
|
332
|
+
if (product?.gallery && product?.gallery.length > 0) {
|
|
333
|
+
for (const img of product?.gallery) {
|
|
334
|
+
if (img?.file) {
|
|
335
|
+
imageList.push(img?.file)
|
|
336
|
+
}
|
|
337
|
+
if (img?.video) {
|
|
338
|
+
const keys = img?.video.split('/')
|
|
339
|
+
let _videoId = keys[keys.length - 1]
|
|
340
|
+
|
|
341
|
+
if (_videoId.includes('watch')) {
|
|
342
|
+
const __url = _videoId.split('=')[1]
|
|
343
|
+
_videoId = __url
|
|
344
|
+
} else if (_videoId.includes('?')) {
|
|
345
|
+
const __url = _videoId.split('?')[0]
|
|
346
|
+
_videoId = __url
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (_videoId.search(/&/i) >= 0) {
|
|
350
|
+
_videoId = _videoId.split('&')[0]
|
|
351
|
+
} else if (_videoId.search(/\?/i) >= 0) {
|
|
352
|
+
_videoId = _videoId.split('?')[0]
|
|
353
|
+
}
|
|
354
|
+
if ((_videoId.length === 11)) {
|
|
355
|
+
videoList.push(_videoId)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const gallery = imageList.concat(videoList)
|
|
361
|
+
setGallery(gallery)
|
|
362
|
+
|
|
363
|
+
if (product?.weight && product?.weight_unit) {
|
|
364
|
+
setIsHaveWeight(true)
|
|
365
|
+
setPricePerWeightUnit(product?.price / product?.weight)
|
|
366
|
+
}
|
|
367
|
+
}, [product])
|
|
368
|
+
|
|
373
369
|
return (
|
|
374
370
|
<SafeAreaView style={{ flex: 1 }}>
|
|
375
371
|
<TopHeader>
|
|
@@ -658,6 +654,25 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
658
654
|
{t('ALL', 'All')}
|
|
659
655
|
</OText>
|
|
660
656
|
</TouchableOpacity>
|
|
657
|
+
{product?.ingredients.length > 0 && (
|
|
658
|
+
<TouchableOpacity
|
|
659
|
+
key={`eopt_all_00`}
|
|
660
|
+
onPress={() => setSelectedOpt(-1)}
|
|
661
|
+
style={[
|
|
662
|
+
styles.extraItem,
|
|
663
|
+
{
|
|
664
|
+
borderBottomColor:
|
|
665
|
+
selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
|
|
666
|
+
},
|
|
667
|
+
]}>
|
|
668
|
+
<OText
|
|
669
|
+
color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
|
|
670
|
+
size={selOpt == -1 ? 14 : 12}
|
|
671
|
+
weight={selOpt == -1 ? '600' : 'normal'}>
|
|
672
|
+
{t('INGREDIENTS', 'Ingredients')}
|
|
673
|
+
</OText>
|
|
674
|
+
</TouchableOpacity>
|
|
675
|
+
)}
|
|
661
676
|
{product?.extras.map((extra: any) =>
|
|
662
677
|
<ExtraOptions key={extra.id} options={extra.options} />
|
|
663
678
|
)}
|
|
@@ -687,8 +702,8 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
687
702
|
</WrapperIngredients>
|
|
688
703
|
</View>
|
|
689
704
|
)}
|
|
690
|
-
{product?.extras.map((extra: any) =>
|
|
691
|
-
extra.options.map((option: any) => {
|
|
705
|
+
{product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
|
|
706
|
+
extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
|
|
692
707
|
const currentState =
|
|
693
708
|
productCart.options[`id:${option.id}`] || {};
|
|
694
709
|
return (
|
|
@@ -704,7 +719,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
704
719
|
backgroundColor: isError(option.id),
|
|
705
720
|
borderRadius: 7.6
|
|
706
721
|
}}>
|
|
707
|
-
{option.suboptions.map(
|
|
722
|
+
{option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
|
|
708
723
|
(suboption: any) => {
|
|
709
724
|
const currentState =
|
|
710
725
|
productCart.options[
|
|
@@ -731,7 +746,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
731
746
|
isSoldOut ||
|
|
732
747
|
maxProductQuantity <= 0
|
|
733
748
|
}
|
|
734
|
-
|
|
749
|
+
setIsScrollAvailable={setIsScrollAvailable}
|
|
735
750
|
error={errors[`id:${option.id}`]}
|
|
736
751
|
/>
|
|
737
752
|
);
|
|
@@ -772,7 +787,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
772
787
|
) : (
|
|
773
788
|
<>
|
|
774
789
|
{product?.extras.map((extra: any) =>
|
|
775
|
-
extra.options.map((option: any) => {
|
|
790
|
+
extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
|
|
776
791
|
if (
|
|
777
792
|
option.id == selOpt ||
|
|
778
793
|
(hasRespected(
|
|
@@ -797,7 +812,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
797
812
|
option.id,
|
|
798
813
|
),
|
|
799
814
|
}}>
|
|
800
|
-
{option.suboptions.map(
|
|
815
|
+
{option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
|
|
801
816
|
(suboption: any) => {
|
|
802
817
|
const currentState =
|
|
803
818
|
productCart.options[
|