import { SuperTable } from '@/components';
import BaseCourseController from '@/services/apis/BaseCourseController';
import { ActionType, PageContainer, ProColumns } from '@ant-design/pro-components';
import { useRef } from 'react';

/** 学科列表 */
const CourseList: React.FC = () => {
    const actionRef = useRef<ActionType>();

    const columns: ProColumns<API.CourseOutput>[] = [
        {
            title: 'ID',
            dataIndex: 'id',
            width: 80,
            align: 'center',
        },
        {
            title: '名称',
            dataIndex: 'name',
            width: 96,
            align: 'center',
        },
        {
            title: '简称',
            dataIndex: 'shortName',
            width: 96,
            align: 'center',
        },
        {
            title: '别称',
            dataIndex: 'nickName',
            width: 96,
            align: 'center',
        },
        {
            title: '备注',
            dataIndex: 'remark',
        },
    ];

    return (
        <PageContainer title={false} childrenContentStyle={{ paddingTop: 0 }}>
            <SuperTable<API.CourseOutput>
                headerTitle="学科列表"
                actionRef={actionRef}
                columns={columns}
                pagination={false}
                search={false}
                request={async () => {
                    // return SuperTable.requestPageAgent({ params, sort }, async (p) => {
                    //     const res = await BaseCourseController.getAllList();
                    //     return res;
                    // });
                    const data = await BaseCourseController.getAllList();
                    return { data, success: true };
                }}
            />
        </PageContainer>
    );
};

export default CourseList;
