ordering-ui-react-native 0.21.88 → 0.21.89
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
CHANGED
|
@@ -118,14 +118,14 @@ const ProfileUI = (props: ProfileParams) => {
|
|
|
118
118
|
includeBase64: true,
|
|
119
119
|
},
|
|
120
120
|
(image: any) => {
|
|
121
|
-
const response = image?.assets[0];
|
|
122
|
-
if (response
|
|
121
|
+
const response = image?.assets?.[0];
|
|
122
|
+
if (response?.didCancel) {
|
|
123
123
|
console.log('User cancelled image picker');
|
|
124
|
-
} else if (response
|
|
124
|
+
} else if (response?.errorMessage) {
|
|
125
125
|
console.log('ImagePicker Error: ', response.errorMessage);
|
|
126
126
|
showToast(ToastType.Error, response.errorMessage);
|
|
127
127
|
} else {
|
|
128
|
-
if (response
|
|
128
|
+
if (response?.uri) {
|
|
129
129
|
const url = `data:${response.type};base64,${response.base64}`;
|
|
130
130
|
handleButtonUpdateClick(null, true, url);
|
|
131
131
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { useLanguage, useConfig, useUtils, useOrder } from 'ordering-components/native';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
@@ -13,7 +13,8 @@ export const CartContent = (props: any) => {
|
|
|
13
13
|
const {
|
|
14
14
|
onNavigationRedirect,
|
|
15
15
|
singleBusiness,
|
|
16
|
-
businessSlug
|
|
16
|
+
businessSlug,
|
|
17
|
+
navigation
|
|
17
18
|
} = props
|
|
18
19
|
|
|
19
20
|
const theme = useTheme();
|
|
@@ -22,7 +23,7 @@ export const CartContent = (props: any) => {
|
|
|
22
23
|
const [{ parsePrice }] = useUtils();
|
|
23
24
|
const [isCartsLoading, setIsCartsLoading] = useState(false)
|
|
24
25
|
const [cartsOpened, setCartsOpened] = useState([])
|
|
25
|
-
const [{ carts: cartsContext }] = useOrder();
|
|
26
|
+
const [{ carts: cartsContext }, { confirmCart }] = useOrder();
|
|
26
27
|
const cartsList =
|
|
27
28
|
(cartsContext &&
|
|
28
29
|
Object.values(cartsContext).filter((cart: any) => cart.products.length > 0)) ??
|
|
@@ -71,7 +72,7 @@ export const CartContent = (props: any) => {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
const changeActiveState = useCallback((isClosed
|
|
75
|
+
const changeActiveState = useCallback((isClosed: boolean, uuid: string) => {
|
|
75
76
|
const isActive = cartsOpened?.includes?.(uuid) || !!singleBusiness
|
|
76
77
|
if (isActive || !isClosed) {
|
|
77
78
|
setCartsOpened(cartsOpened?.filter?.((_uuid) => _uuid !== uuid))
|
|
@@ -83,6 +84,20 @@ export const CartContent = (props: any) => {
|
|
|
83
84
|
}
|
|
84
85
|
}, [cartsOpened])
|
|
85
86
|
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const unsuscribe = navigation.addListener('focus', () => {
|
|
89
|
+
const cartsListBlockedByPaypal = carts?.filter((cart: any) => cart?.status === 2 && cart?.paymethod_data?.gateway === 'paypal')
|
|
90
|
+
if (cartsListBlockedByPaypal?.length > 0) {
|
|
91
|
+
cartsListBlockedByPaypal.map(async (cart: any) => {
|
|
92
|
+
await confirmCart(cart?.uuid)
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
return () => {
|
|
97
|
+
return unsuscribe()
|
|
98
|
+
}
|
|
99
|
+
}, [carts, navigation])
|
|
100
|
+
|
|
86
101
|
return (
|
|
87
102
|
<CCContainer
|
|
88
103
|
style={{ paddingHorizontal: 20 }}
|