import { type ReactNode } from "react"; import { HiOutlinePlusSmall, HiEllipsisHorizontal, HiOutlineTrash, HiOutlineSquaresPlus, } from "react-icons/hi2"; import { Draggable } from "react-beautiful-dnd"; import { useForm } from "react-hook-form"; import { api } from "~/utils/api"; import { useModal } from "~/providers/modal"; import Dropdown from "~/components/Dropdown"; interface ListProps { children: ReactNode; index: number; list: List; setSelectedPublicListId: (publicListId: PublicListId) => void; } interface List { publicId: string; name: string; } interface FormValues { listPublicId: string; name: string; } type PublicListId = string; export default function List({ children, index, list, setSelectedPublicListId, }: ListProps) { const { openModal } = useModal(); const openNewCardForm = (publicListId: PublicListId) => { openModal("NEW_CARD"); setSelectedPublicListId(publicListId); }; const updateList = api.list.update.useMutation(); const { register, handleSubmit } = useForm({ defaultValues: { listPublicId: list.publicId, name: list.name, }, values: { listPublicId: list.publicId, name: list.name, }, }); const onSubmit = (values: FormValues) => { updateList.mutate({ listPublicId: values.listPublicId, name: values.name, }); }; const handleOpenDeleteListConfirmation = () => { setSelectedPublicListId(list.publicId); openModal("DELETE_LIST"); }; return ( {(provided) => (
openNewCardForm(list.publicId), icon: ( ), }, { label: "Delete list", action: handleOpenDeleteListConfirmation, icon: ( ), }, ]} >
{children}
)}
); }