From e058a2db307e46ae97482028ab3296ef0dc45b04 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 18 Mar 2024 09:02:50 +0000 Subject: [PATCH] feat: create another card toggle --- .../[...boardId]/components/NewCardForm.tsx | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) 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(); }} >
@@ -71,6 +79,27 @@ export function NewCardForm({ listPublicId }: listPublicId) { name="title" className="block w-full rounded-md border-0 bg-dark-300 bg-white/5 py-1.5 text-dark-1000 shadow-sm ring-1 ring-inset ring-dark-700 focus:ring-2 focus:ring-inset focus:ring-dark-700 sm:text-sm sm:leading-6" /> +
+ Create more + + Use setting + +
+