Skip to content

Commit

Permalink
feat: 현재 북 Id에 post보내기
Browse files Browse the repository at this point in the history
  • Loading branch information
eunbeann committed Jan 18, 2024
1 parent 5ef11d1 commit a6f390f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Detail/components/LecueNoteListContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ function LecueNoteListContainer(props: LecueNoteListContainerProps) {
};

const handleClickWriteButton = () => {
navigate('/create-note');
navigate(`/create-note/${bookUuid}`, {
state: { bookId: bookId },
});
};

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/LecueNote/api/postLecueNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/LecueNote/hooks/usePostLecueNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ const usePostLecueNote = () => {
fileName,
bgColor,
isIconClicked,
bookId,
}: postLecueNoteProps) => {
return postLecueNote({
contents,
color,
fileName,
bgColor,
isIconClicked,
bookId,
});
},
onError: (err: AxiosError) => console.log(err),
Expand Down
4 changes: 4 additions & 0 deletions src/LecueNote/page/LeceuNotePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -80,6 +83,7 @@ function LecueNotePage() {
fileName: fileName,
bgColor: clickedBgColor,
isIconClicked: isIconClicked,
bookId: bookId,
});
navigate(`/lecue-book/${bookUuid}`);
};
Expand Down
1 change: 1 addition & 0 deletions src/LecueNote/type/lecueNoteType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ export interface postLecueNoteProps {
fileName: string;
bgColor: string;
isIconClicked: boolean;
bookId: number;
}

0 comments on commit a6f390f

Please sign in to comment.