ordering-ui-react-native 0.14.36 → 0.14.39
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 +1 -1
- package/src/components/BusinessProductsListing/index.tsx +10 -26
- package/src/components/Cart/index.tsx +11 -30
- package/src/components/Checkout/index.tsx +5 -3
- package/src/components/OrderSummary/index.tsx +12 -31
- package/src/components/ProductForm/index.tsx +1 -3
- package/src/components/UpsellingProducts/index.tsx +13 -31
- package/src/types/index.tsx +2 -0
- package/src/types/react-native-color-matrix-image-filters/index.d.ts +1 -0
- package/themes/original/index.tsx +4 -0
- package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +35 -0
- package/themes/original/src/components/BusinessProductsListing/index.tsx +16 -47
- package/themes/original/src/components/Cart/index.tsx +10 -31
- package/themes/original/src/components/Checkout/index.tsx +1 -0
- package/themes/original/src/components/Home/index.tsx +5 -3
- package/themes/original/src/components/OrderDetails/index.tsx +3 -1
- package/themes/original/src/components/OrderSummary/index.tsx +11 -30
- package/themes/original/src/components/ProductForm/index.tsx +16 -27
- package/themes/original/src/components/ProductForm/styles.tsx +9 -2
- package/themes/original/src/components/UpsellingProducts/index.tsx +84 -86
- package/themes/original/src/types/index.tsx +4 -0
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
useToast,
|
|
11
11
|
ToastType
|
|
12
12
|
} from 'ordering-components/native'
|
|
13
|
-
import { OButton,
|
|
13
|
+
import { OButton, OText } from '../shared'
|
|
14
14
|
import { BusinessBasicInformation } from '../BusinessBasicInformation'
|
|
15
15
|
import { SearchBar } from '../SearchBar'
|
|
16
16
|
import { BusinessProductsCategories } from '../BusinessProductsCategories'
|
|
@@ -45,7 +45,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
45
45
|
errorQuantityProducts,
|
|
46
46
|
header,
|
|
47
47
|
logo,
|
|
48
|
-
productModal,
|
|
49
48
|
businessId,
|
|
50
49
|
categoryId,
|
|
51
50
|
productId,
|
|
@@ -75,7 +74,13 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
const onProductClick = (product: any) => {
|
|
78
|
-
|
|
77
|
+
onRedirect('ProductDetails', {
|
|
78
|
+
product: product,
|
|
79
|
+
businessSlug: business.slug,
|
|
80
|
+
businessId: business.id,
|
|
81
|
+
categoryId: categoryId,
|
|
82
|
+
productId: productId,
|
|
83
|
+
})
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
const handleCancel = () => {
|
|
@@ -89,10 +94,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
89
94
|
updateProductModal && updateProductModal(null)
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
const handlerProductAction = () => {
|
|
93
|
-
handleCloseProductModal()
|
|
94
|
-
}
|
|
95
|
-
|
|
96
97
|
const handleUpsellingPage = () => {
|
|
97
98
|
onRedirect('CheckoutNavigator', {
|
|
98
99
|
screen: 'CheckoutPage',
|
|
@@ -258,27 +259,9 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
258
259
|
handleClick={() => setOpenUpselling(true)}
|
|
259
260
|
/>
|
|
260
261
|
)}
|
|
261
|
-
<OModal
|
|
262
|
-
open={openModalProduct || !!curProduct || (!!productModal.product && !orderState.loading)}
|
|
263
|
-
onClose={handleCloseProductModal}
|
|
264
|
-
entireModal
|
|
265
|
-
customClose
|
|
266
|
-
isAvoidKeyBoardView
|
|
267
|
-
>
|
|
268
|
-
<ProductForm
|
|
269
|
-
product={curProduct || productModal.product}
|
|
270
|
-
businessSlug={business?.slug}
|
|
271
|
-
businessId={businessId || business?.id || productModal?.product?.category?.business_id}
|
|
272
|
-
onClose={handleCloseProductModal}
|
|
273
|
-
navigation={navigation}
|
|
274
|
-
onSave={handlerProductAction}
|
|
275
|
-
setProductLogin={setProductLogin}
|
|
276
|
-
categoryId={categoryId}
|
|
277
|
-
productId={productId}
|
|
278
|
-
/>
|
|
279
|
-
</OModal>
|
|
280
262
|
{openUpselling && (
|
|
281
263
|
<UpsellingProducts
|
|
264
|
+
setOpenUpselling={setOpenUpselling}
|
|
282
265
|
businessId={currentCart?.business_id}
|
|
283
266
|
business={currentCart?.business}
|
|
284
267
|
cartProducts={currentCart?.products}
|
|
@@ -286,6 +269,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
286
269
|
openUpselling={openUpselling}
|
|
287
270
|
canOpenUpselling={canOpenUpselling}
|
|
288
271
|
setCanOpenUpselling={setCanOpenUpselling}
|
|
272
|
+
onRedirect={onRedirect}
|
|
289
273
|
/>
|
|
290
274
|
)}
|
|
291
275
|
</>
|
|
@@ -17,7 +17,6 @@ import { BusinessItemAccordion } from '../BusinessItemAccordion';
|
|
|
17
17
|
import { CouponControl } from '../CouponControl';
|
|
18
18
|
|
|
19
19
|
import { OButton, OModal, OText, OInput } from '../shared';
|
|
20
|
-
import { ProductForm } from '../ProductForm';
|
|
21
20
|
import { UpsellingProducts } from '../UpsellingProducts';
|
|
22
21
|
import { verifyDecimals } from '../../utils';
|
|
23
22
|
import { useTheme } from 'styled-components/native';
|
|
@@ -46,8 +45,6 @@ const CartUI = (props: any) => {
|
|
|
46
45
|
const [{ parsePrice, parseNumber, parseDate }] = useUtils()
|
|
47
46
|
const [validationFields] = useValidationFields()
|
|
48
47
|
|
|
49
|
-
const [openProduct, setModalIsOpen] = useState(false)
|
|
50
|
-
const [curProduct, setCurProduct] = useState<any>(null)
|
|
51
48
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
52
49
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
53
50
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
@@ -64,14 +61,15 @@ const CartUI = (props: any) => {
|
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
const handleEditProduct = (product: any) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
props?.onNavigationRedirect &&
|
|
65
|
+
props?.onNavigationRedirect('ProductDetails', {
|
|
66
|
+
businessId: cart?.business_id,
|
|
67
|
+
isCartProduct: true,
|
|
68
|
+
productCart: product,
|
|
69
|
+
businessSlug: cart?.business?.slug,
|
|
70
|
+
categoryId: product?.category_id,
|
|
71
|
+
productId: product?.id,
|
|
72
|
+
})
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
const handleClearProducts = async () => {
|
|
@@ -292,25 +290,6 @@ const CartUI = (props: any) => {
|
|
|
292
290
|
</CheckoutAction>
|
|
293
291
|
)}
|
|
294
292
|
</BusinessItemAccordion>
|
|
295
|
-
<OModal
|
|
296
|
-
open={openProduct}
|
|
297
|
-
entireModal
|
|
298
|
-
customClose
|
|
299
|
-
onClose={() => setModalIsOpen(false)}
|
|
300
|
-
isAvoidKeyBoardView
|
|
301
|
-
>
|
|
302
|
-
<ProductForm
|
|
303
|
-
isCartProduct
|
|
304
|
-
productCart={curProduct}
|
|
305
|
-
businessSlug={cart?.business?.slug}
|
|
306
|
-
businessId={cart?.business_id}
|
|
307
|
-
categoryId={curProduct?.category_id}
|
|
308
|
-
productId={curProduct?.id}
|
|
309
|
-
onSave={handlerProductAction}
|
|
310
|
-
onClose={() => setModalIsOpen(false)}
|
|
311
|
-
/>
|
|
312
|
-
|
|
313
|
-
</OModal>
|
|
314
293
|
|
|
315
294
|
{openUpselling && (
|
|
316
295
|
<UpsellingProducts
|
|
@@ -321,6 +300,8 @@ const CartUI = (props: any) => {
|
|
|
321
300
|
cartProducts={cart?.products}
|
|
322
301
|
canOpenUpselling={canOpenUpselling}
|
|
323
302
|
setCanOpenUpselling={setCanOpenUpselling}
|
|
303
|
+
setOpenUpselling={setOpenUpselling}
|
|
304
|
+
onRedirect={props.onNavigationRedirect}
|
|
324
305
|
/>
|
|
325
306
|
)}
|
|
326
307
|
<OModal
|
|
@@ -152,8 +152,8 @@ const CheckoutUI = (props: any) => {
|
|
|
152
152
|
|
|
153
153
|
const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map((option: any) => {
|
|
154
154
|
return {
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
value: option?.id, key: option?.id, label: t(option?.name.toUpperCase().replace(/\s/g, '_'), option?.name)
|
|
156
|
+
}
|
|
157
157
|
})
|
|
158
158
|
|
|
159
159
|
const handlePlaceOrder = () => {
|
|
@@ -241,7 +241,7 @@ const CheckoutUI = (props: any) => {
|
|
|
241
241
|
setShowGateway({ open: false, closedByUser: true })
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
const changeDeliveryOption = (option
|
|
244
|
+
const changeDeliveryOption = (option: any) => {
|
|
245
245
|
handleChangeDeliveryOption(option)
|
|
246
246
|
setIsDeliveryOptionModalVisible(false)
|
|
247
247
|
}
|
|
@@ -580,6 +580,7 @@ const CheckoutUI = (props: any) => {
|
|
|
580
580
|
cart={cart}
|
|
581
581
|
isCartPending={cart?.status === 2}
|
|
582
582
|
isFromCheckout
|
|
583
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
583
584
|
/>
|
|
584
585
|
</>
|
|
585
586
|
)}
|
|
@@ -766,6 +767,7 @@ const CheckoutUI = (props: any) => {
|
|
|
766
767
|
amount: cart?.total,
|
|
767
768
|
delivery_zone_id: cart?.delivery_zone_id,
|
|
768
769
|
user_id: user?.id,
|
|
770
|
+
user_name: user?.name
|
|
769
771
|
},
|
|
770
772
|
currency: configs?.stripe_currency?.value || currency,
|
|
771
773
|
userToken: token,
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
21
21
|
import { CouponControl } from '../CouponControl';
|
|
22
22
|
import { OInput, OModal, OText } from '../shared';
|
|
23
|
-
import { ProductForm } from '../ProductForm';
|
|
24
23
|
import { verifyDecimals } from '../../utils';
|
|
25
24
|
import { useTheme } from 'styled-components/native';
|
|
26
25
|
import { TaxInformation } from '../TaxInformation';
|
|
@@ -36,7 +35,8 @@ const OrderSummaryUI = (props: any) => {
|
|
|
36
35
|
isCartPending,
|
|
37
36
|
isFromCheckout,
|
|
38
37
|
commentState,
|
|
39
|
-
handleChangeComment
|
|
38
|
+
handleChangeComment,
|
|
39
|
+
onNavigationRedirect
|
|
40
40
|
} = props;
|
|
41
41
|
|
|
42
42
|
const theme = useTheme();
|
|
@@ -45,8 +45,6 @@ const OrderSummaryUI = (props: any) => {
|
|
|
45
45
|
const [orderState] = useOrder();
|
|
46
46
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
47
47
|
const [validationFields] = useValidationFields();
|
|
48
|
-
const [openProduct, setModalIsOpen] = useState(false)
|
|
49
|
-
const [curProduct, setCurProduct] = useState<any>(null)
|
|
50
48
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
51
49
|
|
|
52
50
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
@@ -56,14 +54,16 @@ const OrderSummaryUI = (props: any) => {
|
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
const handleEditProduct = (product: any) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
onNavigationRedirect &&
|
|
58
|
+
onNavigationRedirect('ProductDetails', {
|
|
59
|
+
isCartProduct: true,
|
|
60
|
+
productCart: product,
|
|
61
|
+
businessSlug: cart?.business?.slug,
|
|
62
|
+
businessId: cart?.business_id,
|
|
63
|
+
categoryId: product?.category_id,
|
|
64
|
+
productId: product?.id,
|
|
65
|
+
isFromCheckout: isFromCheckout,
|
|
66
|
+
})
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const getIncludedTaxes = () => {
|
|
@@ -223,25 +223,6 @@ const OrderSummaryUI = (props: any) => {
|
|
|
223
223
|
)}
|
|
224
224
|
</OSBill>
|
|
225
225
|
)}
|
|
226
|
-
<OModal
|
|
227
|
-
open={openProduct}
|
|
228
|
-
entireModal
|
|
229
|
-
customClose
|
|
230
|
-
onClose={() => setModalIsOpen(false)}
|
|
231
|
-
isAvoidKeyBoardView
|
|
232
|
-
>
|
|
233
|
-
<ProductForm
|
|
234
|
-
isCartProduct
|
|
235
|
-
productCart={curProduct}
|
|
236
|
-
businessSlug={cart?.business?.slug}
|
|
237
|
-
businessId={cart?.business_id}
|
|
238
|
-
categoryId={curProduct?.category_id}
|
|
239
|
-
productId={curProduct?.id}
|
|
240
|
-
onSave={handlerProductAction}
|
|
241
|
-
onClose={() => setModalIsOpen(false)}
|
|
242
|
-
isFromCheckout={isFromCheckout}
|
|
243
|
-
/>
|
|
244
|
-
</OModal>
|
|
245
226
|
<OModal
|
|
246
227
|
open={openTaxModal.open}
|
|
247
228
|
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
@@ -52,7 +52,6 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
52
52
|
handleChangeSuboptionState,
|
|
53
53
|
handleChangeCommentState,
|
|
54
54
|
productObject,
|
|
55
|
-
onClose,
|
|
56
55
|
businessSlug
|
|
57
56
|
} = props
|
|
58
57
|
|
|
@@ -84,7 +83,6 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
const handleRedirectLogin = (product : any) => {
|
|
87
|
-
onClose()
|
|
88
86
|
navigation.navigate('Login', {product: {businessId: product?.businessId, id: product?.id, categoryId: product?.categoryId, slug: businessSlug} })
|
|
89
87
|
}
|
|
90
88
|
|
|
@@ -110,7 +108,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
110
108
|
name="x"
|
|
111
109
|
size={35}
|
|
112
110
|
style={{ color: theme.colors.white, backgroundColor: 'rgba(0,0,0,0.3)' }}
|
|
113
|
-
onPress={
|
|
111
|
+
onPress={props.handleGoBack}
|
|
114
112
|
/>
|
|
115
113
|
</View>
|
|
116
114
|
</TopHeader>
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
AddButton,
|
|
17
17
|
CloseUpselling
|
|
18
18
|
} from './styles'
|
|
19
|
-
import { ProductForm } from '../ProductForm';
|
|
20
19
|
import { useTheme } from 'styled-components/native'
|
|
21
20
|
|
|
22
21
|
const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
@@ -27,7 +26,9 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
27
26
|
handleUpsellingPage,
|
|
28
27
|
openUpselling,
|
|
29
28
|
canOpenUpselling,
|
|
30
|
-
setCanOpenUpselling
|
|
29
|
+
setCanOpenUpselling,
|
|
30
|
+
onRedirect,
|
|
31
|
+
setOpenUpselling
|
|
31
32
|
} = props
|
|
32
33
|
|
|
33
34
|
const theme = useTheme();
|
|
@@ -53,8 +54,6 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
53
54
|
}
|
|
54
55
|
})
|
|
55
56
|
|
|
56
|
-
const [actualProduct, setActualProduct] = useState<any>(null)
|
|
57
|
-
const [modalIsOpen, setModalIsOpen] = useState(false)
|
|
58
57
|
const [{ parsePrice }] = useUtils()
|
|
59
58
|
const [, t] = useLanguage()
|
|
60
59
|
|
|
@@ -71,13 +70,15 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
71
70
|
}, [upsellingProducts.loading, upsellingProducts?.products.length])
|
|
72
71
|
|
|
73
72
|
const handleFormProduct = (product: any) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
setOpenUpselling && setOpenUpselling(false)
|
|
74
|
+
onRedirect && onRedirect('ProductDetails', {
|
|
75
|
+
product: product,
|
|
76
|
+
businessId: product?.api?.businessId,
|
|
77
|
+
businessSlug: business.slug,
|
|
78
|
+
onAction: () => {
|
|
79
|
+
setOpenUpselling && setOpenUpselling(true)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
const UpsellingLayout = () => {
|
|
@@ -132,13 +133,12 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
132
133
|
<>
|
|
133
134
|
{!canOpenUpselling || upsellingProducts?.products?.length === 0 ? null : (
|
|
134
135
|
<>
|
|
135
|
-
{!modalIsOpen && (
|
|
136
136
|
<OBottomPopup
|
|
137
137
|
title={t('WANT_SOMETHING_ELSE', 'Do you want something else?')}
|
|
138
138
|
open={openUpselling}
|
|
139
139
|
onClose={() => handleUpsellingPage()}
|
|
140
140
|
>
|
|
141
|
-
|
|
141
|
+
<UpsellingLayout />
|
|
142
142
|
<CloseUpselling>
|
|
143
143
|
<OButton
|
|
144
144
|
imgRightSrc=''
|
|
@@ -148,28 +148,10 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
148
148
|
/>
|
|
149
149
|
</CloseUpselling>
|
|
150
150
|
</OBottomPopup>
|
|
151
|
-
)}
|
|
152
151
|
</>
|
|
153
152
|
)}
|
|
154
153
|
</>
|
|
155
154
|
)}
|
|
156
|
-
<OModal
|
|
157
|
-
open={modalIsOpen}
|
|
158
|
-
onClose={() => setModalIsOpen(false)}
|
|
159
|
-
entireModal
|
|
160
|
-
customClose
|
|
161
|
-
isAvoidKeyBoardView
|
|
162
|
-
>
|
|
163
|
-
{actualProduct && (
|
|
164
|
-
<ProductForm
|
|
165
|
-
product={actualProduct}
|
|
166
|
-
businessId={actualProduct?.api?.businessId}
|
|
167
|
-
businessSlug={business.slug}
|
|
168
|
-
onSave={() => handleSaveProduct()}
|
|
169
|
-
onClose={() => setModalIsOpen(false)}
|
|
170
|
-
/>
|
|
171
|
-
)}
|
|
172
|
-
</OModal>
|
|
173
155
|
</>
|
|
174
156
|
)
|
|
175
157
|
}
|
package/src/types/index.tsx
CHANGED
|
@@ -408,6 +408,8 @@ export interface UpsellingProductsParams {
|
|
|
408
408
|
isCustomMode?: boolean;
|
|
409
409
|
upsellingProducts?: any;
|
|
410
410
|
business?: any;
|
|
411
|
+
setOpenUpselling?: any;
|
|
412
|
+
onRedirect?: any;
|
|
411
413
|
businessId?: number;
|
|
412
414
|
cartProducts?: Array<any>;
|
|
413
415
|
handleUpsellingPage: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'react-native-color-matrix-image-filters'
|
|
@@ -30,6 +30,8 @@ import { NotFoundSource } from './src/components/NotFoundSource';
|
|
|
30
30
|
import { OrderTypeSelector } from './src/components/OrderTypeSelector';
|
|
31
31
|
import { Wallets } from './src/components/Wallets';
|
|
32
32
|
import { PaymentOptionWallet } from './src/components/PaymentOptionWallet';
|
|
33
|
+
import { ProductForm } from './src/components/ProductForm';
|
|
34
|
+
import { UpsellingProducts } from './src/components/UpsellingProducts';
|
|
33
35
|
|
|
34
36
|
import { Toast } from './src/components/shared/OToast';
|
|
35
37
|
import {
|
|
@@ -90,6 +92,8 @@ export {
|
|
|
90
92
|
OrderTypeSelector,
|
|
91
93
|
Wallets,
|
|
92
94
|
PaymentOptionWallet,
|
|
95
|
+
ProductForm,
|
|
96
|
+
UpsellingProducts,
|
|
93
97
|
|
|
94
98
|
// OComponents
|
|
95
99
|
Toast,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import { UpsellingPage as UpsellingPageController } from 'ordering-components/native'
|
|
3
|
+
|
|
4
|
+
const UpsellingRedirectUI = (props: any) => {
|
|
5
|
+
const {
|
|
6
|
+
setOpenUpselling,
|
|
7
|
+
upsellingProducts,
|
|
8
|
+
handleUpsellingPage,
|
|
9
|
+
onRedirect,
|
|
10
|
+
} = props
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!upsellingProducts.loading) {
|
|
14
|
+
if (upsellingProducts?.products?.length) {
|
|
15
|
+
onRedirect &&
|
|
16
|
+
onRedirect('UpsellingPage', props)
|
|
17
|
+
} else {
|
|
18
|
+
handleUpsellingPage && handleUpsellingPage()
|
|
19
|
+
}
|
|
20
|
+
setOpenUpselling(false)
|
|
21
|
+
}
|
|
22
|
+
}, [upsellingProducts.loading, upsellingProducts?.products.length])
|
|
23
|
+
|
|
24
|
+
return (<>{null}</>)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const UpsellingRedirect = (props: any) => {
|
|
28
|
+
const upsellingProps = {
|
|
29
|
+
...props,
|
|
30
|
+
UIComponent: UpsellingRedirectUI
|
|
31
|
+
}
|
|
32
|
+
return (
|
|
33
|
+
<UpsellingPageController {...upsellingProps} />
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
|
-
import { View, TouchableOpacity, StyleSheet, SafeAreaView
|
|
2
|
+
import { View, TouchableOpacity, StyleSheet, SafeAreaView } from 'react-native'
|
|
3
3
|
import { useTheme } from 'styled-components/native';
|
|
4
4
|
import {
|
|
5
5
|
BusinessAndProductList,
|
|
@@ -17,17 +17,13 @@ import { BusinessProductsCategories } from '../BusinessProductsCategories'
|
|
|
17
17
|
import { BusinessProductsList } from '../BusinessProductsList'
|
|
18
18
|
import { BusinessProductsListingParams } from '../../types'
|
|
19
19
|
import {
|
|
20
|
-
WrapHeader,
|
|
21
20
|
TopHeader,
|
|
22
|
-
AddressInput,
|
|
23
21
|
WrapSearchBar,
|
|
24
22
|
WrapContent,
|
|
25
23
|
BusinessProductsListingContainer
|
|
26
24
|
} from './styles'
|
|
27
25
|
import { FloatingButton } from '../FloatingButton'
|
|
28
|
-
import {
|
|
29
|
-
import { UpsellingProducts } from '../UpsellingProducts'
|
|
30
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
26
|
+
import { UpsellingRedirect } from './UpsellingRedirect'
|
|
31
27
|
import Animated from 'react-native-reanimated'
|
|
32
28
|
|
|
33
29
|
const PIXELS_TO_SCROLL = 1000
|
|
@@ -47,7 +43,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
47
43
|
errorQuantityProducts,
|
|
48
44
|
header,
|
|
49
45
|
logo,
|
|
50
|
-
getNextProducts
|
|
46
|
+
getNextProducts,
|
|
51
47
|
} = props
|
|
52
48
|
|
|
53
49
|
const theme = useTheme();
|
|
@@ -56,7 +52,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
56
52
|
const [orderState] = useOrder()
|
|
57
53
|
const [{ parsePrice }] = useUtils()
|
|
58
54
|
const [, { showToast }] = useToast()
|
|
59
|
-
const { top } = useSafeAreaInsets();
|
|
60
55
|
|
|
61
56
|
const styles = StyleSheet.create({
|
|
62
57
|
mainContainer: {
|
|
@@ -87,7 +82,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
87
82
|
const { business, loading, error } = businessState
|
|
88
83
|
const [openBusinessInformation, setOpenBusinessInformation] = useState(false)
|
|
89
84
|
const [isOpenSearchBar, setIsOpenSearchBar] = useState(false)
|
|
90
|
-
const [curProduct, setCurProduct] = useState(null)
|
|
91
85
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
92
86
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
93
87
|
const scrollViewRef = useRef<any>(null)
|
|
@@ -102,7 +96,11 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
const onProductClick = (product: any) => {
|
|
105
|
-
|
|
99
|
+
onRedirect('ProductDetails', {
|
|
100
|
+
product: product,
|
|
101
|
+
businessSlug: business.slug,
|
|
102
|
+
businessId: business.id,
|
|
103
|
+
})
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
const handleCancel = () => {
|
|
@@ -110,14 +108,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
110
108
|
handleChangeSearch('')
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
const handleCloseProductModal = () => {
|
|
114
|
-
setCurProduct(null)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const handlerProductAction = () => {
|
|
118
|
-
handleCloseProductModal()
|
|
119
|
-
}
|
|
120
|
-
|
|
121
111
|
const handleUpsellingPage = () => {
|
|
122
112
|
onRedirect('CheckoutNavigator', {
|
|
123
113
|
screen: 'CheckoutPage',
|
|
@@ -166,13 +156,6 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
166
156
|
setCategoryClicked(false);
|
|
167
157
|
}, []);
|
|
168
158
|
|
|
169
|
-
|
|
170
|
-
useEffect(() => {
|
|
171
|
-
if (!orderState.loading) {
|
|
172
|
-
handleCloseProductModal()
|
|
173
|
-
}
|
|
174
|
-
}, [orderState.loading])
|
|
175
|
-
|
|
176
159
|
return (
|
|
177
160
|
<SafeAreaView
|
|
178
161
|
style={{ flex: 1 }}
|
|
@@ -304,49 +287,35 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
304
287
|
</>
|
|
305
288
|
)}
|
|
306
289
|
</BusinessProductsListingContainer>
|
|
307
|
-
{!loading && auth &&
|
|
290
|
+
{!loading && auth && currentCart?.products?.length > 0 && categoryState.products.length !== 0 && (
|
|
308
291
|
<FloatingButton
|
|
309
292
|
btnText={
|
|
310
293
|
currentCart?.subtotal >= currentCart?.minimum
|
|
311
|
-
?
|
|
294
|
+
? t('VIEW_ORDER', 'View Order')
|
|
312
295
|
: `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(currentCart?.minimum)}`
|
|
313
296
|
}
|
|
314
297
|
isSecondaryBtn={currentCart?.subtotal < currentCart?.minimum}
|
|
315
|
-
btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum &&
|
|
316
|
-
btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum &&
|
|
298
|
+
btnLeftValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
|
|
299
|
+
btnRightValueShow={currentCart?.subtotal >= currentCart?.minimum && currentCart?.products?.length > 0}
|
|
317
300
|
btnLeftValue={currentCart?.products?.length}
|
|
318
301
|
btnRightValue={parsePrice(currentCart?.total)}
|
|
319
|
-
disabled={
|
|
302
|
+
disabled={currentCart?.subtotal < currentCart?.minimum}
|
|
320
303
|
handleClick={() => setOpenUpselling(true)}
|
|
321
304
|
/>
|
|
322
305
|
)}
|
|
323
|
-
<OModal
|
|
324
|
-
open={!!curProduct}
|
|
325
|
-
onClose={handleCloseProductModal}
|
|
326
|
-
entireModal
|
|
327
|
-
customClose
|
|
328
|
-
isAvoidKeyBoardView
|
|
329
|
-
>
|
|
330
|
-
<ProductForm
|
|
331
|
-
product={curProduct}
|
|
332
|
-
businessSlug={business.slug}
|
|
333
|
-
businessId={business.id}
|
|
334
|
-
onClose={handleCloseProductModal}
|
|
335
|
-
navigation={navigation}
|
|
336
|
-
onSave={handlerProductAction}
|
|
337
|
-
/>
|
|
338
|
-
</OModal>
|
|
339
306
|
{openUpselling && (
|
|
340
|
-
<
|
|
307
|
+
<UpsellingRedirect
|
|
341
308
|
businessId={currentCart?.business_id}
|
|
342
309
|
business={currentCart?.business}
|
|
343
310
|
cartProducts={currentCart?.products}
|
|
344
311
|
cart={currentCart}
|
|
312
|
+
setOpenUpselling={setOpenUpselling}
|
|
345
313
|
handleUpsellingPage={handleUpsellingPage}
|
|
346
314
|
handleCloseUpsellingPage={handleCloseUpsellingPage}
|
|
347
315
|
openUpselling={openUpselling}
|
|
348
316
|
canOpenUpselling={canOpenUpselling}
|
|
349
317
|
setCanOpenUpselling={setCanOpenUpselling}
|
|
318
|
+
onRedirect={onRedirect}
|
|
350
319
|
/>
|
|
351
320
|
)}
|
|
352
321
|
</SafeAreaView>
|
|
@@ -17,7 +17,6 @@ import { BusinessItemAccordion } from '../BusinessItemAccordion';
|
|
|
17
17
|
import { CouponControl } from '../CouponControl';
|
|
18
18
|
|
|
19
19
|
import { OButton, OInput, OModal, OText } from '../shared';
|
|
20
|
-
import { ProductForm } from '../ProductForm';
|
|
21
20
|
import { UpsellingProducts } from '../UpsellingProducts';
|
|
22
21
|
import { verifyDecimals } from '../../utils';
|
|
23
22
|
import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
|
|
@@ -35,10 +34,9 @@ const CartUI = (props: any) => {
|
|
|
35
34
|
removeProduct,
|
|
36
35
|
handleCartOpen,
|
|
37
36
|
setIsCartsLoading,
|
|
38
|
-
hideUpselling,
|
|
39
37
|
handleChangeComment,
|
|
40
|
-
commentState
|
|
41
|
-
|
|
38
|
+
commentState,
|
|
39
|
+
onNavigationRedirect
|
|
42
40
|
} = props
|
|
43
41
|
|
|
44
42
|
const theme = useTheme();
|
|
@@ -49,8 +47,6 @@ const CartUI = (props: any) => {
|
|
|
49
47
|
const [{ parsePrice, parseNumber, parseDate }] = useUtils()
|
|
50
48
|
const [validationFields] = useValidationFields()
|
|
51
49
|
|
|
52
|
-
const [openProduct, setModalIsOpen] = useState(false)
|
|
53
|
-
const [curProduct, setCurProduct] = useState<any>(null)
|
|
54
50
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
55
51
|
const [openChangeStore, setOpenChangeStore] = useState(false)
|
|
56
52
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
@@ -71,14 +67,14 @@ const CartUI = (props: any) => {
|
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
const handleEditProduct = (product: any) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
onNavigationRedirect('ProductDetails', {
|
|
71
|
+
businessId,
|
|
72
|
+
isCartProduct: true,
|
|
73
|
+
productCart: product,
|
|
74
|
+
businessSlug: cart?.business?.slug,
|
|
75
|
+
categoryId: product?.category_id,
|
|
76
|
+
productId: product?.id,
|
|
77
|
+
})
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
const handleClearProducts = async () => {
|
|
@@ -329,23 +325,6 @@ const CartUI = (props: any) => {
|
|
|
329
325
|
</CheckoutAction>
|
|
330
326
|
)}
|
|
331
327
|
</BusinessItemAccordion>
|
|
332
|
-
<OModal
|
|
333
|
-
open={openProduct}
|
|
334
|
-
entireModal
|
|
335
|
-
customClose
|
|
336
|
-
onClose={() => setModalIsOpen(false)}
|
|
337
|
-
>
|
|
338
|
-
<ProductForm
|
|
339
|
-
isCartProduct
|
|
340
|
-
productCart={curProduct}
|
|
341
|
-
businessSlug={cart?.business?.slug}
|
|
342
|
-
businessId={businessId}
|
|
343
|
-
categoryId={curProduct?.category_id}
|
|
344
|
-
productId={curProduct?.id}
|
|
345
|
-
onSave={handlerProductAction}
|
|
346
|
-
onClose={() => setModalIsOpen(false)}
|
|
347
|
-
/>
|
|
348
|
-
</OModal>
|
|
349
328
|
|
|
350
329
|
<OModal
|
|
351
330
|
open={openChangeStore && props.isFranchiseApp}
|
|
@@ -5,11 +5,11 @@ import { StyleSheet, View } from 'react-native';
|
|
|
5
5
|
import { OButton, OIcon, OText } from '../shared';
|
|
6
6
|
import { LanguageSelector } from '../LanguageSelector';
|
|
7
7
|
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
8
|
-
import { useWindowDimensions } from 'react-native';
|
|
8
|
+
import { useWindowDimensions, Platform } from 'react-native';
|
|
9
9
|
|
|
10
10
|
export const Home = (props: any) => {
|
|
11
11
|
const { onNavigationRedirect } = props;
|
|
12
|
-
const { width } = useWindowDimensions();
|
|
12
|
+
const { width, height } = useWindowDimensions();
|
|
13
13
|
const [, t] = useLanguage();
|
|
14
14
|
const [orderState] = useOrder();
|
|
15
15
|
|
|
@@ -18,7 +18,9 @@ export const Home = (props: any) => {
|
|
|
18
18
|
return (
|
|
19
19
|
<View style={styles.container}>
|
|
20
20
|
<View>
|
|
21
|
-
<
|
|
21
|
+
<View style={{paddingTop: (height <= 756 && Platform.OS !== 'ios') ? (height * 0.05) : 0 }}>
|
|
22
|
+
<LanguageSelector />
|
|
23
|
+
</View>
|
|
22
24
|
<OIcon
|
|
23
25
|
src={theme.images.logos.logotypeInvert}
|
|
24
26
|
style={{
|
|
@@ -611,7 +611,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
611
611
|
<OText size={16} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
|
|
612
612
|
{t('DELIVERY_PREFERENCE', 'Delivery Preference')}
|
|
613
613
|
</OText>
|
|
614
|
-
<OText size={12} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
|
|
614
|
+
<OText size={12} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
|
|
615
|
+
{order?.delivery_option?.name ? t(order?.delivery_option?.name.toUpperCase().replace(/\s/g, '_')) : t('EITHER_WAY', 'Either way')}
|
|
616
|
+
</OText>
|
|
615
617
|
</View>
|
|
616
618
|
)}
|
|
617
619
|
{order?.comment && (
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
21
21
|
import { CouponControl } from '../CouponControl';
|
|
22
22
|
import { OInput, OModal, OText } from '../shared';
|
|
23
|
-
import { ProductForm } from '../ProductForm';
|
|
24
23
|
import { verifyDecimals } from '../../utils';
|
|
25
24
|
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
26
25
|
import { TaxInformation } from '../TaxInformation';
|
|
@@ -35,7 +34,8 @@ const OrderSummaryUI = (props: any) => {
|
|
|
35
34
|
isCartPending,
|
|
36
35
|
isFromCheckout,
|
|
37
36
|
commentState,
|
|
38
|
-
handleChangeComment
|
|
37
|
+
handleChangeComment,
|
|
38
|
+
onNavigationRedirect
|
|
39
39
|
} = props;
|
|
40
40
|
|
|
41
41
|
const theme = useTheme()
|
|
@@ -44,8 +44,6 @@ const OrderSummaryUI = (props: any) => {
|
|
|
44
44
|
const [orderState] = useOrder();
|
|
45
45
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
46
46
|
const [validationFields] = useValidationFields();
|
|
47
|
-
const [openProduct, setModalIsOpen] = useState(false)
|
|
48
|
-
const [curProduct, setCurProduct] = useState<any>(null)
|
|
49
47
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
50
48
|
|
|
51
49
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled;
|
|
@@ -55,14 +53,15 @@ const OrderSummaryUI = (props: any) => {
|
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
const handleEditProduct = (product: any) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
onNavigationRedirect('ProductDetails', {
|
|
57
|
+
isCartProduct: true,
|
|
58
|
+
productCart: product,
|
|
59
|
+
businessSlug: cart?.business?.slug,
|
|
60
|
+
businessId: cart?.business_id,
|
|
61
|
+
categoryId: product?.category_id,
|
|
62
|
+
productId: product?.id,
|
|
63
|
+
isFromCheckout: isFromCheckout,
|
|
64
|
+
})
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
const getIncludedTaxes = () => {
|
|
@@ -242,24 +241,6 @@ const OrderSummaryUI = (props: any) => {
|
|
|
242
241
|
)}
|
|
243
242
|
</OSBill>
|
|
244
243
|
)}
|
|
245
|
-
<OModal
|
|
246
|
-
open={openProduct}
|
|
247
|
-
entireModal
|
|
248
|
-
customClose
|
|
249
|
-
onClose={() => setModalIsOpen(false)}
|
|
250
|
-
>
|
|
251
|
-
<ProductForm
|
|
252
|
-
isCartProduct
|
|
253
|
-
productCart={curProduct}
|
|
254
|
-
businessSlug={cart?.business?.slug}
|
|
255
|
-
businessId={cart?.business_id}
|
|
256
|
-
categoryId={curProduct?.category_id}
|
|
257
|
-
productId={curProduct?.id}
|
|
258
|
-
onSave={handlerProductAction}
|
|
259
|
-
onClose={() => setModalIsOpen(false)}
|
|
260
|
-
isFromCheckout={isFromCheckout}
|
|
261
|
-
/>
|
|
262
|
-
</OModal>
|
|
263
244
|
<OModal
|
|
264
245
|
open={openTaxModal.open}
|
|
265
246
|
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
@@ -16,10 +16,9 @@ import {
|
|
|
16
16
|
Grayscale
|
|
17
17
|
} from 'react-native-color-matrix-image-filters'
|
|
18
18
|
|
|
19
|
-
import { View, TouchableOpacity, StyleSheet, Dimensions,
|
|
19
|
+
import { View, TouchableOpacity, StyleSheet, Dimensions, I18nManager, SafeAreaView } from 'react-native';
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
-
ProductHeader,
|
|
23
22
|
WrapHeader,
|
|
24
23
|
TopHeader,
|
|
25
24
|
WrapContent,
|
|
@@ -33,16 +32,15 @@ import {
|
|
|
33
32
|
ProductActions,
|
|
34
33
|
ExtraOptionWrap,
|
|
35
34
|
WeightUnitSwitch,
|
|
36
|
-
WeightUnitItem
|
|
35
|
+
WeightUnitItem,
|
|
36
|
+
TopActions
|
|
37
37
|
} from './styles';
|
|
38
38
|
import { OButton, OIcon, OInput, OText } from '../shared';
|
|
39
39
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
40
40
|
import { ProductOptionSubOption } from '../ProductOptionSubOption';
|
|
41
41
|
import { NotFoundSource } from '../NotFoundSource';
|
|
42
42
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
43
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
44
43
|
import { useState } from 'react';
|
|
45
|
-
import { useWindowDimensions } from 'react-native';
|
|
46
44
|
|
|
47
45
|
const windowHeight = Dimensions.get('window').height;
|
|
48
46
|
const windowWidth = Dimensions.get('window').width;
|
|
@@ -63,8 +61,6 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
63
61
|
handleChangeSuboptionState,
|
|
64
62
|
handleChangeCommentState,
|
|
65
63
|
productObject,
|
|
66
|
-
onClose,
|
|
67
|
-
isFromCheckout,
|
|
68
64
|
} = props;
|
|
69
65
|
|
|
70
66
|
const theme = useTheme();
|
|
@@ -97,7 +93,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
97
93
|
},
|
|
98
94
|
btnBackArrow: {
|
|
99
95
|
borderWidth: 0,
|
|
100
|
-
backgroundColor: '
|
|
96
|
+
backgroundColor: '#FFF',
|
|
101
97
|
borderRadius: 24,
|
|
102
98
|
marginRight: 15,
|
|
103
99
|
},
|
|
@@ -160,15 +156,13 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
160
156
|
const [gallery, setGallery] = useState([])
|
|
161
157
|
const [thumbsSwiper, setThumbsSwiper] = useState(0)
|
|
162
158
|
|
|
163
|
-
const { top, bottom } = useSafeAreaInsets();
|
|
164
|
-
const { height } = useWindowDimensions();
|
|
165
159
|
const [selOpt, setSelectedOpt] = useState(0);
|
|
166
160
|
const [isHaveWeight, setIsHaveWeight] = useState(false)
|
|
167
161
|
const [qtyBy, setQtyBy] = useState({
|
|
168
162
|
weight_unit: false,
|
|
169
163
|
pieces: true
|
|
170
164
|
})
|
|
171
|
-
const [pricePerWeightUnit, setPricePerWeightUnit] = useState(null)
|
|
165
|
+
const [pricePerWeightUnit, setPricePerWeightUnit] = useState<any>(null)
|
|
172
166
|
|
|
173
167
|
const swiperRef: any = useRef(null)
|
|
174
168
|
|
|
@@ -187,10 +181,8 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
187
181
|
};
|
|
188
182
|
|
|
189
183
|
const handleSaveProduct = () => {
|
|
190
|
-
console.log('----- click handle ------')
|
|
191
184
|
const isErrors = Object.values(errors).length > 0;
|
|
192
185
|
if (!isErrors) {
|
|
193
|
-
console.log('----- save handle ------')
|
|
194
186
|
handleSave && handleSave();
|
|
195
187
|
return;
|
|
196
188
|
}
|
|
@@ -220,7 +212,6 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
220
212
|
}
|
|
221
213
|
|
|
222
214
|
const handleRedirectLogin = () => {
|
|
223
|
-
onClose();
|
|
224
215
|
navigation.navigate('Login');
|
|
225
216
|
};
|
|
226
217
|
|
|
@@ -298,14 +289,16 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
298
289
|
</>
|
|
299
290
|
);
|
|
300
291
|
|
|
292
|
+
const handleGoBack = navigation?.canGoBack()
|
|
293
|
+
? () => navigation.goBack()
|
|
294
|
+
: () => navigation.navigate('Business', { store: props.businessSlug })
|
|
295
|
+
|
|
301
296
|
return (
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
<OIcon src={theme.images.general.close} width={16} />
|
|
308
|
-
</TouchableOpacity>
|
|
297
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
298
|
+
<TopHeader>
|
|
299
|
+
<TopActions onPress={() => handleGoBack()}>
|
|
300
|
+
<OIcon src={theme.images.general.arrow_left} width={15} />
|
|
301
|
+
</TopActions>
|
|
309
302
|
</TopHeader>
|
|
310
303
|
<ScrollView>
|
|
311
304
|
{!error && (
|
|
@@ -773,11 +766,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
773
766
|
)}
|
|
774
767
|
</ScrollView>
|
|
775
768
|
{!loading && !error && product && (
|
|
776
|
-
<ProductActions
|
|
777
|
-
style={{
|
|
778
|
-
paddingBottom: Platform.OS === 'ios' ? bottom + 30 : bottom + 80
|
|
779
|
-
}}
|
|
780
|
-
>
|
|
769
|
+
<ProductActions>
|
|
781
770
|
<OText size={16} lineHeight={24} weight={'600'}>
|
|
782
771
|
{productCart.total ? parsePrice(productCart?.total) : ''}
|
|
783
772
|
</OText>
|
|
@@ -921,7 +910,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
921
910
|
</View>
|
|
922
911
|
</ProductActions>
|
|
923
912
|
)}
|
|
924
|
-
|
|
913
|
+
</SafeAreaView>
|
|
925
914
|
);
|
|
926
915
|
};
|
|
927
916
|
|
|
@@ -5,13 +5,20 @@ export const WrapHeader = styled.View`
|
|
|
5
5
|
z-index: 1;
|
|
6
6
|
`
|
|
7
7
|
|
|
8
|
+
export const TopActions = styled.TouchableOpacity`
|
|
9
|
+
height: 44px;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
padding-horizontal: 30px;
|
|
12
|
+
`;
|
|
13
|
+
|
|
8
14
|
export const TopHeader = styled.View`
|
|
9
15
|
width: 100%;
|
|
10
16
|
flex-direction: row;
|
|
11
17
|
align-items: center;
|
|
12
18
|
justify-content: space-between;
|
|
13
19
|
z-index: 1;
|
|
14
|
-
|
|
20
|
+
height: 60px;
|
|
21
|
+
min-height: 60px;
|
|
15
22
|
`
|
|
16
23
|
|
|
17
24
|
export const ProductHeader = styled.ImageBackground`
|
|
@@ -89,4 +96,4 @@ export const WeightUnitItem = styled.View`
|
|
|
89
96
|
${({ active }: any) => active && css`
|
|
90
97
|
background-color: ${(props: any) => props.theme.colors.primary}20;
|
|
91
98
|
`}
|
|
92
|
-
`
|
|
99
|
+
`
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
UpsellingPage as UpsellingPageController,
|
|
5
5
|
useUtils,
|
|
6
6
|
useLanguage,
|
|
7
|
+
useOrder
|
|
7
8
|
} from 'ordering-components/native'
|
|
8
9
|
import { useTheme } from 'styled-components/native';
|
|
9
|
-
import { OText, OIcon,
|
|
10
|
+
import { OText, OIcon, OBottomPopup, OButton } from '../shared'
|
|
10
11
|
import { UpsellingProductsParams } from '../../types'
|
|
11
12
|
import {
|
|
12
13
|
Container,
|
|
@@ -14,11 +15,9 @@ import {
|
|
|
14
15
|
Item,
|
|
15
16
|
Details,
|
|
16
17
|
AddButton,
|
|
17
|
-
CloseUpselling,
|
|
18
18
|
TopBar,
|
|
19
19
|
TopActions
|
|
20
20
|
} from './styles'
|
|
21
|
-
import { ProductForm } from '../ProductForm';
|
|
22
21
|
import { OrderSummary } from '../OrderSummary';
|
|
23
22
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
24
23
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -28,18 +27,18 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
28
27
|
isCustomMode,
|
|
29
28
|
upsellingProducts,
|
|
30
29
|
business,
|
|
31
|
-
cart,
|
|
32
30
|
handleUpsellingPage,
|
|
33
31
|
handleCloseUpsellingPage,
|
|
34
32
|
openUpselling,
|
|
35
33
|
canOpenUpselling,
|
|
36
34
|
setCanOpenUpselling,
|
|
37
|
-
isFromCart
|
|
35
|
+
isFromCart,
|
|
36
|
+
onNavigationRedirect,
|
|
37
|
+
onGoBack
|
|
38
38
|
} = props
|
|
39
39
|
|
|
40
40
|
const theme = useTheme();
|
|
41
41
|
|
|
42
|
-
|
|
43
42
|
const styles = StyleSheet.create({
|
|
44
43
|
imageStyle: {
|
|
45
44
|
width: 73,
|
|
@@ -66,14 +65,25 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
66
65
|
}
|
|
67
66
|
})
|
|
68
67
|
|
|
69
|
-
const [actualProduct, setActualProduct] = useState<any>(null)
|
|
70
68
|
const [modalIsOpen, setModalIsOpen] = useState(false)
|
|
69
|
+
const [{ carts }] = useOrder()
|
|
71
70
|
const [{ parsePrice }] = useUtils()
|
|
72
71
|
const [, t] = useLanguage()
|
|
73
72
|
const { bottom } = useSafeAreaInsets()
|
|
74
73
|
|
|
74
|
+
const cart = carts?.[`businessId:${props.businessId}`] ?? {}
|
|
75
|
+
const cartProducts = cart?.products?.length
|
|
76
|
+
? cart?.products.map((product: any) => product.id)
|
|
77
|
+
: []
|
|
78
|
+
|
|
79
|
+
const productsList = !upsellingProducts.loading && !upsellingProducts.error
|
|
80
|
+
? upsellingProducts?.products?.length
|
|
81
|
+
? upsellingProducts?.products.filter((product: any) => !cartProducts.includes(product.id))
|
|
82
|
+
: (props?.products ?? []).filter((product: any) => !cartProducts.includes(product.id)) ?? []
|
|
83
|
+
: []
|
|
84
|
+
|
|
75
85
|
useEffect(() => {
|
|
76
|
-
if (!isCustomMode) {
|
|
86
|
+
if (!isCustomMode && !props.products) {
|
|
77
87
|
if (!upsellingProducts.loading) {
|
|
78
88
|
if (upsellingProducts?.products?.length && !isFromCart) {
|
|
79
89
|
setCanOpenUpselling && setCanOpenUpselling(true)
|
|
@@ -81,25 +91,15 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
81
91
|
handleUpsellingPage && handleUpsellingPage()
|
|
82
92
|
}
|
|
83
93
|
}
|
|
84
|
-
// if ((!upsellingProducts?.products?.length && !upsellingProducts.loading && !canOpenUpselling && openUpselling) ||
|
|
85
|
-
// (!upsellingProducts?.products?.length && !upsellingProducts.loading && openUpselling)) {
|
|
86
|
-
// handleUpsellingPage && handleUpsellingPage()
|
|
87
|
-
// }
|
|
88
94
|
}
|
|
89
95
|
}, [upsellingProducts.loading, upsellingProducts?.products.length])
|
|
90
96
|
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
if (!cart?.validate && cart?.products?.length == 0) handleCloseUpsellingPage()
|
|
93
|
-
}, [cart])
|
|
94
|
-
|
|
95
97
|
const handleFormProduct = (product: any) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
setActualProduct(null)
|
|
102
|
-
setModalIsOpen(false)
|
|
98
|
+
onNavigationRedirect && onNavigationRedirect('ProductDetails', {
|
|
99
|
+
product: product,
|
|
100
|
+
businessId: product?.api?.businessId,
|
|
101
|
+
businessSlug: business.slug,
|
|
102
|
+
})
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const UpsellingLayout = () => {
|
|
@@ -114,7 +114,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
114
114
|
!upsellingProducts.loading && (
|
|
115
115
|
<>
|
|
116
116
|
{
|
|
117
|
-
!upsellingProducts.error ?
|
|
117
|
+
!upsellingProducts.error ? productsList.map((product: any) => (
|
|
118
118
|
<Item key={product.id}>
|
|
119
119
|
<View style={{ flexBasis: '57%' }}>
|
|
120
120
|
<Details>
|
|
@@ -125,7 +125,7 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
125
125
|
<OText size={10} color={theme.colors.primary}>{t('ADD', 'Add')}</OText>
|
|
126
126
|
</AddButton>
|
|
127
127
|
</View>
|
|
128
|
-
<View
|
|
128
|
+
<View>
|
|
129
129
|
<OIcon url={product.images} style={styles.imageStyle} />
|
|
130
130
|
</View>
|
|
131
131
|
</Item>
|
|
@@ -143,75 +143,73 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
143
143
|
)
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
const UpsellingContent = () => {
|
|
147
|
+
return (
|
|
148
|
+
<>
|
|
149
|
+
<TopBar style={{ paddingTop: Platform.OS == 'ios' ? 10 : 30 }}>
|
|
150
|
+
<TopActions onPress={() => onGoBack()}>
|
|
151
|
+
<OIcon src={theme.images.general.arrow_left} width={15} />
|
|
152
|
+
</TopActions>
|
|
153
|
+
<TopActions style={styles.cancelBtn} onPress={() => handleUpsellingPage()}>
|
|
154
|
+
<OText size={12} color={theme.colors.textSecondary}>{t('CANCEL', 'Cancel')}</OText>
|
|
155
|
+
</TopActions>
|
|
156
|
+
</TopBar>
|
|
157
|
+
<ScrollView style={{ marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
|
|
158
|
+
{productsList.length > 0 &&
|
|
159
|
+
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
160
|
+
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
161
|
+
<UpsellingLayout />
|
|
162
|
+
</View>
|
|
163
|
+
}
|
|
164
|
+
<View style={{ paddingHorizontal: 40 }}>
|
|
165
|
+
<OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
|
|
166
|
+
<OrderSummary
|
|
167
|
+
cart={cart}
|
|
168
|
+
isCartPending={cart?.status === 2}
|
|
169
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
170
|
+
/>
|
|
171
|
+
</View>
|
|
172
|
+
</ScrollView>
|
|
173
|
+
<View
|
|
174
|
+
style={{
|
|
175
|
+
alignItems: 'center',
|
|
176
|
+
bottom: props.isPage ? 20 : Platform.OS === 'ios' ? bottom + 59 : bottom + 125
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
<OButton
|
|
180
|
+
imgRightSrc=''
|
|
181
|
+
text={t('CHECKOUT', 'Checkout')}
|
|
182
|
+
style={{...styles.closeUpsellingButton}}
|
|
183
|
+
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
184
|
+
onClick={() => handleUpsellingPage()}
|
|
185
|
+
/>
|
|
186
|
+
</View>
|
|
187
|
+
</>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
146
191
|
return (
|
|
147
192
|
<>
|
|
148
193
|
{isCustomMode ? (
|
|
149
194
|
<UpsellingLayout />
|
|
150
195
|
) : (
|
|
151
196
|
<>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<OText size={12} color={theme.colors.textSecondary}>{t('CANCEL', 'Cancel')}</OText>
|
|
167
|
-
</TopActions>
|
|
168
|
-
</TopBar>
|
|
169
|
-
<ScrollView style={{ marginBottom: bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
|
|
170
|
-
{upsellingProducts?.products?.length > 0 &&
|
|
171
|
-
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
172
|
-
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
173
|
-
<UpsellingLayout />
|
|
174
|
-
</View>
|
|
175
|
-
}
|
|
176
|
-
<View style={{ paddingHorizontal: 40 }}>
|
|
177
|
-
<OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
|
|
178
|
-
<OrderSummary
|
|
179
|
-
cart={cart}
|
|
180
|
-
isCartPending={cart?.status === 2}
|
|
181
|
-
/>
|
|
182
|
-
</View>
|
|
183
|
-
</ScrollView>
|
|
184
|
-
<View style={{alignItems: 'center', bottom: Platform.OS === 'ios' ? bottom + 59 : bottom + 125}}>
|
|
185
|
-
<OButton
|
|
186
|
-
imgRightSrc=''
|
|
187
|
-
text={t('CHECKOUT', 'Checkout')}
|
|
188
|
-
style={{...styles.closeUpsellingButton}}
|
|
189
|
-
textStyle={{ color: theme.colors.white, fontSize: 14 }}
|
|
190
|
-
onClick={() => handleUpsellingPage()}
|
|
191
|
-
/>
|
|
192
|
-
</View>
|
|
193
|
-
</OBottomPopup>
|
|
194
|
-
)}
|
|
195
|
-
</>
|
|
196
|
-
)}
|
|
197
|
+
{props.isPage ? (
|
|
198
|
+
<UpsellingContent />
|
|
199
|
+
) : (
|
|
200
|
+
canOpenUpselling && !modalIsOpen && (
|
|
201
|
+
<OBottomPopup
|
|
202
|
+
title={''}
|
|
203
|
+
open={openUpselling}
|
|
204
|
+
onClose={() => handleUpsellingPage()}
|
|
205
|
+
isStatusBar
|
|
206
|
+
>
|
|
207
|
+
<UpsellingContent />
|
|
208
|
+
</OBottomPopup>
|
|
209
|
+
)
|
|
210
|
+
)}
|
|
197
211
|
</>
|
|
198
212
|
)}
|
|
199
|
-
<OModal
|
|
200
|
-
open={modalIsOpen}
|
|
201
|
-
onClose={() => setModalIsOpen(false)}
|
|
202
|
-
entireModal
|
|
203
|
-
customClose
|
|
204
|
-
>
|
|
205
|
-
{actualProduct && (
|
|
206
|
-
<ProductForm
|
|
207
|
-
product={actualProduct}
|
|
208
|
-
businessId={actualProduct?.api?.businessId}
|
|
209
|
-
businessSlug={business.slug}
|
|
210
|
-
onSave={() => handleSaveProduct()}
|
|
211
|
-
onClose={() => setModalIsOpen(false)}
|
|
212
|
-
/>
|
|
213
|
-
)}
|
|
214
|
-
</OModal>
|
|
215
213
|
</>
|
|
216
214
|
)
|
|
217
215
|
}
|
|
@@ -438,6 +438,10 @@ export interface UpsellingProductsParams {
|
|
|
438
438
|
cart?: any;
|
|
439
439
|
handleCloseUpsellingPage: () => void;
|
|
440
440
|
isFromCart?: boolean;
|
|
441
|
+
isPage?: boolean;
|
|
442
|
+
products?: any;
|
|
443
|
+
onNavigationRedirect?: any;
|
|
444
|
+
onGoBack?: any;
|
|
441
445
|
}
|
|
442
446
|
|
|
443
447
|
export interface GoogleMapsParams {
|