import { AuditTimeline } from '@/components';
import { ProDescriptions, ProDescriptionsItemProps } from '@ant-design/pro-components';
import { Card, Drawer } from 'antd';
import { useState } from 'react';

export type ExamSpecialStudentDetailDrawerProps = {
    columns: ProDescriptionsItemProps<Partial<API.ExamSpecialStudentOutput>>[];
    data: Partial<API.ExamSpecialStudentOutput>;
    /** 关闭回调函数 */
    onClose: () => void;
};

/** 监测特殊学生详情 */
const ExamSpecialStudentDetailDrawer: React.FC<ExamSpecialStudentDetailDrawerProps> = ({ columns, data, onClose }) => {
    const [open, setOpen] = useState<boolean>(true);
    const handleClose = () => { setOpen(false); setTimeout(onClose, 300); };
    return (
        <Drawer
            title="特殊学生详情"
            width={1080}
            open={open}
            onClose={handleClose}
            className="yb-pro-desc hide-header"
        >
            <ProDescriptions
                columns={columns}
                column={1}
                dataSource={data}
                labelStyle={{ width: 96 }}
            >
                <ProDescriptions.Item label="审核记录">
                    {data.auditList && data.auditList.length > 0 ?
                        <Card style={{ width: '100%' }} bodyStyle={{ paddingBottom: 0 }}>
                            <AuditTimeline auditList={data.auditList} />
                        </Card> : '无'
                    }
                </ProDescriptions.Item>
            </ProDescriptions>
        </Drawer>
    );
};

export default ExamSpecialStudentDetailDrawer;
