Skip to content

Commit

Permalink
Merge pull request #285 from ssu-student-union/fix/#283_audit_pagination
Browse files Browse the repository at this point in the history
Fix/#283 audit pagination
  • Loading branch information
jongse7 authored Oct 24, 2024
2 parents 63dcfdc + d697665 commit 51b0455
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/pages/audit/auditEdit/utils/fileHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ export function onDrop(

export function addEmptyField(files: FileItem[], setFiles: (files: FileItem[]) => void) {
setFiles([...files, { id: Date.now(), file: null }]);
console.log(files);
}
10 changes: 4 additions & 6 deletions src/pages/audit/hooks/useAuditBoard.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { useGetBoardPostSearch } from '@/hooks/useGetBoardPostSearch';
import { useResponseBoard } from '@/hooks/useResponseBoard';
import { useCurrentPage } from '@/hooks/useCurrentPage';
import { useCategory } from './useCategory';
import { categoryMap } from '../const/data';
import { useRecoilValue } from 'recoil';
import { SearchState } from '@/recoil/atoms/atom';
import { useEffect } from 'react';
import { AuditResponse } from '../types';

export function useAuditBoard(boardCode: string) {
export function useAuditBoard(boardCode: string, category: string) {
const { itemsPerPage } = useResponseBoard();
const { currentPage, handlePageChange } = useCurrentPage();
const { categoryParam } = useCategory();

const searchQuery = useRecoilValue(SearchState);

const subcategories = Object.values(categoryMap).filter(Boolean) as string[];
const selectedCategory = categoryMap[categoryParam] === '전체' ? null : categoryMap[categoryParam];
const selectedCategory = categoryMap[category] === '전체' ? null : categoryMap[category];

useEffect(() => {
handlePageChange(1);
}, [categoryParam, handlePageChange]);
}, [category]);

const { data, isLoading, isError } = useGetBoardPostSearch<AuditResponse>({
boardCode,
Expand All @@ -38,7 +36,7 @@ export function useAuditBoard(boardCode: string) {
totalPages,
currentPage,
handlePageChange,
categoryParam,
category,
subcategories,
isLoading,
isError,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/audit/hooks/useCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
export function useCategory() {
const navigate = useNavigate();
const [searchParams] = useSearchParams();
const categoryParam = searchParams.get('category') || 'all';
const category = searchParams.get('category') || 'all';

return {
navigate,
categoryParam,
category,
};
}
10 changes: 7 additions & 3 deletions src/pages/audit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import { useAuditBoard } from './hooks/useAuditBoard';
import { categoryMap } from './const/data';
import { useNavigate } from 'react-router-dom';
import { BoardContent } from '@/template/board/BoardContent';
import { useCategory } from './hooks/useCategory';

export function AuditPage() {
const boardCode = '감사기구게시판';
const { data, totalPages, currentPage, handlePageChange, categoryParam, subcategories, isLoading } =
useAuditBoard(boardCode);
const { category } = useCategory();
const { data, totalPages, currentPage, handlePageChange, subcategories, isLoading } = useAuditBoard(
boardCode,
category
);

const navigate = useNavigate();

Expand All @@ -35,7 +39,7 @@ export function AuditPage() {
selector={
<BoardSelector
subcategories={subcategories}
selectedSubcategory={categoryMap[categoryParam] || '전체'}
selectedSubcategory={categoryMap[category] || '전체'}
onSubcategorySelect={(selectedCategory) => {
const categoryKey = Object.keys(categoryMap).find((key) => categoryMap[key] === selectedCategory);
if (categoryKey) {
Expand Down
1 change: 0 additions & 1 deletion src/pages/notice/hooks/useNoticeToday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export function useTodayPosts(boardCode: string, category: string, subCategory:
});

const posts: Post[] = data?.data?.postListResDto || [];
console.log(posts);

const isPostToday = (dateString: string): boolean => {
const today = new Date();
Expand Down
1 change: 0 additions & 1 deletion src/pages/notice/noticePatch/hook/useNoticePatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function useNoticePatch() {
uploadedFileList = handleFileLists(postFiles);
}

console.log(isUrgent);
await patchPost({
boardCode,
postId,
Expand Down
3 changes: 0 additions & 3 deletions src/pages/notice/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ export function NoticePage() {
);
const { todayPostCount, isLoading: isPostsLoading } = useTodayPosts(boardCode, category, subCategory);

console.log(todayPostCount);
console.log(category, subCategory);

return (
<>
<HeadLayout
Expand Down
1 change: 0 additions & 1 deletion src/pages/partnership/partnershipDetail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export function PartnershipDetailPage() {
const boardCode: string = '제휴게시판';

const { data: resp } = useGetBoardDetail({ boardCode, postId });
console.log(resp);

const postDetail = resp?.data.postDetailResDto;

Expand Down

0 comments on commit 51b0455

Please sign in to comment.