import { type ReactNode } from "react"; import { HiOutlinePlusSmall } 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 ListDropdown from "./ListDropdown"; 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, }, }); const onSubmit = (values: FormValues) => { updateList.mutate({ listPublicId: values.listPublicId, name: values.name, }); }; return ( {(provided) => (
setSelectedPublicListId(list.publicId) } />
{children}
)}
); }