diff --git a/src/app/boards/[...boardId]/components/NewCardForm.tsx b/src/app/boards/[...boardId]/components/NewCardForm.tsx index 4bb4ae86..d260b7e3 100644 --- a/src/app/boards/[...boardId]/components/NewCardForm.tsx +++ b/src/app/boards/[...boardId]/components/NewCardForm.tsx @@ -1,8 +1,10 @@ "use client"; +import { useState } from "react"; import { api } from "~/trpc/react"; import { HiXMark } from "react-icons/hi2"; +import { Switch } from "@headlessui/react"; import { useBoard } from "~/app/providers/board"; import { useModal } from "~/app/providers/modal"; @@ -17,10 +19,15 @@ interface listPublicId { listPublicId: string; } +function classNames(...classes: string[]): string { + return classes.filter(Boolean).join(" "); +} + export function NewCardForm({ listPublicId }: listPublicId) { const utils = api.useUtils(); const { boardData } = useBoard(); const { closeModal } = useModal(); + const [isCreateAnotherEnabled, setIsCreateAnotherEnabled] = useState(false); const refetchBoard = () => utils.board.byId.refetch({ id: boardData.publicId }); @@ -29,7 +36,7 @@ export function NewCardForm({ listPublicId }: listPublicId) { onSuccess: async () => { try { await refetchBoard(); - closeModal(); + if (!isCreateAnotherEnabled) closeModal(); } catch (e) { console.log(e); } @@ -52,11 +59,12 @@ export function NewCardForm({ listPublicId }: listPublicId) { initialValues={{ title: "", }} - onSubmit={(values: FormValues) => { + onSubmit={(values: FormValues, { resetForm }) => { createCard.mutate({ title: values.title, listPublicId, }); + resetForm(); }} >