42 lines
983 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { AddBankCardForm } from '@/entity/cards';
import { Modal } from '@/shared/ui/Modal';
import { useAddBankCardButton } from '../hooks/useAddBankCardButton';
import type { ButtonHTMLAttributes, FC, Ref } from 'react';
type AddBankCardButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
ref?: Ref<HTMLButtonElement>;
};
const AddBankCardButton: FC<AddBankCardButtonProps> = (props) => {
const { ref, onClick, ...restProps } = props;
const {
isOpen,
isPending,
onCloseModalHandler,
onClickHandler,
onFormSubmitHandler,
} = useAddBankCardButton({ onClick });
return (
<>
<button
ref={ref}
type="button"
onClick={onClickHandler}
{...restProps}
>
Добавить
</button>
<Modal open={isOpen} onClose={onCloseModalHandler}>
<AddBankCardForm disabled={isPending} onSubmit={onFormSubmitHandler} />
</Modal>
</>
);
};
export default AddBankCardButton;