import React, { useCallback, useState } from 'react'
import styles from './index.module.scss'
import TopCom from '@/components/TopCom'

import topImg from '@/assets/img/team/top.png'
import history from '@/utils/history'
import ZinfoPop from '@/components/ZinfoPop'
import { A4_APIcheck } from '@/store/action/all'

function A7team() {
  const toFromFu = useCallback(async (can: string) => {
    const res = await A4_APIcheck()

    if (res.code === 0) {
      if (res.data) {
        setTitPop({
          txt1: '您已完成认证',
          txt2: '无需重复申请'
        })
      } else history.push(`/proof/${can}`)
    }
  }, [])

  // 打开提示弹窗
  const [titPop, setTitPop] = useState({
    txt1: '',
    txt2: ''
  })

  return (
    <div className={styles.A7team}>
      <TopCom txt='选择团体' />
      <div className='A7main'>
        <img src={topImg} alt='' />
        <div className='A7tit'>请选择认证单位</div>

        <div className='A7dan1' onClick={() => toFromFu('live')}>
          <div>横琴粤澳深度合作区民生事务局</div>
        </div>
        <div className='A7dan1' onClick={() => toFromFu('neighbour')}>
          <div className='A7dan1_1'>澳门街坊会联合总会广东办事处</div>
        </div>
      </div>
      {/* 提示的弹窗 */}
      {titPop.txt1 ? (
        <ZinfoPop
          txt1={titPop.txt1}
          txt2={titPop.txt2}
          type='info'
          callFu={() => setTitPop({ txt1: '', txt2: '' })}
        />
      ) : null}
    </div>
  )
}

const MemoA7team = React.memo(A7team)

export default MemoA7team
