From 4e3028c6eee76379f60036c37c6f7f9bb2050c5b Mon Sep 17 00:00:00 2001 From: hamo-o Date: Fri, 30 Aug 2024 01:54:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20defaultValue=20=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?=EC=95=88=EB=90=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_components/CustomTextField.tsx | 3 ++- .../[studyDetailId]/edit-assignment/page.tsx | 26 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/apps/admin/app/studies/assignments/[studyDetailId]/_components/CustomTextField.tsx b/apps/admin/app/studies/assignments/[studyDetailId]/_components/CustomTextField.tsx index ded4e55f..28979eba 100644 --- a/apps/admin/app/studies/assignments/[studyDetailId]/_components/CustomTextField.tsx +++ b/apps/admin/app/studies/assignments/[studyDetailId]/_components/CustomTextField.tsx @@ -1,3 +1,5 @@ +"use client"; + import { useController } from "react-hook-form"; import type { TextFieldProps } from "wowds-ui/TextField"; import TextField from "wowds-ui/TextField"; @@ -7,7 +9,6 @@ interface CustomTextFieldProps extends TextFieldProps { control: any; } -// TODO: defaultValue 적용 안되는 문제 const CustomTextField = ({ name, control, diff --git a/apps/admin/app/studies/assignments/[studyDetailId]/edit-assignment/page.tsx b/apps/admin/app/studies/assignments/[studyDetailId]/edit-assignment/page.tsx index edfd3c96..fc6b7a78 100644 --- a/apps/admin/app/studies/assignments/[studyDetailId]/edit-assignment/page.tsx +++ b/apps/admin/app/studies/assignments/[studyDetailId]/edit-assignment/page.tsx @@ -20,19 +20,6 @@ const Assignments = ({ }) => { const { open, onOpen } = useOpenState(); - const methods = useForm< - AssignmentApiRequestDto & { - onOpen: () => void; - } - >({ - defaultValues: { - title: "", - deadLine: "2024-09-07T00:00:00", - descriptionNotionLink: "", - onOpen: onOpen, - }, - }); - const [assignment, setAssignment] = useState( null ); @@ -47,6 +34,19 @@ const Assignments = ({ fetchAssignment(); }, [studyDetailId]); + const methods = useForm< + AssignmentApiRequestDto & { + onOpen: () => void; + } + >({ + defaultValues: { + title: assignment?.title, + deadLine: "2024-09-07T00:00:00", + descriptionNotionLink: assignment?.descriptionLink, + onOpen: onOpen, + }, + }); + if (!assignment) return null; const { assignmentStatus, week } = assignment;