import BTable from "@/components/b_table";
import { UserDataType } from "@/model/userModel";
import { Store } from "antd/es/form/interface";
import { ColumnsType } from "antd/lib/table";
import { inject, observer } from "mobx-react";
import { useEffect, useState } from "react";
interface EmUserInterface {
  emergencyStore?: Store;
  id?: string;
}
const EmUser = (props: EmUserInterface) => {
  const { emergencyStore, id } = props;
  const [ulist, setUlist] = useState<number | null>(0);

  useEffect(() => {
    emergencyStore?.getUserlist(id).then((e) => {
      setUlist(e.data.record);
    });
  }, [emergencyStore, id]);

  const _columns: ColumnsType<UserDataType> = [
    { title: "民兵名称", dataIndex: "user_name" },
    { title: "民兵描述", dataIndex: "remark" },
    { title: "民兵账号", dataIndex: "account" },
    {
      title: "是否接收任务",
      dataIndex: "acce_status",
      render(value, record, index) {
        return value ? "是" : "否";
      }
    },
    { title: "拒绝原因", dataIndex: "reject" },
  ];
  return (
    <>
      <div style={{ display: "flex", justifyContent: "space-between" }}>
        <p>训练人员</p>
      </div>
      <BTable
        store={emergencyStore}
        columns={_columns}
        dataSource={ulist}
        selectCallback={(e) => {}}
      />
    </>
  );
};

export default inject("emergencyStore")(observer(EmUser));
