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

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

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

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

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

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

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

const MemoD2lookPro = React.memo(D2lookPro)

export default MemoD2lookPro
