2022-01-12 17:17:07 +01:00
|
|
|
import {
|
|
|
|
PaymentMethod,
|
|
|
|
PaymentSchedule,
|
2023-02-17 16:07:18 +01:00
|
|
|
PaymentScheduleItem
|
2022-01-12 17:17:07 +01:00
|
|
|
} from '../../models/payment-schedule';
|
2022-11-16 10:08:09 +01:00
|
|
|
import { ReactElement, useState } from 'react';
|
|
|
|
import * as React from 'react';
|
2022-01-11 18:41:04 +01:00
|
|
|
import { FabButton } from '../base/fab-button';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2022-05-09 12:11:37 +02:00
|
|
|
import { User } from '../../models/user';
|
2022-01-12 17:17:07 +01:00
|
|
|
import PaymentScheduleAPI from '../../api/payment-schedule';
|
|
|
|
import { FabModal } from '../base/fab-modal';
|
|
|
|
import FormatLib from '../../lib/format';
|
|
|
|
import { StripeConfirmModal } from '../payment/stripe/stripe-confirm-modal';
|
|
|
|
import { UpdateCardModal } from '../payment/update-card-modal';
|
2022-01-17 12:38:53 +01:00
|
|
|
import { UpdatePaymentMeanModal } from './update-payment-mean-modal';
|
2022-01-11 18:41:04 +01:00
|
|
|
|
|
|
|
// we want to display some buttons only once. This is the types of buttons it applies to.
|
2023-02-17 16:07:18 +01:00
|
|
|
export type TypeOnce = 'card-update'|'subscription-cancel'|'update-payment-mean';
|
2022-01-11 18:41:04 +01:00
|
|
|
|
|
|
|
interface PaymentScheduleItemActionsProps {
|
|
|
|
paymentScheduleItem: PaymentScheduleItem,
|
2022-01-12 17:17:07 +01:00
|
|
|
paymentSchedule: PaymentSchedule,
|
2022-01-11 18:41:04 +01:00
|
|
|
onError: (message: string) => void,
|
2022-01-12 17:17:07 +01:00
|
|
|
onSuccess: () => void,
|
|
|
|
onCardUpdateSuccess: () => void
|
2022-01-11 18:41:04 +01:00
|
|
|
operator: User,
|
2022-01-17 10:48:23 +01:00
|
|
|
displayOnceMap: Map<TypeOnce, Map<number, number>>,
|
|
|
|
show: boolean,
|
2022-01-11 18:41:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This component is responsible for rendering the actions buttons for a payment schedule item.
|
|
|
|
*/
|
2022-01-17 10:48:23 +01:00
|
|
|
export const PaymentScheduleItemActions: React.FC<PaymentScheduleItemActionsProps> = ({ paymentScheduleItem, paymentSchedule, onError, onSuccess, onCardUpdateSuccess, displayOnceMap, operator, show }) => {
|
2022-01-11 18:41:04 +01:00
|
|
|
const { t } = useTranslation('shared');
|
|
|
|
|
|
|
|
// is open, the modal dialog to cancel the associated subscription?
|
|
|
|
const [showCancelSubscription, setShowCancelSubscription] = useState<boolean>(false);
|
|
|
|
// is open, the modal dialog to confirm the cashing of a check?
|
|
|
|
const [showConfirmCashing, setShowConfirmCashing] = useState<boolean>(false);
|
|
|
|
// is open, the modal dialog to confirm a back transfer?
|
|
|
|
const [showConfirmTransfer, setShowConfirmTransfer] = useState<boolean>(false);
|
|
|
|
// is open, the modal dialog the resolve a pending card payment?
|
|
|
|
const [showResolveAction, setShowResolveAction] = useState<boolean>(false);
|
2022-01-12 17:17:07 +01:00
|
|
|
// is open, the modal dialog to update the card details
|
|
|
|
const [showUpdateCard, setShowUpdateCard] = useState<boolean>(false);
|
2022-01-17 12:38:53 +01:00
|
|
|
// is open, the modal dialog to update the payment mean
|
|
|
|
const [showUpdatePaymentMean, setShowUpdatePaymentMean] = useState<boolean>(false);
|
2022-01-12 17:17:07 +01:00
|
|
|
// the user cannot confirm the action modal (3D secure), unless he has resolved the pending action
|
|
|
|
const [isConfirmActionDisabled, setConfirmActionDisabled] = useState<boolean>(true);
|
2022-01-11 18:41:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the current operator has administrative rights or is a normal member
|
|
|
|
*/
|
|
|
|
const isPrivileged = (): boolean => {
|
2023-04-17 12:20:36 +02:00
|
|
|
return (operator?.role === 'admin' || operator?.role === 'manager');
|
2022-01-11 18:41:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a button to download a PDF invoice file
|
|
|
|
*/
|
|
|
|
const downloadInvoiceButton = (id: number): JSX.Element => {
|
|
|
|
const link = `api/invoices/${id}/download`;
|
|
|
|
return (
|
|
|
|
<a href={link} target="_blank" className="download-button" rel="noreferrer">
|
|
|
|
<i className="fas fa-download" />
|
|
|
|
{t('app.shared.payment_schedule_item_actions.download')}
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a button to cancel the given subscription, if the user is privileged enough
|
|
|
|
*/
|
2022-01-12 17:17:07 +01:00
|
|
|
const cancelSubscriptionButton = (): ReactElement => {
|
2023-02-17 16:07:18 +01:00
|
|
|
const displayOnceStatus = displayOnceMap.get('subscription-cancel').get(paymentSchedule.id);
|
2022-01-17 10:48:23 +01:00
|
|
|
if (isPrivileged() && (!displayOnceStatus || displayOnceStatus === paymentScheduleItem.id)) {
|
2023-02-17 16:07:18 +01:00
|
|
|
displayOnceMap.get('subscription-cancel').set(paymentSchedule.id, paymentScheduleItem.id);
|
2022-01-11 18:41:04 +01:00
|
|
|
return (
|
2022-01-17 10:48:23 +01:00
|
|
|
<FabButton key={`cancel-subscription-${paymentSchedule.id}`}
|
|
|
|
onClick={toggleCancelSubscriptionModal}
|
2022-01-11 18:41:04 +01:00
|
|
|
icon={<i className="fas fa-times" />}>
|
|
|
|
{t('app.shared.payment_schedule_item_actions.cancel_subscription')}
|
|
|
|
</FabButton>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-12 17:17:07 +01:00
|
|
|
/**
|
|
|
|
* Return a button to confirm the receipt of the bank transfer, if the user is privileged enough
|
|
|
|
*/
|
2022-01-11 18:41:04 +01:00
|
|
|
const confirmTransferButton = (): ReactElement => {
|
2022-01-12 17:17:07 +01:00
|
|
|
if (isPrivileged()) {
|
|
|
|
return (
|
2022-01-17 10:48:23 +01:00
|
|
|
<FabButton key={`confirm-transfer-${paymentScheduleItem.id}`}
|
|
|
|
onClick={toggleConfirmTransferModal}
|
2022-01-12 17:17:07 +01:00
|
|
|
icon={<i className="fas fa-university"/>}>
|
|
|
|
{t('app.shared.payment_schedule_item_actions.confirm_payment')}
|
|
|
|
</FabButton>
|
|
|
|
);
|
|
|
|
}
|
2022-01-11 18:41:04 +01:00
|
|
|
};
|
|
|
|
|
2022-01-12 17:17:07 +01:00
|
|
|
/**
|
|
|
|
* Return a button to confirm the cashing of the check, if the user is privileged enough
|
|
|
|
*/
|
2022-01-11 18:41:04 +01:00
|
|
|
const confirmCheckButton = (): ReactElement => {
|
2022-01-12 17:17:07 +01:00
|
|
|
if (isPrivileged()) {
|
|
|
|
return (
|
2022-01-17 10:48:23 +01:00
|
|
|
<FabButton key={`confirm-check-${paymentScheduleItem.id}`}
|
|
|
|
onClick={toggleConfirmCashingModal}
|
2022-01-12 17:17:07 +01:00
|
|
|
icon={<i className="fas fa-check"/>}>
|
|
|
|
{t('app.shared.payment_schedule_item_actions.confirm_check')}
|
|
|
|
</FabButton>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a button to resolve the 3DS security check
|
|
|
|
*/
|
|
|
|
const solveActionButton = (): ReactElement => {
|
2022-01-11 18:41:04 +01:00
|
|
|
return (
|
2022-01-17 10:48:23 +01:00
|
|
|
<FabButton key={`solve-action-${paymentScheduleItem.id}`}
|
|
|
|
onClick={toggleResolveActionModal}
|
2022-01-12 17:17:07 +01:00
|
|
|
icon={<i className="fas fa-wrench"/>}>
|
|
|
|
{t('app.shared.payment_schedule_item_actions.resolve_action')}
|
2022-01-11 18:41:04 +01:00
|
|
|
</FabButton>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-01-17 12:38:53 +01:00
|
|
|
/**
|
|
|
|
* Return a button to update the default payment mean for the current payment schedule
|
|
|
|
*/
|
|
|
|
const updatePaymentMeanButton = (): ReactElement => {
|
2023-02-17 16:07:18 +01:00
|
|
|
const displayOnceStatus = displayOnceMap.get('update-payment-mean').get(paymentSchedule.id);
|
2022-01-17 12:38:53 +01:00
|
|
|
if (isPrivileged() && (!displayOnceStatus || displayOnceStatus === paymentScheduleItem.id)) {
|
2023-02-17 16:07:18 +01:00
|
|
|
displayOnceMap.get('update-payment-mean').set(paymentSchedule.id, paymentScheduleItem.id);
|
2022-01-17 12:38:53 +01:00
|
|
|
return (
|
|
|
|
<FabButton key={`update-payment-mean-${paymentScheduleItem.id}`}
|
|
|
|
onClick={toggleUpdatePaymentMeanModal}
|
|
|
|
icon={<i className="fas fa-money-bill-alt" />}>
|
|
|
|
{t('app.shared.payment_schedule_item_actions.update_payment_mean')}
|
|
|
|
</FabButton>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-01-12 17:17:07 +01:00
|
|
|
/**
|
|
|
|
* Return a button to update the credit card associated with the payment schedule
|
|
|
|
*/
|
|
|
|
const updateCardButton = (): ReactElement => {
|
2023-02-17 16:07:18 +01:00
|
|
|
const displayOnceStatus = displayOnceMap.get('card-update').get(paymentSchedule.id);
|
|
|
|
if (!displayOnceStatus || displayOnceStatus === paymentScheduleItem.id) {
|
|
|
|
displayOnceMap.get('card-update').set(paymentSchedule.id, paymentScheduleItem.id);
|
2022-01-12 17:17:07 +01:00
|
|
|
return (
|
2022-01-17 10:48:23 +01:00
|
|
|
<FabButton key={`update-card-${paymentSchedule.id}`}
|
|
|
|
onClick={toggleUpdateCardModal}
|
2022-01-12 17:17:07 +01:00
|
|
|
icon={<i className="fas fa-credit-card"/>}>
|
|
|
|
{t('app.shared.payment_schedule_item_actions.update_card')}
|
|
|
|
</FabButton>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the actions button(s) for current paymentScheduleItem with state Pending
|
|
|
|
*/
|
|
|
|
const pendingActions = (): ReactElement => {
|
|
|
|
if (isPrivileged()) {
|
|
|
|
if (paymentSchedule.payment_method === PaymentMethod.Transfer) {
|
|
|
|
return confirmTransferButton();
|
|
|
|
}
|
|
|
|
if (paymentSchedule.payment_method === PaymentMethod.Check) {
|
|
|
|
return confirmCheckButton();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return <span>{t('app.shared.payment_schedule_item_actions.please_ask_reception')}</span>;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the actions button(s) for current paymentScheduleItem with state Error or GatewayCanceled
|
|
|
|
*/
|
2022-01-17 12:38:53 +01:00
|
|
|
const errorActions = (): ReactElement[] => {
|
2022-01-12 17:17:07 +01:00
|
|
|
// if the payment schedule is canceled/in error, the schedule is over, and we can't update the card
|
2023-02-17 16:07:18 +01:00
|
|
|
displayOnceMap.get('card-update').set(paymentSchedule.id, paymentScheduleItem.id);
|
2022-01-17 12:38:53 +01:00
|
|
|
|
|
|
|
const buttons = [];
|
2022-01-12 17:17:07 +01:00
|
|
|
if (isPrivileged()) {
|
2022-01-17 12:38:53 +01:00
|
|
|
buttons.push(cancelSubscriptionButton());
|
|
|
|
buttons.push(updatePaymentMeanButton());
|
2022-01-12 17:17:07 +01:00
|
|
|
} else {
|
2022-01-17 12:38:53 +01:00
|
|
|
buttons.push(<span>{t('app.shared.payment_schedule_item_actions.please_ask_reception')}</span>);
|
2022-01-12 17:17:07 +01:00
|
|
|
}
|
2022-01-17 12:38:53 +01:00
|
|
|
return buttons;
|
2022-01-12 17:17:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the actions button(s) for current paymentScheduleItem with state New
|
|
|
|
*/
|
|
|
|
const newActions = (): Array<ReactElement> => {
|
|
|
|
const buttons = [];
|
|
|
|
if (paymentSchedule.payment_method === PaymentMethod.Card) {
|
|
|
|
buttons.push(updateCardButton());
|
|
|
|
}
|
|
|
|
if (isPrivileged()) {
|
|
|
|
buttons.push(cancelSubscriptionButton());
|
|
|
|
}
|
|
|
|
return buttons;
|
|
|
|
};
|
|
|
|
|
2022-01-11 18:41:04 +01:00
|
|
|
/**
|
|
|
|
* Show/hide the modal dialog to cancel the current subscription
|
|
|
|
*/
|
|
|
|
const toggleCancelSubscriptionModal = (): void => {
|
|
|
|
setShowCancelSubscription(!showCancelSubscription);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show/hide the modal dialog that enable to confirm the cashing of the check for a given deadline.
|
|
|
|
*/
|
|
|
|
const toggleConfirmCashingModal = (): void => {
|
|
|
|
setShowConfirmCashing(!showConfirmCashing);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show/hide the modal dialog that enable to confirm the bank transfer for a given deadline.
|
|
|
|
*/
|
|
|
|
const toggleConfirmTransferModal = (): void => {
|
|
|
|
setShowConfirmTransfer(!showConfirmTransfer);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show/hide the modal dialog that trigger the card "action".
|
|
|
|
*/
|
|
|
|
const toggleResolveActionModal = (): void => {
|
|
|
|
setShowResolveAction(!showResolveAction);
|
|
|
|
};
|
|
|
|
|
2022-01-12 17:17:07 +01:00
|
|
|
/**
|
|
|
|
* Enable/disable the confirm button of the "action" modal
|
|
|
|
*/
|
|
|
|
const toggleConfirmActionButton = (): void => {
|
|
|
|
setConfirmActionDisabled(!isConfirmActionDisabled);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show/hide the modal dialog to update the bank card details
|
|
|
|
*/
|
|
|
|
const toggleUpdateCardModal = (): void => {
|
|
|
|
setShowUpdateCard(!showUpdateCard);
|
|
|
|
};
|
|
|
|
|
2022-01-17 12:38:53 +01:00
|
|
|
/**
|
|
|
|
* Show/hide the modal dialog to update the payment mean
|
|
|
|
*/
|
|
|
|
const toggleUpdatePaymentMeanModal = (): void => {
|
|
|
|
setShowUpdatePaymentMean(!showUpdatePaymentMean);
|
|
|
|
};
|
|
|
|
|
2022-01-12 17:17:07 +01:00
|
|
|
/**
|
|
|
|
* After the user has confirmed that he wants to cash the check, update the API, refresh the list and close the modal.
|
|
|
|
*/
|
|
|
|
const onCheckCashingConfirmed = (): void => {
|
|
|
|
PaymentScheduleAPI.cashCheck(paymentScheduleItem.id).then((res) => {
|
2023-02-17 16:07:18 +01:00
|
|
|
if (res.state === 'paid') {
|
2022-01-12 17:17:07 +01:00
|
|
|
onSuccess();
|
|
|
|
toggleConfirmCashingModal();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2022-01-11 18:41:04 +01:00
|
|
|
|
2022-01-12 17:17:07 +01:00
|
|
|
/**
|
2022-01-17 12:38:53 +01:00
|
|
|
* After the user has confirmed that he validates the transfer, update the API, refresh the list and close the modal.
|
2022-01-12 17:17:07 +01:00
|
|
|
*/
|
|
|
|
const onTransferConfirmed = (): void => {
|
2022-01-17 12:38:53 +01:00
|
|
|
PaymentScheduleAPI.confirmTransfer(paymentScheduleItem.id).then((res) => {
|
2023-02-17 16:07:18 +01:00
|
|
|
if (res.state === 'paid') {
|
2022-01-12 17:17:07 +01:00
|
|
|
onSuccess();
|
|
|
|
toggleConfirmTransferModal();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When the card was successfully updated, pay the invoice (using the new payment method) and close the modal
|
|
|
|
*/
|
|
|
|
const handleCardUpdateSuccess = (): void => {
|
2023-02-17 16:07:18 +01:00
|
|
|
if (paymentScheduleItem.state === 'requires_payment_method') {
|
2022-01-12 17:17:07 +01:00
|
|
|
PaymentScheduleAPI.payItem(paymentScheduleItem.id).then(() => {
|
|
|
|
onSuccess();
|
|
|
|
onCardUpdateSuccess();
|
|
|
|
toggleUpdateCardModal();
|
|
|
|
}).catch((err) => {
|
|
|
|
onError(err);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// the user is updating his card number in a pro-active way, we don't need to trigger the payment
|
|
|
|
onCardUpdateSuccess();
|
|
|
|
toggleUpdateCardModal();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When the user has confirmed the cancellation, we transfer the request to the API
|
|
|
|
*/
|
|
|
|
const onCancelSubscriptionConfirmed = (): void => {
|
|
|
|
PaymentScheduleAPI.cancel(paymentSchedule.id).then(() => {
|
|
|
|
onSuccess();
|
|
|
|
toggleCancelSubscriptionModal();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* After the 3DS confirmation was done (successfully or not), ask the API to refresh the item status,
|
|
|
|
* then refresh the list and close the modal
|
|
|
|
*/
|
|
|
|
const afterConfirmAction = (): void => {
|
|
|
|
toggleConfirmActionButton();
|
|
|
|
PaymentScheduleAPI.refreshItem(paymentScheduleItem.id).then(() => {
|
|
|
|
onSuccess();
|
|
|
|
toggleResolveActionModal();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-01-17 12:38:53 +01:00
|
|
|
/**
|
|
|
|
* When the update of the payment mean was successful, refresh the list and close the modal
|
|
|
|
*/
|
|
|
|
const onPaymentMeanUpdateSuccess = (): void => {
|
|
|
|
onSuccess();
|
|
|
|
toggleUpdatePaymentMeanModal();
|
|
|
|
};
|
|
|
|
|
2022-01-17 10:48:23 +01:00
|
|
|
if (!show) return null;
|
2022-01-12 17:17:07 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<span className="payment-schedule-item-actions">
|
2023-02-17 16:07:18 +01:00
|
|
|
{paymentScheduleItem.state === 'paid' && downloadInvoiceButton(paymentScheduleItem.invoice_id)}
|
|
|
|
{paymentScheduleItem.state === 'pending' && pendingActions()}
|
|
|
|
{paymentScheduleItem.state === 'requires_action' && solveActionButton()}
|
|
|
|
{paymentScheduleItem.state === 'requires_payment_method' && updateCardButton()}
|
|
|
|
{paymentScheduleItem.state === 'error' && errorActions()}
|
|
|
|
{paymentScheduleItem.state === 'gateway_canceled' && errorActions()}
|
|
|
|
{paymentScheduleItem.state === 'new' && newActions()}
|
2022-01-12 17:17:07 +01:00
|
|
|
<div className="modals">
|
|
|
|
{/* Confirm the cashing of the current deadline by check */}
|
2022-01-17 10:48:23 +01:00
|
|
|
<FabModal title={t('app.shared.payment_schedule_item_actions.confirm_check_cashing')}
|
2022-01-12 17:17:07 +01:00
|
|
|
isOpen={showConfirmCashing}
|
|
|
|
toggleModal={toggleConfirmCashingModal}
|
|
|
|
onConfirm={onCheckCashingConfirmed}
|
|
|
|
closeButton={true}
|
2022-01-17 10:48:23 +01:00
|
|
|
confirmButton={t('app.shared.payment_schedule_item_actions.confirm_button')}>
|
2022-01-12 17:17:07 +01:00
|
|
|
<span>
|
2022-01-17 10:48:23 +01:00
|
|
|
{t('app.shared.payment_schedule_item_actions.confirm_check_cashing_body', {
|
2022-01-12 17:17:07 +01:00
|
|
|
AMOUNT: FormatLib.price(paymentScheduleItem.amount),
|
|
|
|
DATE: FormatLib.date(paymentScheduleItem.due_date)
|
|
|
|
})}
|
|
|
|
</span>
|
|
|
|
</FabModal>
|
|
|
|
{/* Confirm the bank transfer for the current deadline */}
|
2022-01-17 10:48:23 +01:00
|
|
|
<FabModal title={t('app.shared.payment_schedule_item_actions.confirm_bank_transfer')}
|
2022-01-12 17:17:07 +01:00
|
|
|
isOpen={showConfirmTransfer}
|
|
|
|
toggleModal={toggleConfirmTransferModal}
|
|
|
|
onConfirm={onTransferConfirmed}
|
|
|
|
closeButton={true}
|
2022-01-17 10:48:23 +01:00
|
|
|
confirmButton={t('app.shared.payment_schedule_item_actions.confirm_button')}>
|
2022-01-12 17:17:07 +01:00
|
|
|
<span>
|
2022-01-17 10:48:23 +01:00
|
|
|
{t('app.shared.payment_schedule_item_actions.confirm_bank_transfer_body', {
|
2022-01-12 17:17:07 +01:00
|
|
|
AMOUNT: FormatLib.price(paymentScheduleItem.amount),
|
|
|
|
DATE: FormatLib.date(paymentScheduleItem.due_date)
|
|
|
|
})}
|
|
|
|
</span>
|
|
|
|
</FabModal>
|
|
|
|
{/* Cancel the subscription */}
|
2022-01-17 10:48:23 +01:00
|
|
|
<FabModal title={t('app.shared.payment_schedule_item_actions.cancel_subscription')}
|
2022-01-12 17:17:07 +01:00
|
|
|
isOpen={showCancelSubscription}
|
|
|
|
toggleModal={toggleCancelSubscriptionModal}
|
|
|
|
onConfirm={onCancelSubscriptionConfirmed}
|
|
|
|
closeButton={true}
|
2022-01-17 10:48:23 +01:00
|
|
|
confirmButton={t('app.shared.payment_schedule_item_actions.confirm_button')}>
|
|
|
|
{t('app.shared.payment_schedule_item_actions.confirm_cancel_subscription')}
|
2022-01-12 17:17:07 +01:00
|
|
|
</FabModal>
|
2022-01-17 10:48:23 +01:00
|
|
|
{/* 3D secure confirmation */}
|
|
|
|
<StripeConfirmModal isOpen={showResolveAction}
|
|
|
|
toggleModal={toggleResolveActionModal}
|
|
|
|
onSuccess={afterConfirmAction}
|
|
|
|
paymentScheduleItemId={paymentScheduleItem.id} />
|
|
|
|
{/* Update credit card */}
|
|
|
|
<UpdateCardModal isOpen={showUpdateCard}
|
|
|
|
toggleModal={toggleUpdateCardModal}
|
|
|
|
operator={operator}
|
|
|
|
afterSuccess={handleCardUpdateSuccess}
|
|
|
|
onError={onError}
|
|
|
|
schedule={paymentSchedule}>
|
|
|
|
</UpdateCardModal>
|
2022-01-17 12:38:53 +01:00
|
|
|
{/* Update the payment mean */}
|
|
|
|
<UpdatePaymentMeanModal isOpen={showUpdatePaymentMean}
|
|
|
|
toggleModal={toggleUpdatePaymentMeanModal}
|
|
|
|
onError={onError}
|
|
|
|
afterSuccess={onPaymentMeanUpdateSuccess}
|
|
|
|
paymentSchedule={paymentSchedule} />
|
2022-01-12 17:17:07 +01:00
|
|
|
</div>
|
|
|
|
</span>
|
2022-01-11 18:41:04 +01:00
|
|
|
);
|
|
|
|
};
|
2022-01-17 10:48:23 +01:00
|
|
|
|
|
|
|
PaymentScheduleItemActions.defaultProps = { show: false };
|