Skip to content

Commit

Permalink
Merge pull request #312 from ssu-student-union/feat/#310_header_notice
Browse files Browse the repository at this point in the history
Feat/#310 header notice
  • Loading branch information
jongse7 authored Nov 6, 2024
2 parents 96a913c + 6c7ba8d commit 1de34ab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/containers/common/Header/const/pathData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ export const menuItems = {
path: '/intro?category=central_executive_committee&sub-category=intro',
},
],
공지사항: [
{
name: '중앙 공지사항',
path: '/notice?category=중앙',
},
{
name: '단과대 공지사항',
path: '/notice?category=단과대',
},
],
학교생활: [
{ name: '공지사항', path: '/notice' },
// { name: '일정', path: '/menu7' },
Expand Down
4 changes: 3 additions & 1 deletion src/pages/notice/hooks/useNoticeBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export function useNoticeBoard(boardCode: string, category: string, subCategory:
const searchQuery = useRecoilValue(SearchState);

useEffect(() => {
handlePageChange(1);
if (currentPage !== 1) {
handlePageChange(1);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [category, subCategory]);

Expand Down
15 changes: 14 additions & 1 deletion src/pages/notice/hooks/useNoticeCategory.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { subName, subName2 } from '../const/data';
import { useSearchParams } from 'react-router-dom';

export function useNoticeCategory() {
const [category, setCategory] = useState<string>('중앙');
const [subCategory, setSubCategory] = useState<string>('전체');
const [subCategorys, setSubCategorys] = useState<string[]>(subName);

const [searchParams, setSearchParams] = useSearchParams();
const categoryParam = searchParams.get('category');

useEffect(() => {
if (categoryParam) {
handleCategoryChange(categoryParam);
}
const newParams = new URLSearchParams(searchParams);
newParams.delete('category');
setSearchParams(newParams);
}, [categoryParam]);

const handleCategoryChange = (newCategory: string) => {
setCategory(newCategory);
setSubCategory('전체');
Expand Down

0 comments on commit 1de34ab

Please sign in to comment.