import { Tag, Typography } from 'antd'; import React from 'react'; import XinTable from '@/components/XinTable'; import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings'; import type IRunnerWorker from '@/domain/iRunnerWorker'; 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[] = [ { title: t('runner.worker.id'), dataIndex: 'id', hideInForm: true, sorter: true, align: 'center', width: 80, }, { title: t('runner.worker.user_id'), dataIndex: 'user_id', valueType: 'text', align: 'center', }, { title: t('runner.worker.real_name'), dataIndex: 'real_name', valueType: 'text', align: 'center', }, { title: t('runner.worker.mobile'), dataIndex: 'mobile', valueType: 'text', align: 'center', }, { title: t('runner.worker.id_card'), dataIndex: 'id_card', valueType: 'text', align: 'center', hideInSearch: true, }, { title: t('runner.worker.total_income'), dataIndex: 'total_income', valueType: 'text', align: 'center', hideInSearch: true, }, { title: t('runner.worker.total_order'), dataIndex: 'total_order', valueType: 'text', align: 'center', hideInSearch: true, }, { title: t('runner.worker.cancel_order'), dataIndex: 'cancel_order', valueType: 'text', align: 'center', hideInSearch: true, }, { title: t('runner.worker.credit_score'), dataIndex: 'credit_score', valueType: 'text', align: 'center', hideInSearch: true, }, { title: t('runner.worker.verified_at'), dataIndex: 'verified_at', hideInForm: true, hideInSearch: true, align: 'center', render: (value: string) => (value ? dayjs(value).fromNow() : '-'), }, { title: t('runner.worker.status'), dataIndex: 'status', valueType: 'radioButton', fieldProps: { options: [ { value: 0, label: t('runner.worker.status.0') }, { value: 1, label: t('runner.worker.status.1') }, ], }, render: (value: number) => { return value === 1 ? {t('runner.worker.status.1')} : {t('runner.worker.status.0')}; }, filters: [ { text: t('runner.worker.status.0'), value: 0 }, { text: t('runner.worker.status.1'), value: 1 }, ], align: 'center', }, { title: t('runner.worker.created_at'), hideInForm: true, hideInSearch: true, dataIndex: 'created_at', align: 'center', render: (value: string) => (value ? dayjs(value).fromNow() : '-'), }, { title: t('runner.worker.updated_at'), hideInForm: true, hideInSearch: true, dataIndex: 'updated_at', align: 'center', render: (value: string) => (value ? dayjs(value).fromNow() : '-'), }, ]; const tableProps: XinTableProps = { api: '/runner/worker', columns, rowKey: 'id', accessName: 'runner.worker', formProps: { grid: true, colProps: { span: 12 }, rowProps: { gutter: [30, 0] }, layout: 'vertical', }, modalProps: { width: 800, }, cardProps: { variant: 'borderless', }, pagination: { size: 'small', style: { marginBottom: 0 }, }, }; return ( <>
{t('runner.worker.page.title')} {t('runner.worker.page.description')}
{...tableProps} /> ); }; export default Table;