import { useState } from "react"; import { IconCheck, IconPlus, IconX } from "@tabler/icons-react"; import { Box, Group, TextInput } from "@mantine/core"; import { useBoardsContext } from "@/app/deals/contexts/BoardsContext"; const CreateBoardButton = () => { const { onCreateBoard } = useBoardsContext(); const [isWriting, setIsWriting] = useState(false); const [name, setName] = useState(""); const onStartCreating = () => { setName(""); setIsWriting(true); }; const onCancelCreating = () => setIsWriting(false); const onCompleteCreating = () => { if (name) { onCreateBoard(name); } setIsWriting(false); }; return ( {isWriting ? ( setName(e.target.value)} onKeyDown={e => e.key === "Enter" && onCompleteCreating() } /> ) : ( )} ); }; export default CreateBoardButton;