import { ContextModalProps } from "@mantine/modals";
import { Button, Stack, TextInput } from "@mantine/core";
import { BoardSchema } from "../../../../client";
import useBoardModal from "./hooks/useBoardModal.tsx";

type Props = {
    projectId: number;
    board?: BoardSchema;
    refetchBoards: () => void;
};

const BoardModal = ({
                        context,
                        id,
                        innerProps,
                    }: ContextModalProps<Props>) => {
    const closeModal = () => context.closeContextModal(id);

    const {
        form,
        onSubmit,
    } = useBoardModal({
        ...innerProps,
        closeModal,
    });

    return (
        <form onSubmit={form.onSubmit(values => onSubmit(values))}>
            <Stack>
                <TextInput
                    {...form.getInputProps("name")}
                    label={"Название"}
                    placeholder={"Введите название"}
                />
                <Button
                    type={"submit"}
                    variant={"default"}
                >
                    Сохранить
                </Button>
            </Stack>
        </form>
    );
};

export default BoardModal;
