ordering-ui-react-native 0.17.36-release → 0.17.37-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
CHANGED
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
useLanguage,
|
|
4
4
|
useConfig,
|
|
5
5
|
useUtils,
|
|
6
|
+
useToast,
|
|
7
|
+
ToastType,
|
|
6
8
|
MultiCartsPaymethodsAndWallets as MultiCartsPaymethodsAndWalletsController
|
|
7
9
|
} from 'ordering-components/native'
|
|
8
10
|
import { useTheme } from 'styled-components/native'
|
|
@@ -45,7 +47,8 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
|
45
47
|
const [, t] = useLanguage()
|
|
46
48
|
const [{ configs }] = useConfig()
|
|
47
49
|
const [{ parsePrice }] = useUtils()
|
|
48
|
-
const {
|
|
50
|
+
const [, { showToast }] = useToast();
|
|
51
|
+
const { confirmApplePayPayment } = useApplePay()
|
|
49
52
|
|
|
50
53
|
const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
|
|
51
54
|
|
|
@@ -91,20 +94,38 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
useEffect(() => {
|
|
94
|
-
|
|
95
|
-
if (typeof paymethodSelected?.paymethod_data === 'string'){
|
|
96
|
-
const sourceId =
|
|
97
|
+
if (methodsPay.includes(paymethodSelected?.gateway)) {
|
|
98
|
+
if (typeof paymethodSelected?.paymethod_data === 'string') {
|
|
99
|
+
const sourceId = JSON.parse(paymethodSelected?.paymethod_data)?.source_id
|
|
97
100
|
sourceId && handlePlaceOrder(confirmApplePayPayment)
|
|
98
101
|
}
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
}
|
|
103
|
+
}, [JSON.stringify(paymethodSelected)])
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (cartTotal === 0) {
|
|
107
|
+
handlePaymethodDataChange(null)
|
|
108
|
+
handleSelectPaymethod(null)
|
|
109
|
+
}
|
|
110
|
+
}, [cartTotal])
|
|
111
|
+
|
|
112
|
+
const handleChangePaymethod = (paymethod: any) => {
|
|
113
|
+
if (cartTotal > 0) {
|
|
114
|
+
handleSelectPaymethod(paymethod)
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
showToast(
|
|
118
|
+
ToastType.Error,
|
|
119
|
+
t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
|
|
120
|
+
;
|
|
121
|
+
}
|
|
101
122
|
|
|
102
123
|
const renderPaymethods = ({ item }: any) => {
|
|
103
124
|
return (
|
|
104
125
|
<>
|
|
105
126
|
{item?.gateway === 'global_apple_pay' ? (
|
|
106
127
|
<TouchableOpacity
|
|
107
|
-
onPress={() =>
|
|
128
|
+
onPress={() => handleChangePaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
|
|
108
129
|
>
|
|
109
130
|
<OIcon
|
|
110
131
|
src={getPayIcon(item.gateway)}
|
|
@@ -115,7 +136,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
|
115
136
|
</TouchableOpacity>
|
|
116
137
|
) : (
|
|
117
138
|
<TouchableOpacity
|
|
118
|
-
onPress={() =>
|
|
139
|
+
onPress={() => handleChangePaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
|
|
119
140
|
>
|
|
120
141
|
<PMItem
|
|
121
142
|
key={item.id}
|
|
@@ -208,9 +229,9 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
|
|
|
208
229
|
handleSource={handlePaymethodDataChange}
|
|
209
230
|
onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
210
231
|
setMethodPaySupported={setMethodPaySupported}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
232
|
+
methodPaySupported={methodPaySupported}
|
|
233
|
+
placeByMethodPay={placeByMethodPay}
|
|
234
|
+
setPlaceByMethodPay={setPlaceByMethodPay}
|
|
214
235
|
methodsPay={methodsPay}
|
|
215
236
|
paymethod={paymethodSelected?.paymethod?.gateway}
|
|
216
237
|
cartTotal={cartTotal}
|
|
@@ -126,6 +126,12 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
126
126
|
;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (cart?.balance === 0) {
|
|
131
|
+
handlePaymethodClick(null)
|
|
132
|
+
}
|
|
133
|
+
}, [cart?.balance])
|
|
134
|
+
|
|
129
135
|
useEffect(() => {
|
|
130
136
|
if (paymethodsList.paymethods.length === 1) {
|
|
131
137
|
handlePaymethodClick && handlePaymethodClick(paymethodsList.paymethods[0])
|
|
@@ -339,7 +345,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
339
345
|
onPaymentChange={onPaymentChange}
|
|
340
346
|
payType={isOpenMethod?.paymethod?.name}
|
|
341
347
|
onSelectCard={handlePaymethodDataChange}
|
|
342
|
-
addCardOpen={addCardOpen}
|
|
348
|
+
addCardOpen={addCardOpen}
|
|
343
349
|
setAddCardOpen={setAddCardOpen}
|
|
344
350
|
onCancel={() => handlePaymethodClick(null)}
|
|
345
351
|
paymethodSelected={paymethodSelected?.data?.id}
|