import React, { useMemo } from "react";
import styles from "./index.module.scss";
import { Modal } from "antd";
import { A1TableType } from "@/types";

type Props = {
  data: A1TableType;
  closeModelFu: () => void;
};

function A1Look({ data, closeModelFu }: Props) {
  const infoArr = useMemo(() => {
    const arr: any = [];

    const arr1 = data.contact.split(",");

    arr1.forEach((v) => {
      arr.push({
        name: v.split("-")[0] + " - " + v.split("-")[1],
        zheng: v.split("-")[2] || "无",
      });
    });

    return arr;
  }, [data.contact]);

  return (
    <Modal
      wrapClassName={styles.A1Look}
      destroyOnClose
      open={true}
      title="预约详情"
      onCancel={closeModelFu}
      footer={
        [] // 设置footer为空，去掉 取消 确定默认按钮
      }
    >
      <div className="A1MBox">
        <div className="A1MBoxL">申请时间：</div>
        <div className="A1MBoxR">
          <p>{data.createTime}</p>
        </div>
      </div>

      <div className="A1MBox">
        <div className="A1MBoxL">参观展馆：</div>
        <div className="A1MBoxR">
          <p>{data.exhibitionName}</p>
        </div>
      </div>

      <div className="A1MBox">
        <div className="A1MBoxL">所在单位：</div>
        <div className="A1MBoxR">
          <p>{data.organ}</p>
        </div>
      </div>

      <div className="A1MBox">
        <div className="A1MBoxL">预约人：</div>
        <div className="A1MBoxR">
          {infoArr.map((v: any, i: number) => (
            <div className="infoP" key={i}>
              <p>{v.name}</p>
              <p>{v.zheng}</p>
            </div>
          ))}
        </div>
      </div>

      <div className="A1MBox">
        <div className="A1MBoxL">预约时间：</div>
        <div className="A1MBoxR">
          <p>{data.bookDay + " " + data.bootTimeScope}</p>
        </div>
      </div>

      <div className="A1MBox">
        <div className="A1MBoxL">备注：</div>
        <div className="A1MBoxR">
          <p>{data.description ? data.description : "无"}</p>
        </div>
      </div>
      <br />
      <br />
    </Modal>
  );
}

const MemoA1Look = React.memo(A1Look);

export default MemoA1Look;
