index.tsx
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Table from './Table';
import {
makeArticleURLWithNumber,
makeCategoryTableBody,
} from '@shared/functions';
import { useRouter } from 'next/router';
export default function Category({ category, articleList }) {
const router = useRouter();
// example
const newData = makeCategoryTableBody(articleList);
const handleRoute = ({ id }) => (e) => {
e.preventDefault();
if (id === '-') return;
const {
query: { name: categoryName },
} = router;
const URL = makeArticleURLWithNumber(categoryName as string, id);
router.push(URL);
};
return (
<div className={'outer-container category-table-container'}>
<Table
title={category}
columns={[
{
key: '1',
title: 'No.',
dataIndex: 'id',
align: 'center',
},
{ key: '2', title: '제목', dataIndex: 'title', width: '70%' },
{
key: '3',
title: '작성자',
dataIndex: 'author',
align: 'center',
},
{
key: '4',
title: '등록일',
dataIndex: 'created_date',
align: 'center',
},
]}
data={newData}
onRow={(record) => ({
onClick: handleRoute(record),
})}
/>
</div>
);
}