import React, { useEffect, useRef } from 'react';
import { Col, Divider, message, Modal, Row } from 'antd';
import type { AddressTableListItem, OptionLog } from '../data';
import { queryAddress } from '../service';
import type { ActionType, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';

export interface CreateFormProps {
  onCancel: () => void;
  onSubmit: () => void;
  addressModalVisible: boolean;
  memberId: number;
  logs: OptionLog[]
}

const LogsModal: React.FC<CreateFormProps> = (props) => {
  const actionRef = useRef<ActionType>();

  const {
    onSubmit,
    onCancel,
    addressModalVisible, memberId, logs } = props;


  useEffect(() => {
    let isMounted = true
    if (addressModalVisible) {
      // if (actionRef.current) {
      //   actionRef.current.reload();
      // }

      const fetchPost = async () => {
        if (isMounted) {
          // initTagsFunc()
          // initAllFunc()
          // initDeleteFunc()
          // initDraftFunc()
        }
      }

      fetchPost()
    }
    return () => {
      isMounted = false
    }
  }, [addressModalVisible]);

  const handleSubmit = () => {
    onSubmit();
  };

  const modalFooter = {
    // okText: '保存', 
    onOk: handleSubmit,
    onCancel
  };

  return (
    <Modal
      forceRender
      destroyOnClose
      title="操作信息 "
      open={addressModalVisible}
      {...modalFooter}
      width={400}
    >
      {

        logs != null && logs.map((item, index) => {
          return <Row
            justify="space-between"
            align={"middle"}
            key={index}
          >
            <Col span={24}>操作人: {item.oper_user}</Col>
            <Col span={24}>操作时间: {item.oper_time}</Col>
          </Row>
        })
      }

    </Modal>
  );
};

export default LogsModal;
