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

type Props = {
    boardId?: number;
    status?: StatusSchema;
    refetch: () => void;
};

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

    const {
        form,
        onSubmit,
    } = useStatusModal({
        ...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 StatusModal;
