mirror of
https://github.com/valitydev/checkout.git
synced 2024-11-06 02:25:18 +00:00
Fix is last condition is nil (#347)
This commit is contained in:
parent
9afbafa386
commit
7355f9a41d
@ -1,7 +1,7 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { InvoiceStatusChanged, PaymentCondition, PaymentStatusChanged } from 'checkout/paymentCondition';
|
||||
import { last, sendPostMessage } from 'checkout/utils';
|
||||
import { isNil, last, sendPostMessage } from 'checkout/utils';
|
||||
|
||||
const handlePaymentStatusChanged = (condition: PaymentStatusChanged) => {
|
||||
switch (condition.status) {
|
||||
@ -29,6 +29,7 @@ const handleInvoiceStatusChanged = (condition: InvoiceStatusChanged) => {
|
||||
export function usePostMessage(conditions: PaymentCondition[]) {
|
||||
useEffect(() => {
|
||||
const lastCondition = last(conditions);
|
||||
if (isNil(lastCondition)) return;
|
||||
switch (lastCondition.name) {
|
||||
case 'paymentProcessFailed':
|
||||
sendPostMessage('onError');
|
||||
|
Loading…
Reference in New Issue
Block a user