Skip to content

Commit

Permalink
fix(member): resolved inconsistency caused by English `border categor…
Browse files Browse the repository at this point in the history
…y` (#86)
  • Loading branch information
gwansikk committed Apr 6, 2024
1 parent de3ac6d commit b9eb8cb
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 35 deletions.
11 changes: 7 additions & 4 deletions apps/member/src/api/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<PaginationType<PostItem>>({
url: createCommonPagination(END_POINT.BOARDS_LIST, params),
url: createCommonPagination(END_POINT.BOARDS_LIST, {
category: category.toUpperCase(),
page,
size,
}),
});

return data;
Expand Down
31 changes: 17 additions & 14 deletions apps/member/src/api/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PaginationType<CommentItem>>({
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,
Expand All @@ -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<CommentWriteItem, BaseResponse>({
url,
url: createPath(
END_POINT.COMMENTS(boardId),
parentId && `?parentId=${parentId}`,
),
body,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down Expand Up @@ -44,10 +44,7 @@ const MyHistorySection = ({ title, data }: MyHistorySectionProps) => {
return (
<ListButton
key={id}
to={PATH_FINDER.COMMUNITY_POST(
titleToCategory(boardCategory),
boardId,
)}
to={PATH_FINDER.COMMUNITY_POST(boardCategory, boardId)}
>
<p className="pr-4 truncate grow">{content}</p>
<p className="text-clab-main-light">{toYYMMDD(createdAt)}</p>
Expand Down Expand Up @@ -94,7 +91,7 @@ const MyHistorySection = ({ title, data }: MyHistorySectionProps) => {
return (
<ListButton
key={id}
to={PATH_FINDER.COMMUNITY_POST(titleToCategory(category), id)}
to={PATH_FINDER.COMMUNITY_POST(category, id)}
>
<p className="pr-4 truncate grow">{title}</p>
<p className="text-clab-main-light">{toYYMMDD(createdAt)}</p>
Expand Down
11 changes: 5 additions & 6 deletions apps/member/src/hooks/queries/useBoardsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions apps/member/src/types/board.ts
Original file line number Diff line number Diff line change
@@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/member/src/types/comment.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { CommunityCategoryKorType } from './community';
import type { CommunityCategoryType } from './community';

export interface CommentItem {
id: number;
writerName: string;
writerImageUrl: string;
content: string;
boardId: number;
boardCategory: CommunityCategoryKorType;
boardCategory: CommunityCategoryType;
hasLikeByMe: boolean;
likes: number;
writer: string;
Expand Down

0 comments on commit b9eb8cb

Please sign in to comment.