정원
@@ -68,9 +67,7 @@ export default function HeaderNav({
식물 카드
diff --git a/client/src/components/common/SeoHead.tsx b/client/src/components/common/SeoHead.tsx
index 10c951bb..ceac1e26 100644
--- a/client/src/components/common/SeoHead.tsx
+++ b/client/src/components/common/SeoHead.tsx
@@ -1,8 +1,8 @@
import { useRouter } from 'next/router';
-// import getMetaData from '@/hooks/useGetMetaData';
+import getMetaDate from '@/hooks/useGetMetaData';
-import { PageType, Post } from '@/types/common';
+import { ContextType, PageType, Post } from '@/types/common';
type MetaDataProps = {
post: Post;
@@ -11,7 +11,7 @@ type MetaDataProps = {
export default function SeoHead({ post, page }: MetaDataProps) {
const router = useRouter();
- // const metaData = getMetaData(page, router.query, post);
+ const metaData = getMetaDate(page, router.query, post);
//TODO: 주석에 원하는대로 값이 나오는지 테스트가 필요하다
//TODO: og 이미지는 어떻게 할 것인가?
return;
diff --git a/client/src/components/common/index.ts b/client/src/components/common/index.ts
deleted file mode 100644
index 9aa0327a..00000000
--- a/client/src/components/common/index.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import CommonButton from './CommonButton';
-import ConnectCheckBox from './ConnectCheckBox';
-import ControlButton from './ControlButton';
-import ErrorMessage from './ErrorMessage';
-import ErrorNotice from './ErrorNotice';
-import Footer from './Footer';
-import FooterLink from './FooterLink';
-import HashTag from './HashTag';
-import Header from './Header';
-import HeaderLink from './HeaderLink';
-import HeaderNav from './HeaderNav';
-import ImageUpload from './ImageUpload';
-import Intro from './Intro';
-import Leaf from './Leaf';
-import LeafForm from './LeafForm';
-import LeafName from './LeafName';
-import LoadingMessage from './LoadingMessage';
-import LoadingNotice from './LoadingNotice';
-import Logo from './Logo';
-import Modal from './Modal';
-import ModalPortal from './ModalPortal';
-import NoImage from './NoImage';
-import PageTitle from './PageTitle';
-import PasswordInput from './PasswordInput';
-import PostCountInfo from './PostCountInfo';
-import Preview from './Preview';
-import ReactQueryProvider from './ReactQueryProvider';
-import Screws from './Screws';
-import SeoHead from './SeoHead';
-import ShareButton from './ShareButton';
-import ShareModal from './ShareModal';
-import TagInput from './TagInput';
-import TextArea from './TextArea';
-import TextInput from './TextInput';
-
-export {
- CommonButton,
- ConnectCheckBox,
- ControlButton,
- ErrorMessage,
- ErrorNotice,
- Footer,
- FooterLink,
- HashTag,
- Header,
- HeaderLink,
- HeaderNav,
- ImageUpload,
- Intro,
- Leaf,
- LeafForm,
- LeafName,
- LoadingMessage,
- LoadingNotice,
- Logo,
- Modal,
- ModalPortal,
- NoImage,
- PageTitle,
- PasswordInput,
- PostCountInfo,
- Preview,
- ReactQueryProvider,
- Screws,
- SeoHead,
- ShareButton,
- ShareModal,
- TagInput,
- TextArea,
- TextInput,
-};
diff --git a/client/src/components/history/ConfirmModal.tsx b/client/src/components/history/ConfirmModal.tsx
index 0ceeaba1..a87efc2e 100644
--- a/client/src/components/history/ConfirmModal.tsx
+++ b/client/src/components/history/ConfirmModal.tsx
@@ -1,31 +1,42 @@
'use client';
-import useDeleteUser from '@/hooks/useDeleteUser';
+import { deleteUser } from '@/api/history';
-import { CommonButton, Modal, ModalPortal } from '../common';
+import useSignModalStore from '@/stores/signModalStore';
+import useUserStore from '@/stores/userStore';
+
+import Modal from '../common/Modal';
+import ModalPortal from '../common/ModalPortal';
+import CommonButton from '../common/CommonButton';
export default function ConfirmModal() {
- const { onDeleteUser, close } = useDeleteUser();
+ const { close, changeState } = useSignModalStore();
+
+ const hanldeDeleteUser = async () => {
+ const response = await deleteUser();
+
+ if (response === 204) {
+ return changeState('SuccessedModal');
+ }
+ };
return (
-
+
정말
탈퇴
하시겠습니까?
-
onDeleteUser()}>
+ onCheck={hanldeDeleteUser}>
네
-
-
+
+
{
@@ -25,30 +24,18 @@ export default function Dropdown() {
{DROPDOWN_OPTIONS.map((list, index) => (
-
+
{selectOption === list.title && list.selected}
))}
-
{isOpen ? (
-
+
![](/assets/icon/up.svg)
) : (
-
+
![](/assets/icon/down.svg)
)}
-
{isOpen && (
@@ -62,7 +49,6 @@ export default function Dropdown() {
작성한 게시글
-
setSelectOption('boardLiked')}>
@@ -70,7 +56,6 @@ export default function Dropdown() {
좋아요를 누른 게시글
-
{
setSelectOption('commentWritten');
@@ -83,7 +68,7 @@ export default function Dropdown() {
)}
-
-
+
+
);
}
diff --git a/client/src/components/history/FailureModal.tsx b/client/src/components/history/FailureModal.tsx
index f4417427..1ec15a1b 100644
--- a/client/src/components/history/FailureModal.tsx
+++ b/client/src/components/history/FailureModal.tsx
@@ -1,31 +1,32 @@
'use client';
-import useModalStore from '@/stores/modalStore';
+import useSignModalStore from '@/stores/signModalStore';
-import { CommonButton, Modal, ModalPortal } from '../common';
+import Modal from '../common/Modal';
+import ModalPortal from '../common/ModalPortal';
+import CommonButton from '../common/CommonButton';
export default function FailureModal() {
- const { close } = useModalStore();
+ const close = useSignModalStore((state) => state.close);
return (
-
-
-
-
+
+
-
닫기
diff --git a/client/src/components/history/HistoryBoard.tsx b/client/src/components/history/HistoryBoard.tsx
index 1d33e9c4..89f0bba0 100644
--- a/client/src/components/history/HistoryBoard.tsx
+++ b/client/src/components/history/HistoryBoard.tsx
@@ -1,30 +1,40 @@
'use client';
import { useRouter } from 'next/navigation';
+import { useInfiniteQuery } from '@tanstack/react-query';
import InfiniteScroll from 'react-infinite-scroller';
-import useUserStore from '@/stores/userStore';
+import { getBoardWrittenByPage } from '@/api/history';
-import useHistoryBoard from '@/hooks/useHistoryBoard';
+import useUserStore from '@/stores/userStore';
-import { HistoryPostCard } from '.';
import EmptyDiary from '../leaf/EmptyDiary';
-import { ErrorMessage, LoadingMessage } from '../common';
+import HistoryPostCard from './HistoryPostCard';
+
+import ErrorMessage from '../common/ErrorMessage';
+import LoadingMessage from '../common/LoadingMessage';
import { HistoryBoradProps } from '@/types/common';
+import useClient from '@/hooks/useClient';
export default function HistoryBoard({ paramsId }: HistoryBoradProps) {
const router = useRouter();
+ const isClient = useClient();
+ const userId = useUserStore((state) => state.userId);
- const { userId } = useUserStore();
+ const { data, fetchNextPage, hasNextPage, isLoading, isError } =
+ useInfiniteQuery(
+ ['boardWritten'],
+ ({ pageParam = 1 }) => getBoardWrittenByPage({ pageParam }, paramsId),
- const {
- data: boards,
- fetchNextPage,
- hasNextPage,
- isLoading,
- isError,
- } = useHistoryBoard(paramsId);
+ {
+ getNextPageParam: (lastPage) => {
+ return lastPage.pageInfo.page !== lastPage.pageInfo.totalPages
+ ? lastPage.pageInfo.page + 1
+ : undefined;
+ },
+ },
+ );
const likesAmount = (likes: []) => {
if (likes?.length === 0) return 0;
@@ -34,10 +44,10 @@ export default function HistoryBoard({ paramsId }: HistoryBoradProps) {
return (
<>
- {boards?.map((page, index) => (
+ {data?.pages.map((page, index) => (
{page?.boardWritten?.length === 0 ? (
-
+
) : (
fetchNextPage()}>
-
+
{page.boardWritten?.map((board: any) => (
))}
-
+
)}
))}
-
{isLoading && (
)}
-
{isError && (
diff --git a/client/src/components/history/HistoryBox.tsx b/client/src/components/history/HistoryBox.tsx
index a23826cd..b4c8d17e 100644
--- a/client/src/components/history/HistoryBox.tsx
+++ b/client/src/components/history/HistoryBox.tsx
@@ -5,14 +5,12 @@ import useUserStore from '@/stores/userStore';
import useClient from '@/hooks/useClient';
-import {
- UserButton,
- UserInfo,
- Dropdown,
- HistoryBoard,
- HistoryLikes,
- HistoryComment,
-} from '.';
+import UserButton from './UserButton';
+import UserInfo from './UserInfo';
+import Dropdown from './Dropdown';
+import HistoryBoard from './HistoryBoard';
+import HistoryLikes from './HistoryLikes';
+import HistoryComment from './HistoryComment';
import { ADMIN_USER_ID } from '@/constants/values';
@@ -21,22 +19,23 @@ interface HistoryProps {
}
export default function HistoryBox({ paramsId }: HistoryProps) {
- const { userId } = useUserStore();
- const { selectOption } = useHistoryStore();
-
const isClient = useClient();
const id = paramsId;
+ const userId = useUserStore((state) => state.userId);
+
+ const selectOption = useHistoryStore((state) => state.selectOption);
+
const isOwner = userId === id;
const isBoardWritten = selectOption === 'boardWritten';
- const isBoardLikes = selectOption === 'boardLiked';
- const isBoardComments = selectOption === 'commentWritten';
+ const isBoardLike = selectOption === 'boardLiked';
+ const isComment = selectOption === 'commentWritten';
return (
<>
{isClient && (
-
+
{userId !== ADMIN_USER_ID && (
@@ -57,12 +56,12 @@ export default function HistoryBox({ paramsId }: HistoryProps) {
{(userId || paramsId) && (
{isBoardWritten && }
- {isOwner && isBoardLikes && }
- {isOwner && isBoardComments && }
+ {isOwner && isBoardLike && }
+ {isOwner && isComment && }
)}
-
+
)}
>
);
diff --git a/client/src/components/history/HistoryComment.tsx b/client/src/components/history/HistoryComment.tsx
index bf8c15a5..815087f0 100644
--- a/client/src/components/history/HistoryComment.tsx
+++ b/client/src/components/history/HistoryComment.tsx
@@ -1,43 +1,44 @@
'use client';
import { useRouter } from 'next/navigation';
+import { useInfiniteQuery } from '@tanstack/react-query';
import InfiniteScroll from 'react-infinite-scroller';
-import useUserStore from '@/stores/userStore';
+import { getCommentWrittenByPage } from '@/api/history';
-import useHistoryComment from '@/hooks/useHistoryComment';
+import useUserStore from '@/stores/userStore';
-import { HistoryPostCard } from '.';
import EmptyDiary from '../leaf/EmptyDiary';
-import { ErrorMessage, LoadingMessage } from '../common';
+import HistoryPostCard from './HistoryPostCard';
+
+import LoadingMessage from '../common/LoadingMessage';
+import ErrorMessage from '../common/ErrorMessage';
import { HistoryBoradProps } from '@/types/common';
export default function HistoryComment({ paramsId }: HistoryBoradProps) {
const router = useRouter();
+ const userId = useUserStore((state) => state.userId);
- const { userId } = useUserStore();
-
- const {
- data: comments,
- fetchNextPage,
- hasNextPage,
- isLoading,
- isError,
- } = useHistoryComment(paramsId);
-
- const likesAmount = (likes: []) => {
- if (likes?.length === 0) return 0;
-
- return likes.length;
- };
+ const { data, fetchNextPage, hasNextPage, isLoading, isError } =
+ useInfiniteQuery(
+ ['commentWritten'],
+ ({ pageParam = 1 }) => getCommentWrittenByPage({ pageParam }, paramsId),
+ {
+ getNextPageParam: (lastPage) => {
+ return lastPage.pageInfo.page !== lastPage.pageInfo.totalPages
+ ? lastPage.pageInfo.page + 1
+ : undefined;
+ },
+ },
+ );
return (
<>
- {comments?.map((page, index) => (
+ {data?.pages.map((page, index) => (
{page.commentWritten?.length === 0 ? (
-
+
) : (
fetchNextPage()}>
-
+
{page.commentWritten?.map((board: any) => (
))}
-
+
)}
))}
-
{isLoading && (
)}
-
{isError && (
diff --git a/client/src/components/history/HistoryLikes.tsx b/client/src/components/history/HistoryLikes.tsx
index a50b70d7..4add05fc 100644
--- a/client/src/components/history/HistoryLikes.tsx
+++ b/client/src/components/history/HistoryLikes.tsx
@@ -1,30 +1,39 @@
'use client';
import { useRouter } from 'next/navigation';
+import { useInfiniteQuery } from '@tanstack/react-query';
import InfiniteScroll from 'react-infinite-scroller';
-import useHistoryLikes from '@/hooks/useHistoryLikes';
+import { getBoardLikedByPage } from '@/api/history';
import useUserStore from '@/stores/userStore';
-import { HistoryPostCard } from '.';
import EmptyDiary from '../leaf/EmptyDiary';
-import { ErrorMessage, LoadingMessage } from '../common';
+import HistoryPostCard from './HistoryPostCard';
+
+import LoadingMessage from '../common/LoadingMessage';
+import ErrorMessage from '../common/ErrorMessage';
import { HistoryBoradProps } from '@/types/common';
export default function HistoryLikes({ paramsId }: HistoryBoradProps) {
const router = useRouter();
+ const userId = useUserStore((state) => state.userId);
- const { userId } = useUserStore();
+ const { data, fetchNextPage, hasNextPage, isLoading, isError } =
+ useInfiniteQuery(
+ ['boardLiked'],
+ ({ pageParam = 1 }) => getBoardLikedByPage({ pageParam }, paramsId),
+ {
+ getNextPageParam: (lastPage) => {
+ if (lastPage.pageInfo.totalElement === 0) return;
- const {
- data: likes,
- fetchNextPage,
- hasNextPage,
- isLoading,
- isError,
- } = useHistoryLikes(paramsId);
+ if (lastPage.pageInfo.page !== lastPage.pageInfo.totalPages) {
+ return lastPage.pageInfo.page + 1;
+ }
+ },
+ },
+ );
const likesAmount = (likes: []) => {
if (likes?.length === 0) return 0;
@@ -34,7 +43,7 @@ export default function HistoryLikes({ paramsId }: HistoryBoradProps) {
return (
<>
- {likes?.map((page, index) => (
+ {data?.pages.map((page, index) => (
{page?.boardLiked?.length === 0 ? (
)}
-
{isError && (
diff --git a/client/src/components/history/HistoryPostCard.tsx b/client/src/components/history/HistoryPostCard.tsx
index 630d2ac5..a297b0d9 100644
--- a/client/src/components/history/HistoryPostCard.tsx
+++ b/client/src/components/history/HistoryPostCard.tsx
@@ -1,5 +1,5 @@
-import Image from 'next/image';
import { motion } from 'framer-motion';
+import Image from 'next/image';
interface HistoryPostCardProps {
imageUrl: string;
@@ -20,13 +20,23 @@ export default function HistoryPostCard({
whileTap={{ scale: 0.95 }}
className="flex flex-col items-center justify-center w-[200px] h-[175px] rounded-lg border-2 border-brown-50 bg-brown-10 shadow-outer/down">
-
+ {imageUrl ? (
+
+ ) : (
+
+ )}
diff --git a/client/src/components/history/ResignModal.tsx b/client/src/components/history/ResignModal.tsx
index 00f24111..d9a836f3 100644
--- a/client/src/components/history/ResignModal.tsx
+++ b/client/src/components/history/ResignModal.tsx
@@ -2,10 +2,15 @@
import { useForm } from 'react-hook-form';
-import useResignCheck from '@/hooks/useResignCheck';
+import { postUserPassword } from '@/api/history';
-import { SignModalInput } from '../sign';
-import { CommonButton, Modal, ModalPortal } from '../common';
+import useSignModalStore from '@/stores/signModalStore';
+import useUserStore from '@/stores/userStore';
+
+import Modal from '../common/Modal';
+import ModalPortal from '../common/ModalPortal';
+import SignModalInput from '../sign/SignModalInput';
+import CommonButton from '../common/CommonButton';
import { SignFormValue } from '@/types/common';
@@ -13,61 +18,67 @@ export default function ResignModal() {
const {
register,
watch,
- handleSubmit,
- formState: { errors, isSubmitting },
+ formState: { isSubmitting },
} = useForm
();
- const { onPasswordCheck, close } = useResignCheck();
+ const setAccessToken = useUserStore((state) => state.setAccessToken);
+ const { close, changeState } = useSignModalStore();
const userPassword = watch('password');
+ const handlePasswordCheck = async () => {
+ if (!userPassword) return;
+
+ const response = await postUserPassword(userPassword);
+
+ if (response) {
+ return (
+ changeState('ConfirmModal'),
+ setAccessToken(response.headers?.authorization)
+ );
+ }
+
+ return changeState('FailureModal');
+ };
+
return (
-