From 978767e1e91306fa207335ef4d064eb1685f2c83 Mon Sep 17 00:00:00 2001 From: kyu <2066apple@naver.com> Date: Wed, 13 Sep 2023 22:41:06 +0900 Subject: [PATCH] =?UTF-8?q?[=20fix=20]=20=EC=88=98=EC=A0=95=EB=90=9C?= =?UTF-8?q?=EA=B2=8C=20=EC=97=86=EC=9C=BC=EB=A9=B4=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=EB=B9=84=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/nottodo/NotTodoCreatePage.tsx | 42 +++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/pages/nottodo/NotTodoCreatePage.tsx b/src/pages/nottodo/NotTodoCreatePage.tsx index 74356b9..d37570d 100644 --- a/src/pages/nottodo/NotTodoCreatePage.tsx +++ b/src/pages/nottodo/NotTodoCreatePage.tsx @@ -7,7 +7,17 @@ import { diffDay, formatDateToString, dateToyyyymmdd } from '@/utils/datepicker' import { Toast } from '@/components/toast/Toast'; import { createNottodo, editNottodo } from '@/api/nottodo'; import { useRecoilValue } from 'recoil'; -import { currentNottodoState } from '@/recoil/nottodo/atom'; +import { currentNottodoState, nottodoProps } from '@/recoil/nottodo/atom'; + +interface editPayload { + notToDoText: string; + startDate: string; + endDate: string; + goal: string; + cheerUpMsg1: string; + cheerUpMsg2: string; + cheerUpMsg3: string; +} export default function NotTodoCreatePage() { const router = useNavigate(); @@ -188,10 +198,38 @@ export default function NotTodoCreatePage() { } }; + const isEditing = (origin: nottodoProps | null, edit: editPayload) => { + if (origin) { + if (origin.notToDoText !== edit.notToDoText) return true; + if (origin.startDate !== edit.startDate) return true; + if (origin.endDate !== edit.endDate) return true; + if (origin.goal !== edit.goal) return true; + if (origin.cheerUpMessageList[0].content !== edit.cheerUpMsg1) return true; + if (origin.cheerUpMessageList[1].content !== edit.cheerUpMsg2) return true; + if (origin.cheerUpMessageList[2].content !== edit.cheerUpMsg3) return true; + return false; + } else { + return false; + } + }; + const renderButton = (isEdit: boolean) => { if (isEdit) { + const payload = { + notToDoText: title, + startDate: dateToyyyymmdd(startDate, '-'), + endDate: dateToyyyymmdd(endDate, '-'), + goal, + cheerUpMsg1: message1, + cheerUpMsg2: message2, + cheerUpMsg3: message3, + }; return ( - + 수정 완료 );