Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x | import { memo, useCallback } from 'react';
import { FormattedMessage } from 'react-intl';
import { Modal, type ModalProps } from '@allshares/studio-design-system';
import { type Plan } from '@amalia/payout-definition/plans/types';
import { useDeletePlan } from '@amalia/payout-definition/state';
export type DeletePlanConfirmModalProps = Pick<ModalProps, 'isOpen' | 'onClose'> & {
readonly plan: Pick<Plan, 'id' | 'name'>;
readonly onSuccess?: () => void;
};
export const DeletePlanConfirmModal = memo(function DeletePlanConfirmModal({
plan,
isOpen,
onClose,
onSuccess,
}: DeletePlanConfirmModalProps) {
const { mutate: deletePlan, isPending } = useDeletePlan();
const handleDeletePlan = useCallback(() => deletePlan(plan.id, { onSuccess }), [plan.id, deletePlan, onSuccess]);
return (
<Modal
isOpen={isOpen}
variant="danger"
onClose={onClose}
>
<Modal.Content>
<Modal.Header>
<Modal.Title>
<FormattedMessage defaultMessage="Delete plan" />
</Modal.Title>
</Modal.Header>
<Modal.Body>
<FormattedMessage
defaultMessage="Are you sure you want to delete the plan “<b>{planName}</b>”?"
values={{ planName: plan.name, b: (chunks) => <strong>{chunks}</strong> }}
/>
</Modal.Body>
</Modal.Content>
<Modal.Actions>
<Modal.CancelAction />
<Modal.MainAction
isLoading={isPending}
onClick={handleDeletePlan}
>
<FormattedMessage defaultMessage="Delete" />
</Modal.MainAction>
</Modal.Actions>
</Modal>
);
});
|