diff --git a/apps/member/src/api/board.ts b/apps/member/src/api/board.ts index a3ce3088..a31f9510 100644 --- a/apps/member/src/api/board.ts +++ b/apps/member/src/api/board.ts @@ -4,7 +4,7 @@ import { END_POINT } from '@constants/api'; import { createCommonPagination } from '@utils/api'; import type { BoardItem } from '@type/board'; import type { - CommunityCategoryKorType, + CommunityCategoryType, CommunityPostDetailItem, CommunityWriteItem, } from '@type/community'; @@ -40,13 +40,16 @@ export const getBoards = async (page: number, size: number) => { * 커뮤니티 게시글 카테고리별 조회 */ export const getBoardsList = async ( - category: CommunityCategoryKorType, + category: CommunityCategoryType, page: number, size: number, ) => { - const params = { category, page, size }; const { data } = await server.get>({ - url: createCommonPagination(END_POINT.BOARDS_LIST, params), + url: createCommonPagination(END_POINT.BOARDS_LIST, { + category: category.toUpperCase(), + page, + size, + }), }); return data; diff --git a/apps/member/src/api/comment.ts b/apps/member/src/api/comment.ts index 5686162e..050ebdac 100644 --- a/apps/member/src/api/comment.ts +++ b/apps/member/src/api/comment.ts @@ -13,18 +13,22 @@ interface commentWriteArgs { boardId: string; body: CommentWriteItem; } - -// 나의 댓글 조회 +/** + * 나의 댓글 조회 + */ export const getMyComments = async (page: number, size: number) => { - const params = { page, size }; const { data } = await server.get>({ - url: createCommonPagination(END_POINT.MY_COMMENTS, params), + url: createCommonPagination(END_POINT.MY_COMMENTS, { + page, + size, + }), }); return data; }; - -// 댓글 목록 조회 +/** + * 댓글 목록 조회 + */ export const getCommentList = async ( id: string, page: number, @@ -37,20 +41,19 @@ export const getCommentList = async ( return data; }; - -// 댓글 작성 +/** + * 댓글 작성 + */ export const postCommentWrite = async ({ parentId, boardId, body, }: commentWriteArgs) => { - let url = createPath(END_POINT.COMMENTS(boardId)); - if (parentId) { - url += `?parentId=${parentId}`; - } - const { data } = await server.post({ - url, + url: createPath( + END_POINT.COMMENTS(boardId), + parentId && `?parentId=${parentId}`, + ), body, }); diff --git a/apps/member/src/components/my/MyHistorySection/MyHistorySection.tsx b/apps/member/src/components/my/MyHistorySection/MyHistorySection.tsx index 736ced04..5297c506 100644 --- a/apps/member/src/components/my/MyHistorySection/MyHistorySection.tsx +++ b/apps/member/src/components/my/MyHistorySection/MyHistorySection.tsx @@ -4,12 +4,12 @@ import Section from '@components/common/Section/Section'; import { toYYMMDD } from '@utils/date'; import { CommentItem } from '@type/comment'; import { PATH_FINDER } from '@constants/path'; -import { titleToCategory } from '@utils/community'; import useModal from '@hooks/common/useModal'; +import { Badge } from '@clab/design-system'; import type { BookLoanRecordConditionType } from '@type/book'; import type { BoardItem } from '@type/board'; import type { NotificationItem } from '@type/notification'; -import { Badge } from '@clab/design-system'; + interface MyHistorySectionProps { title: string; data: Array< @@ -44,10 +44,7 @@ const MyHistorySection = ({ title, data }: MyHistorySectionProps) => { return (

{content}

{toYYMMDD(createdAt)}

@@ -94,7 +91,7 @@ const MyHistorySection = ({ title, data }: MyHistorySectionProps) => { return (

{title}

{toYYMMDD(createdAt)}

diff --git a/apps/member/src/hooks/queries/useBoardsList.ts b/apps/member/src/hooks/queries/useBoardsList.ts index 6d59f5be..1e9c12e1 100644 --- a/apps/member/src/hooks/queries/useBoardsList.ts +++ b/apps/member/src/hooks/queries/useBoardsList.ts @@ -2,10 +2,9 @@ import { getMyHire } from '@api/hire'; import { getNews } from '@api/news'; import { QUERY_KEY } from '@constants/key'; import { useSuspenseQuery } from '@tanstack/react-query'; -import { categoryToTitle } from '@utils/community'; -import type { CommunityCategoryType } from '@type/community'; import { getBoardsList } from '@api/board'; import { PaginationPramsType } from '@type/api'; +import type { CommunityCategoryType } from '@type/community'; interface UseBoardsListParams extends PaginationPramsType { category: CommunityCategoryType; @@ -22,19 +21,19 @@ export const useBoardsList = ({ const queryOptions = { notice: { queryKey: QUERY_KEY.BORDER_NOTICE, - queryFn: () => getBoardsList(categoryToTitle('notice'), page, size), + queryFn: () => getBoardsList('notice', page, size), }, free: { queryKey: QUERY_KEY.BORDER_FREE, - queryFn: () => getBoardsList(categoryToTitle('free'), page, size), + queryFn: () => getBoardsList('free', page, size), }, qna: { queryKey: QUERY_KEY.BORDER_QNA, - queryFn: () => getBoardsList(categoryToTitle('qna'), page, size), + queryFn: () => getBoardsList('qna', page, size), }, graduated: { queryKey: QUERY_KEY.BORDER_GRADUATED, - queryFn: () => getBoardsList(categoryToTitle('graduated'), page, size), + queryFn: () => getBoardsList('graduated', page, size), }, news: { queryKey: QUERY_KEY.NEWS, diff --git a/apps/member/src/types/board.ts b/apps/member/src/types/board.ts index 1785026c..a7fb2264 100644 --- a/apps/member/src/types/board.ts +++ b/apps/member/src/types/board.ts @@ -1,8 +1,8 @@ -import type { CommunityCategoryKorType } from './community'; +import type { CommunityCategoryType } from './community'; export interface BoardType { id: number; - category: CommunityCategoryKorType; + category: CommunityCategoryType; title: string; } diff --git a/apps/member/src/types/comment.ts b/apps/member/src/types/comment.ts index 95fc5526..d86a153f 100644 --- a/apps/member/src/types/comment.ts +++ b/apps/member/src/types/comment.ts @@ -1,4 +1,4 @@ -import type { CommunityCategoryKorType } from './community'; +import type { CommunityCategoryType } from './community'; export interface CommentItem { id: number; @@ -6,7 +6,7 @@ export interface CommentItem { writerImageUrl: string; content: string; boardId: number; - boardCategory: CommunityCategoryKorType; + boardCategory: CommunityCategoryType; hasLikeByMe: boolean; likes: number; writer: string;