Files
xin-school/web/pages/forum/post-favorite/index.tsx
T
2026-05-31 03:47:57 +08:00

85 lines
2.1 KiB
TypeScript

import { Typography } from 'antd';
import React from 'react';
import XinTable from '@/components/XinTable';
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
import type IForumPostFavorite from '@/domain/iForumPostFavorite';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
const { Title, Text } = Typography;
dayjs.extend(relativeTime);
const Table: React.FC = () => {
const { t } = useTranslation();
const columns: XinTableColumn<IForumPostFavorite>[] = [
{
title: t('forum.post-favorite.id'),
dataIndex: 'id',
hideInForm: true,
sorter: true,
align: 'center',
width: 80,
},
{
title: t('forum.post-favorite.post_id'),
dataIndex: 'post_id',
valueType: 'text',
align: 'center',
},
{
title: t('forum.post-favorite.user_id'),
dataIndex: 'user_id',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('forum.post-favorite.created_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'created_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
];
const tableProps: XinTableProps<IForumPostFavorite> = {
api: '/forum/post-favorite',
columns,
rowKey: 'id',
accessName: 'forum.post-favorite',
createShow: false,
editShow: false,
formProps: {
grid: true,
colProps: { span: 12 },
rowProps: { gutter: [30, 0] },
layout: 'vertical',
},
modalProps: {
width: 500,
},
cardProps: {
variant: 'borderless',
},
pagination: {
size: 'small',
style: { marginBottom: 0 },
},
};
return (
<>
<div className="mb-5">
<Title level={3}>{t('forum.post-favorite.page.title')}</Title>
<Text type="secondary">{t('forum.post-favorite.page.description')}</Text>
</div>
<XinTable<IForumPostFavorite> {...tableProps} />
</>
);
};
export default Table;