import React, { useCallback, useEffect, useState } from 'react'
import styles from './index.module.scss'
import { Button, Modal } from 'antd'
import { Z3_APIgetProGetUser } from '@/store/action/Z3flowSet'

type Props = {
  sId: number
  closeFu: () => void
}

function Z3lookPro({ sId, closeFu }: Props) {
  const [list, setList] = useState<string[]>([])

  const getInfoFu = useCallback(async () => {
    const res = await Z3_APIgetProGetUser(sId)
    if (res.code === 0) {
      setList((res.data || []).map((v: any) => v.realName))
    }
  }, [sId])

  useEffect(() => {
    getInfoFu()
  }, [getInfoFu])

  return (
    <Modal
      wrapClassName={styles.Z3lookPro}
      destroyOnClose
      open={true}
      title='查看办理人'
      footer={
        [] // 设置footer为空，去掉 取消 确定默认按钮
      }
    >
      <div className='Z3lMain'>
        {list.length ? list.map(v => <span key={v}>{v}</span>) : <span>暂无</span>}
      </div>

      <div className='Z3lBtn'>
        <Button onClick={closeFu}>关闭</Button>
      </div>
    </Modal>
  )
}

const MemoZ3lookPro = React.memo(Z3lookPro)

export default MemoZ3lookPro
