Skip to content

Commit e4fb431

Browse files
committed
feat(graduate): table row 선택시 상세 페이지로 이동
1 parent a8646bf commit e4fb431

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

apps/graduate/src/pages/client/home/ui/NoticeSection.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Link } from '@tanstack/react-router';
1+
import { Link, useNavigate } from '@tanstack/react-router';
22
import { FileText } from 'lucide-react';
33

44
import { DataTable, Section } from '~/shared/components';
@@ -17,6 +17,7 @@ type NoticeRow = {
1717
};
1818

1919
export default function NoticeSection() {
20+
const navigate = useNavigate();
2021
const { data, isLoading } = useNoticeList({
2122
category: 'GRADUATION',
2223
page: 0,
@@ -46,7 +47,9 @@ export default function NoticeSection() {
4647
display: 'flex',
4748
alignItems: 'center',
4849
gap: '8px',
50+
cursor: 'pointer',
4951
}}
52+
onClick={() => navigate({ to: `/notice/${row.noticeId}` })}
5053
>
5154
{row.isPinned && (
5255
<span
@@ -74,7 +77,14 @@ export default function NoticeSection() {
7477
header: '작성자',
7578
width: '20%',
7679
align: 'center' as const,
77-
cell: (row: NoticeRow) => row.author,
80+
cell: (row: NoticeRow) => (
81+
<div
82+
style={{ cursor: 'pointer' }}
83+
onClick={() => navigate({ to: `/notice/${row.noticeId}` })}
84+
>
85+
{row.author}
86+
</div>
87+
),
7888
},
7989
{
8090
key: 'createdAt',
@@ -83,11 +93,18 @@ export default function NoticeSection() {
8393
align: 'center' as const,
8494
cell: (row: NoticeRow) => {
8595
const dateObj = new Date(row.createdAt);
86-
return dateObj.toLocaleDateString('ko-KR', {
87-
year: 'numeric',
88-
month: '2-digit',
89-
day: '2-digit',
90-
});
96+
return (
97+
<div
98+
style={{ cursor: 'pointer' }}
99+
onClick={() => navigate({ to: `/notice/${row.noticeId}` })}
100+
>
101+
{dateObj.toLocaleDateString('ko-KR', {
102+
year: 'numeric',
103+
month: '2-digit',
104+
day: '2-digit',
105+
})}
106+
</div>
107+
);
91108
},
92109
},
93110
];

apps/graduate/src/pages/client/notice/ui/NoticePage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useNavigate } from '@tanstack/react-router';
12
import { Table, Tag, Spin } from 'antd';
23
import type { ColumnsType } from 'antd/es/table';
34
import { FileText } from 'lucide-react';
@@ -18,6 +19,7 @@ interface NoticeDataType {
1819
}
1920

2021
export default function NoticePage() {
22+
const navigate = useNavigate();
2123
const { data, isLoading } = useNoticeList({
2224
category: 'GRADUATION',
2325
page: 0,
@@ -129,8 +131,7 @@ export default function NoticePage() {
129131
scroll={{ x: 'max-content' }}
130132
onRow={record => ({
131133
onClick: () => {
132-
// TODO: 상세 페이지로 이동
133-
console.log('Notice clicked:', record.noticeId);
134+
navigate({ to: `/notice/${record.noticeId}` });
134135
},
135136
style: { cursor: 'pointer' },
136137
})}

apps/graduate/src/shared/hooks/notice/useNoticeDetail.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { transformNoticeDetailResponse } from '~/shared/utils';
66

77
export function useNoticeDetail(noticeId: number) {
88
return useQuery({
9-
queryKey: [KEYS.NOTICE, noticeId],
9+
queryKey: [KEYS.NOTICE, 'detail', noticeId],
1010
queryFn: async () => {
1111
const response = await getNoticeDetail(noticeId);
1212
return transformNoticeDetailResponse(response.data);

apps/graduate/src/shared/hooks/notice/useNoticeList.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ export function useNoticeList(params?: NoticeListParams) {
1919
},
2020
});
2121
}
22+
23+
export { useNoticeDetail } from './useNoticeDetail';

0 commit comments

Comments
 (0)