diff --git a/src/app/routes/private/ArticlesPage.tsx b/src/app/routes/private/ArticlesPage.tsx index 4d85c03..7bde114 100644 --- a/src/app/routes/private/ArticlesPage.tsx +++ b/src/app/routes/private/ArticlesPage.tsx @@ -4,8 +4,7 @@ import type { ArticlesOrderBy, RestoreArticlesParams, } from "@/api/articles/types"; -import { getInterests } from "@/api/interests"; -import type { InterestListItem, InterestOrderBy } from "@/api/interests/types"; +import type { InterestListItem } from "@/api/interests/types"; import Button from "@/shared/components/button/Button"; import EmptyState from "@/shared/components/EmptyState"; import Input from "@/shared/components/Input"; @@ -28,6 +27,7 @@ import { useSearchParams, } from "react-router"; import { toast } from "react-toastify"; +import { getUserActivities } from "@/api/user-activities"; interface ApiErrorResponse { message: string; @@ -38,10 +38,6 @@ interface ApiErrorResponse { status?: number; } -const INTEREST_ORDER_BY = "name" as InterestOrderBy; -const INTEREST_DIRECTION = "DESC" as SortDirection; -const INTEREST_LIMIT = 9999; - export default function ArticlesPage() { const [searchParams, setSearchParams] = useSearchParams(); @@ -118,10 +114,10 @@ export default function ArticlesPage() { }; const [sortValue, setSortValue] = useState( - reverseSortMap[orderBy] || "게시일" + reverseSortMap[orderBy] || "게시일", ); const [directionValue, setDirectionValue] = useState( - direction === "DESC" ? "내림차순" : "오름차순" + direction === "DESC" ? "내림차순" : "오름차순", ); const fetchInitialData = useCallback(async () => { @@ -199,14 +195,16 @@ export default function ArticlesPage() { const fetchInterestData = useCallback(async () => { try { - const interestParams = { - orderBy: INTEREST_ORDER_BY, - direction: INTEREST_DIRECTION, - limit: INTEREST_LIMIT, - }; - - const response = await getInterests(interestParams, userId); - setInterests(response.content); + const response = await getUserActivities(userId); + + const userInterests = response.subscriptions.map((sub) => ({ + id: sub.interestId, + name: sub.interestName, + keywords: sub.interestKeywords, + subscriberCount: sub.interestSubscriberCount, + subscribedByMe: true, + })); + setInterests(userInterests); } catch (error) { console.error(error); } @@ -227,7 +225,7 @@ export default function ArticlesPage() { }, { threshold: 0.8, - } + }, ); if (lastElementRef.current) { observerRef.current.observe(lastElementRef.current); @@ -240,13 +238,13 @@ export default function ArticlesPage() { const interestNames = useMemo( () => interests.map((interest) => interest.name), - [interests] + [interests], ); const handleInterestChange = (value: string) => { setSelectedInterest(value); const selectedInterestData = interests.find( - (interest) => interest.name === value + (interest) => interest.name === value, ); if (selectedInterestData) { @@ -292,13 +290,13 @@ export default function ArticlesPage() { newParams.set( "direction", - directionValue === "오름차순" ? "ASC" : "DESC" + directionValue === "오름차순" ? "ASC" : "DESC", ); if (fromDate) { newParams.set( "publishDateFrom", - `${fromDate.replace(/\./g, "-")}T00:00:00` + `${fromDate.replace(/\./g, "-")}T00:00:00`, ); } else { newParams.delete("publishDateFrom"); @@ -306,7 +304,7 @@ export default function ArticlesPage() { if (toDate) { newParams.set( "publishDateTo", - `${toDate.replace(/\./g, "-")}T23:59:59` + `${toDate.replace(/\./g, "-")}T23:59:59`, ); } else { newParams.delete("publishDateTo"); diff --git a/src/shared/components/modal/ArticleDetailModal.tsx b/src/shared/components/modal/ArticleDetailModal.tsx index a7d6206..bca39c8 100644 --- a/src/shared/components/modal/ArticleDetailModal.tsx +++ b/src/shared/components/modal/ArticleDetailModal.tsx @@ -143,7 +143,7 @@ export default function ArticleDetailModal({ }, { threshold: 0.8, - } + }, ); if (lastElementRef.current) { observerRef.current.observe(lastElementRef.current); @@ -228,12 +228,8 @@ export default function ArticleDetailModal({ title: "댓글 삭제", message: "정말 삭제하시겠습니까?", onConfirm: async () => { - console.log("onConfirm 함수 실행 시작"); - try { - console.log("deleteComment 호출 전"); await deleteComment(commentId); - console.log("deleteComment 호출 후"); toast.success("댓글이 삭제되었습니다."); await fetchInitialData(); } catch (error) {