diff --git a/src/apis/queries.ts b/src/apis/queries.ts index 17d8bdb5..4bcb6463 100644 --- a/src/apis/queries.ts +++ b/src/apis/queries.ts @@ -60,37 +60,6 @@ const queries = createQueryKeyStore({ queryFn: () => getEpigrams(request), }), }, - // NOTE: Epigram 관련 query함수 - epigram: { - getEpigram: (request: EpigramRequestType) => ({ - queryKey: ['epigram', request.id, request], - queryFn: () => { - if (request.id === undefined) { - throw new Error('Epigram ID가 제공되지 않았습니다.'); - } - return getEpigram(request); - }, - enabled: request.id !== undefined, - }), - }, - epigramComment: { - getComments: (request: CommentRequestType) => ({ - queryKey: ['epigramComments', request], - queryFn: () => getEpigramComments(request), - }), - }, - emotion: { - getMonthlyEmotionLogs: (request: GetMonthlyEmotionLogsRequestType) => ({ - queryKey: ['getMonthlyEmotionLogs', request], - queryFn: () => getMonthlyEmotionLogs(request), - }), - }, - epigrams: { - getEpigrams: (request: GetEpigramsParamsType) => ({ - queryKey: ['getEpigrams', request], - queryFn: () => getEpigrams(request), - }), - }, }); export default queries; diff --git a/src/pageLayout/MypageLayout/EmotionMonthlyLogs.tsx b/src/pageLayout/MypageLayout/EmotionMonthlyLogs.tsx deleted file mode 100644 index 4020e531..00000000 --- a/src/pageLayout/MypageLayout/EmotionMonthlyLogs.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { useMonthlyEmotionLogs } from '@/hooks/useGetEmotion'; -import { Emotion } from '@/types/emotion'; -import { useEffect, useState } from 'react'; -import Calendar from '../../user/ui-calendar/Calendar'; -import Chart from '../../user/ui-chart/Chart'; - -interface EmotionMonthlyLogsProps { - userId: number; -} - -export default function EmotionMonthlyLogs({ userId }: EmotionMonthlyLogsProps) { - // 현재 날짜를 상태로 관리 - const [currentDate, setCurrentDate] = useState(new Date()); - - // 감정 달력 객체 상태 추가 - const [emotionRequest, setEmotionRequest] = useState({ - userId, - year: currentDate.getFullYear(), - month: currentDate.getMonth() + 1, - }); - - // '월'이 변경될 때마다 request 업데이트 - useEffect(() => { - setEmotionRequest({ - userId, - year: currentDate.getFullYear(), - month: currentDate.getMonth() + 1, - }); - }, [currentDate]); - - // 월별 감정 로그 조회 - const { data: monthlyEmotionLogs = [] } = useMonthlyEmotionLogs(emotionRequest); - - return ( -
- - -
- ); -} diff --git a/src/pageLayout/MypageLayout/MyContent.tsx b/src/pageLayout/MypageLayout/MyContent.tsx deleted file mode 100644 index 4b6c4ebb..00000000 --- a/src/pageLayout/MypageLayout/MyContent.tsx +++ /dev/null @@ -1,182 +0,0 @@ -import { useEffect, useState } from 'react'; -import useGetEpigrams from '@/hooks/useGetEpigrams'; -import MyEpigrams from '@/user/ui-content/MyEpigrams'; -import Image from 'next/image'; -import { useToast } from '@/components/ui/use-toast'; -import { EpigramsResponse } from '@/types/epigram.types'; -import { CommentResponseType } from '@/schema/comment'; -import useCommentsHook from '@/hooks/useCommentsHook'; -import useGetMyContentHook from '@/hooks/useGetMyContentHook'; -import MyComment from '@/user/ui-content/MyComment'; -import UserInfo from '@/types/user'; -import useDeleteCommentMutation from '@/hooks/useDeleteCommentHook'; -import { Button } from '@/components/ui/button'; -import spinner from '../../../public/spinner.svg'; - -interface MyContentProps { - user: UserInfo; -} - -export default function MyContent({ user }: MyContentProps) { - const limit = 3; - const [isLoadingMore, setIsLoadingMore] = useState(false); - const [selectedTab, setSelectedTab] = useState<'epigrams' | 'comments'>('epigrams'); - const { toast } = useToast(); - - /** ************ 내 에피그램/댓글 카운트 조회 ************* */ - const [epigramCount, setEpigramCount] = useState(0); - const [commentCount, setCommentCount] = useState(0); - const { data: count } = useGetMyContentHook({ id: user.id }); - useEffect(() => { - if (count) { - setEpigramCount(count.epigramCount); - setCommentCount(count.commentCount); - } - }, [count]); - - /** ************ 내 에피그램 조회 ************* */ - const [epigramCursor, setEpigramCursor] = useState(0); - const [epigrams, setEpigrams] = useState({ totalCount: 0, nextCursor: null, list: [] }); - const epigramsRequest = { - limit, - cursor: epigramCursor, - writerId: user.id, - }; - const { data: epigramsData, isLoading: isEpigramsLoading, error: epigramsError } = useGetEpigrams(epigramsRequest); - - /** ************ 내 댓글 조회 ************* */ - const [commentCursor, setCommentCursor] = useState(0); - const [comments, setComments] = useState({ totalCount: 0, nextCursor: null, list: [] }); - const commentsRequest = { - limit, - cursor: commentCursor, - id: user.id, - }; - const { data: commentData, isLoading: isCommentsLoading, error: commentsError, refetch: refetchComments } = useCommentsHook(commentsRequest); - - // [내 에피그램] 탭 선택 시 - useEffect(() => { - if (selectedTab === 'epigrams' && epigramsData) { - setEpigrams((prev) => ({ - totalCount: epigramsData.totalCount, - nextCursor: epigramsData.nextCursor, - list: [...prev.list, ...epigramsData.list], - })); - setIsLoadingMore(false); - } - }, [epigramsData, selectedTab]); - - // [내 댓글] 탭 선택 시 - useEffect(() => { - if (selectedTab === 'comments' && commentData) { - setComments((prev) => ({ - totalCount: commentData.totalCount, - nextCursor: commentData.nextCursor, - list: [...prev.list, ...commentData.list], - })); - setIsLoadingMore(false); - } - }, [commentData, selectedTab]); - - // 더보기 버튼 클릭 시 - const handleMoreLoad = () => { - if (selectedTab === 'epigrams' && epigrams.nextCursor) { - setEpigramCursor(epigrams.nextCursor); - setIsLoadingMore(true); - } else if (selectedTab === 'comments' && comments.nextCursor) { - setCommentCursor(comments.nextCursor); - setIsLoadingMore(true); - } - }; - - // [내 에피그램] [내 댓글] 탭 선택 - const handleTabClick = (tab: 'epigrams' | 'comments') => { - setSelectedTab(tab); - // 데이터 초기화 - if (tab === 'epigrams') { - setEpigrams({ totalCount: 0, nextCursor: null, list: [] }); - setEpigramCursor(0); - } else { - setComments({ totalCount: 0, nextCursor: null, list: [] }); - setCommentCursor(0); - } - setIsLoadingMore(false); - }; - - // 댓글 삭제 - const deleteCommentMutation = useDeleteCommentMutation(); - const handleDeleteComment = async (commentId: number) => { - try { - await deleteCommentMutation.mutateAsync(commentId); - setComments((prev) => ({ - totalCount: prev.totalCount - 1, - nextCursor: prev.nextCursor, - list: prev.list.filter((comment) => comment.id !== commentId), - })); - setCommentCount((prev) => prev - 1); - toast({ - title: '댓글이 삭제되었습니다.', - variant: 'destructive', - }); - } catch (error) { - toast({ - title: '댓글 삭제 실패했습니다.', - variant: 'destructive', - }); - } - }; - - // 댓글 수정 - const handleEditComment = () => { - setComments({ totalCount: 0, nextCursor: null, list: [] }); - setCommentCursor(0); - refetchComments(); - }; - - // 로딩 중 - if ((isEpigramsLoading || isCommentsLoading) && !isLoadingMore) { - return 로딩중; - } - - // 에러 - if (epigramsError || commentsError) { - toast({ - description: epigramsError?.message || commentsError?.message, - className: 'border-state-error text-state-error font-semibold', - }); - } - - return ( -
-
- - -
-
-
- {selectedTab === 'epigrams' && } - {selectedTab === 'comments' && ( - - )} - {isLoadingMore && ( -
- 로딩중 -
- )} -
-
-
- ); -} diff --git a/src/pageLayout/MypageLayout/MyPageLayout.tsx b/src/pageLayout/MypageLayout/MyPageLayout.tsx deleted file mode 100644 index 37fae1ae..00000000 --- a/src/pageLayout/MypageLayout/MyPageLayout.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import NewHeader from '@/components/Header/NewHeader'; -import { useMeQuery } from '@/hooks/userQueryHooks'; -import UserInfo from '@/types/user'; -import EmotionMonthlyLogs from '@/pageLayout/MypageLayout/EmotionMonthlyLogs'; -import Profile from '@/user/ui-profile/Profile'; -import { useRouter } from 'next/navigation'; -import TodayEmotion from '@/components/main/TodayEmotion'; -import MyContent from './MyContent'; - -export default function MyPageLayout() { - const { data, isLoading, isError }: { data: UserInfo | undefined; isLoading: boolean; isError: boolean } = useMeQuery(); - - const router = useRouter(); - - if (isError) { - return
error
; - } - - if (isLoading) { - return
loading
; - } - - // NOTE: 회원정보가 확인되지 않는다면 로그인 페이지로 이동 - if (!data) { - router.push('/login'); - return false; - } - - return ( -
- -
-
- -
- -
- -
-
- -
-
- ); -} diff --git a/src/pages/mypage/index.tsx b/src/pages/mypage/index.tsx deleted file mode 100644 index 69b8c83e..00000000 --- a/src/pages/mypage/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import MyPageLayout from '@/pageLayout/MypageLayout/MyPageLayout'; - -export default function mypage() { - return ; -} diff --git a/tailwind.config.js b/tailwind.config.js index e6d59f44..5d387aa6 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -52,14 +52,14 @@ module.exports = { 'sub-gray_3': '#EFF3F8', }, screens: { - 'sm': '640px', - 'md': '768px', - 'lg': '1024px', - 'xl': '1280px', + sm: '640px', + md: '768px', + lg: '1024px', + xl: '1280px', '2xl': '1536px', }, backgroundImage: { - 'stripes': 'repeating-linear-gradient(to bottom, #ffffff, #ffffff 23px, #e5e7eb 23px, #e5e7eb 24px)', + stripes: 'repeating-linear-gradient(to bottom, #ffffff, #ffffff 23px, #e5e7eb 23px, #e5e7eb 24px)', }, }, },