Skip to content

Commit

Permalink
Merge pull request #226 from ssu-student-union/feat/#148_jongse_qa_3
Browse files Browse the repository at this point in the history
fix: useCurrent
  • Loading branch information
jongse7 authored Oct 14, 2024
2 parents e32b78a + cac1b68 commit 0b44f59
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/apis/getBoardPosts.ts
Original file line number Diff line number Diff line change
@@ -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 ({
Expand All @@ -10,7 +10,7 @@ export const getBoardPosts = async ({
category,
boardCode,
}: getBoardPostsProps): Promise<GetBoardDetailResponse> => {
const response: AxiosResponse<GetBoardDetailResponse> = await clientAuth({
const response: AxiosResponse<GetBoardDetailResponse> = await client({
url: `/board/${boardCode}/posts`,
method: 'get',
params: {
Expand Down
5 changes: 1 addition & 4 deletions src/pages/notice/hooks/useNoticeToday.ts
Original file line number Diff line number Diff line change
@@ -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<number>(0);
const [stopFetching, setStopFetching] = useState<boolean>(false);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/notice/noticeEdit/hook/useNoticeEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/notice/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function NoticePage() {
category,
subCategory
);
const { todayPostCount, isLoading: isPostsLoading } = useTodayPosts(boardCode);
const { todayPostCount, isLoading: isPostsLoading } = useTodayPosts(boardCode, category, subCategory);

return (
<>
Expand Down
3 changes: 2 additions & 1 deletion src/template/board/BoardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 } })}
/>
</div>
);
Expand Down
5 changes: 5 additions & 0 deletions src/template/board/boardData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const nameToUrl: Map<string, string> = new Map([
['공지사항게시판', 'notice'],
['감사기구게시판', 'audit'],
['분실물게시판', 'lost-article'],
]);

0 comments on commit 0b44f59

Please sign in to comment.