From 6a1e188919aafece598ccce2030a34ae8cc28bf2 Mon Sep 17 00:00:00 2001 From: keemsebeen Date: Sun, 24 Nov 2024 03:56:18 +0900 Subject: [PATCH] feat: add new bookmark creation feature --- .../features/BookmarkList/BookmarkList.tsx | 77 +++++++++++++++++-- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/src/components/features/BookmarkList/BookmarkList.tsx b/src/components/features/BookmarkList/BookmarkList.tsx index 84aa431..4ad4579 100644 --- a/src/components/features/BookmarkList/BookmarkList.tsx +++ b/src/components/features/BookmarkList/BookmarkList.tsx @@ -1,27 +1,61 @@ +import { useState } from 'react'; + +import { Button } from '@/components/common/Button'; import { Icon } from '@/components/common/Icon'; +import { IconButton } from '@/components/common/IconButton'; +import { Input } from '@/components/common/Input'; import { ListCard } from '@/components/common/ListCard'; +import { Modal } from '@/components/common/Modal'; import { Body1, Body2, Body3 } from '@/components/common/Typography'; +import { findyIconNames } from '@/constants/findyIcons'; import { useBookMarkList } from '@/hooks/api/bookmarks/useBookMarkList'; +import { useNewBookMark } from '@/hooks/api/bookmarks/useNewBookMark'; import { useAuth } from '@/hooks/auth/useAuth'; type Props = { onNext: (bookmarkId: number) => void }; export const BookmarkList = ({ onNext }: Props) => { + const [isOpen, setIsOpen] = useState(false); + const [bookmarkName, setBookmarkName] = useState(''); + const { token } = useAuth(); const { data } = useBookMarkList(token); + const newBookmarkMutation = useNewBookMark(token); + + const handleAddBookmark = () => { + if (!bookmarkName.trim()) return; + newBookmarkMutation.mutate( + { name: bookmarkName.trim() }, + { + onSuccess: () => { + setBookmarkName(''); + setIsOpen(false); + }, + } + ); + }; const handleBookmarkClick = (bookmarkId: number) => { onNext(bookmarkId); }; return ( -
+ <> 나의 핀디 리스트 +
setIsOpen(true)} + > + + + 새 장소 추가하기 + +
+
{data?.data.map((item, index) => ( - <> +
handleBookmarkClick(item.bookmarkId)} className="flex flex-row justify-between items-center cursor-pointer" > @@ -33,7 +67,10 @@ export const BookmarkList = ({ onNext }: Props) => { alt={`${item.name}의 프로필 이미지`} /> ) : ( - + )}
{item.name} @@ -45,9 +82,37 @@ export const BookmarkList = ({ onNext }: Props) => {
{index < data.data.length - 1 &&
} - +
))}
-
+ +
+ + 장소 추가 + + = 1} + errorMessage="1글자 이상 입력해야 합니다." + onClickReset={() => setBookmarkName('')} + onChange={(e) => setBookmarkName(e.target.value)} + /> +
+ + +
+
+
+ ); };