import { HexString } from '@gear-js/api'; import { useApi } from '@gear-js/react-hooks'; import { Button, Modal } from '@gear-js/ui'; import { useModalState, useSignAndSend } from '@/hooks'; import CloseSVG from '@/shared/assets/images/actions/close.svg?react'; import RemoveSVG from '@/shared/assets/images/actions/remove.svg?react'; import styles from './revoke-voucher.module.scss'; type Props = { spender: HexString; id: HexString; onSubmit: () => void; }; const RevokeVoucher = ({ spender, id, onSubmit }: Props) => { const { isApiReady, api } = useApi(); const signAndSend = useSignAndSend(); const [isModalOpen, openModal, closeModal] = useModalState(); const handleSubmitClick = () => { if (!isApiReady) throw new Error('API is not initialized'); const extrinsic = api.voucher.revoke(spender, id); const onSuccess = onSubmit; signAndSend(extrinsic, 'VoucherRevoked', { onSuccess }); closeModal(); }; return ( <> {isModalOpen && ( This action cannot be undone. If you change your mind, you'll need to issue a new voucher manually. )} > ); }; export { RevokeVoucher };
This action cannot be undone. If you change your mind, you'll need to issue a new voucher manually.