import { type ReactNode } from "react"; import { HiOutlinePlusSmall } from "react-icons/hi2"; import { Draggable } from "react-beautiful-dnd"; import { useFormik } from "formik"; 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 formik = useFormik({ initialValues: { listPublicId: list.publicId, name: list.name, }, onSubmit: (values: FormValues) => { updateList.mutate({ listPublicId: values.listPublicId, name: values.name, }); }, enableReinitialize: true, }); return ( {(provided) => (
setSelectedPublicListId(list.publicId) } />
{children}
)}
); }