From 3a911c8b2a5ab3ac69d23cb0e3d46e76fa2a8080 Mon Sep 17 00:00:00 2001 From: hamo-o Date: Wed, 28 Aug 2024 16:09:54 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=A4=91=EB=B3=B5=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=82=BC=ED=95=AD=EC=97=B0=EC=82=B0=EC=9E=90?= =?UTF-8?q?=EB=A1=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_components/AssignmentHeader.tsx | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/apps/admin/app/studies/assignments/[studyDetailId]/_components/AssignmentHeader.tsx b/apps/admin/app/studies/assignments/[studyDetailId]/_components/AssignmentHeader.tsx index d170b3b4..517d1a05 100644 --- a/apps/admin/app/studies/assignments/[studyDetailId]/_components/AssignmentHeader.tsx +++ b/apps/admin/app/studies/assignments/[studyDetailId]/_components/AssignmentHeader.tsx @@ -29,26 +29,22 @@ const AssignmentHeader = ({ assignment, disabled }: AssignmentHeaderProps) => { const onOpen = methods.getValues("onOpen"); const handleClickSubmit = async () => { + if (assignmentStatus === "CANCELLED") return; + const data = { title: methods.getValues("title"), descriptionNotionLink: methods.getValues("descriptionNotionLink"), deadLine: methods.getValues("deadLine"), }; - if (assignmentStatus === "NONE") { - const { success } = await studyApi.createAssignment(studyDetailId, data); - if (success) { - revalidateTagByName(`${tags.assignments} ${studyDetailId.toString()}`); - revalidateTagByName(tags.assignments); - onOpen(); - } - } else if (assignmentStatus === "OPEN") { - const { success } = await studyApi.patchAssignment(studyDetailId, data); - if (success) { - revalidateTagByName(`${tags.assignments} ${studyDetailId.toString()}`); - revalidateTagByName(tags.assignments); - onOpen(); - } + const { success } = + assignmentStatus === "NONE" + ? await studyApi.createAssignment(studyDetailId, data) + : await studyApi.patchAssignment(studyDetailId, data); + if (success) { + revalidateTagByName(`${tags.assignments} ${studyDetailId.toString()}`); + revalidateTagByName(tags.assignments); + onOpen(); } };