From a6f390fbd8a3c2db978ee18a5696cb6f1d002cc1 Mon Sep 17 00:00:00 2001 From: eunbenn Date: Thu, 18 Jan 2024 17:34:52 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=98=84=EC=9E=AC=20=EB=B6=81=20Id?= =?UTF-8?q?=EC=97=90=20post=EB=B3=B4=EB=82=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Detail/components/LecueNoteListContainer/index.tsx | 4 +++- src/LecueNote/api/postLecueNote.ts | 3 ++- src/LecueNote/hooks/usePostLecueNote.ts | 2 ++ src/LecueNote/page/LeceuNotePage/index.tsx | 4 ++++ src/LecueNote/type/lecueNoteType.ts | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Detail/components/LecueNoteListContainer/index.tsx b/src/Detail/components/LecueNoteListContainer/index.tsx index 3683350e..1b772a83 100644 --- a/src/Detail/components/LecueNoteListContainer/index.tsx +++ b/src/Detail/components/LecueNoteListContainer/index.tsx @@ -78,7 +78,9 @@ function LecueNoteListContainer(props: LecueNoteListContainerProps) { }; const handleClickWriteButton = () => { - navigate('/create-note'); + navigate(`/create-note/${bookUuid}`, { + state: { bookId: bookId }, + }); }; useEffect(() => { diff --git a/src/LecueNote/api/postLecueNote.ts b/src/LecueNote/api/postLecueNote.ts index 97f6f707..c2b05cec 100644 --- a/src/LecueNote/api/postLecueNote.ts +++ b/src/LecueNote/api/postLecueNote.ts @@ -7,12 +7,13 @@ const postLecueNote = ({ fileName, bgColor, isIconClicked, + bookId, }: postLecueNoteProps) => { const response = api .post( '/api/notes', { - bookId: 1, + bookId: bookId, content: contents, textColor: color, background: isIconClicked ? fileName : bgColor, diff --git a/src/LecueNote/hooks/usePostLecueNote.ts b/src/LecueNote/hooks/usePostLecueNote.ts index c700b421..52adfc4d 100644 --- a/src/LecueNote/hooks/usePostLecueNote.ts +++ b/src/LecueNote/hooks/usePostLecueNote.ts @@ -12,6 +12,7 @@ const usePostLecueNote = () => { fileName, bgColor, isIconClicked, + bookId, }: postLecueNoteProps) => { return postLecueNote({ contents, @@ -19,6 +20,7 @@ const usePostLecueNote = () => { fileName, bgColor, isIconClicked, + bookId, }); }, onError: (err: AxiosError) => console.log(err), diff --git a/src/LecueNote/page/LeceuNotePage/index.tsx b/src/LecueNote/page/LeceuNotePage/index.tsx index abea76a5..c1a220ec 100644 --- a/src/LecueNote/page/LeceuNotePage/index.tsx +++ b/src/LecueNote/page/LeceuNotePage/index.tsx @@ -33,6 +33,9 @@ function LecueNotePage() { const putMutation = usePutPresignedUrl(); const postMutation = usePostLecueNote(); + const location = useLocation(); + + const { bookId } = location.state; const { bookUuid } = useParams() as { bookUuid: string }; const handleClickCategory = ( @@ -80,6 +83,7 @@ function LecueNotePage() { fileName: fileName, bgColor: clickedBgColor, isIconClicked: isIconClicked, + bookId: bookId, }); navigate(`/lecue-book/${bookUuid}`); }; diff --git a/src/LecueNote/type/lecueNoteType.ts b/src/LecueNote/type/lecueNoteType.ts index 5f7a2494..604abd73 100644 --- a/src/LecueNote/type/lecueNoteType.ts +++ b/src/LecueNote/type/lecueNoteType.ts @@ -81,4 +81,5 @@ export interface postLecueNoteProps { fileName: string; bgColor: string; isIconClicked: boolean; + bookId: number; }