diff --git a/src/apis/getBoardPosts.ts b/src/apis/getBoardPosts.ts index 971a60e6..aba10265 100644 --- a/src/apis/getBoardPosts.ts +++ b/src/apis/getBoardPosts.ts @@ -1,5 +1,5 @@ import { GetBoardDetailResponse, getBoardPostsProps } from '@/types/apis/get'; -import { clientAuth } from './client'; +import { client } from './client'; import { AxiosResponse } from 'axios'; export const getBoardPosts = async ({ @@ -10,7 +10,7 @@ export const getBoardPosts = async ({ category, boardCode, }: getBoardPostsProps): Promise => { - const response: AxiosResponse = await clientAuth({ + const response: AxiosResponse = await client({ url: `/board/${boardCode}/posts`, method: 'get', params: { diff --git a/src/pages/notice/hooks/useNoticeToday.ts b/src/pages/notice/hooks/useNoticeToday.ts index 680f3905..d6ca74ec 100644 --- a/src/pages/notice/hooks/useNoticeToday.ts +++ b/src/pages/notice/hooks/useNoticeToday.ts @@ -1,13 +1,10 @@ import { useEffect, useState } from 'react'; import { useGetBoardPosts } from '@/hooks/useGetBoardPosts'; -import { useNoticeCategory } from './useNoticeCategory'; import { Post } from '@/types/apis/get'; import { useRecoilState } from 'recoil'; import { todayPostCountState } from '@/recoil/atoms/atom'; -export function useTodayPosts(boardCode: string) { - const { category, subCategory } = useNoticeCategory(); - +export function useTodayPosts(boardCode: string, category: string, subCategory: string) { const [todayPostCount, setTodayPostCount] = useRecoilState(todayPostCountState(category)); const [page, setPage] = useState(0); const [stopFetching, setStopFetching] = useState(false); diff --git a/src/pages/notice/noticeEdit/hook/useNoticeEdit.ts b/src/pages/notice/noticeEdit/hook/useNoticeEdit.ts index 9ef9ebdd..e8d57451 100644 --- a/src/pages/notice/noticeEdit/hook/useNoticeEdit.ts +++ b/src/pages/notice/noticeEdit/hook/useNoticeEdit.ts @@ -58,7 +58,7 @@ export function useNoticeEdit() { post: { title, content, - groupCode: groupCodeList[groupCodeList.length - 1], + groupCode: groupCodeList[0], memberCode: localStorage.getItem('memberName'), thumbNailImage: thumbnailImage, isNotice: isUrgent, diff --git a/src/pages/notice/page.tsx b/src/pages/notice/page.tsx index 6efce126..ca28310b 100644 --- a/src/pages/notice/page.tsx +++ b/src/pages/notice/page.tsx @@ -19,7 +19,7 @@ export function NoticePage() { category, subCategory ); - const { todayPostCount, isLoading: isPostsLoading } = useTodayPosts(boardCode); + const { todayPostCount, isLoading: isPostsLoading } = useTodayPosts(boardCode, category, subCategory); return ( <> diff --git a/src/template/board/BoardContent.tsx b/src/template/board/BoardContent.tsx index 5dbd5d91..00404e04 100644 --- a/src/template/board/BoardContent.tsx +++ b/src/template/board/BoardContent.tsx @@ -5,6 +5,7 @@ import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import BoardContentLoading from './BoardContentLoading'; import { formatYYYYMMDD } from '@/utils/formatYYYYMMDD'; +import { nameToUrl } from './boardData'; interface BoardContentProps { boardName: string; @@ -117,7 +118,7 @@ export function BoardContent({ boardName, data, isLoading }: BoardContentProps) badgeType={status} profileName={post.author} className="cursor-pointer" - onClick={() => navigate(`/${boardName}/${post.postId}`, { state: { postId: post.postId } })} + onClick={() => navigate(`/${nameToUrl.get(boardName)}/${post.postId}`, { state: { postId: post.postId } })} /> ); diff --git a/src/template/board/boardData.ts b/src/template/board/boardData.ts new file mode 100644 index 00000000..de5fa81a --- /dev/null +++ b/src/template/board/boardData.ts @@ -0,0 +1,5 @@ +export const nameToUrl: Map = new Map([ + ['공지사항게시판', 'notice'], + ['감사기구게시판', 'audit'], + ['분실물게시판', 'lost-article'], +]);