import { FC } from "react";
import { IconPlus } from "@tabler/icons-react";
import { Box, Group, Text } from "@mantine/core";
import { modals } from "@mantine/modals";
import { CreateBoardSchema } from "@/lib/client";

type Props = {
    onCreateBoard: (data: Partial<CreateBoardSchema>) => void;
};

const CreateBoardButton: FC<Props> = ({ onCreateBoard }) => {
    const onStartCreating = () => {
        modals.openContextModal({
            modal: "enterNameModal",
            title: "Создание доски",
            withCloseButton: true,
            innerProps: {
                onChange: values => onCreateBoard(values),
            },
        });
    };

    return (
        <Group
            ml={"xs"}
            onClick={onStartCreating}>
            <IconPlus />
            <Box mt={5}>
                <Text>Создать доску</Text>
            </Box>
        </Group>
    );
};

export default CreateBoardButton;
