import React, { useEffect, useState } from 'react'
import { Row, Col, Statistic, Icon, Spin } from 'antd'
import { apis, fetch } from '@/utils/request'

const getHouseVerified = fetch(apis.dashboard.houseVerified)

export default props => {
  const [loading, setLoading] = useState({})
  const [data, setData] = useState({})

  useEffect(() => {
    if (props.communityId) {
      setLoading(true)
      getHouseVerified({params: {communityId: props.communityId}}).then(res => {
        setData(res)
        setLoading(false)
      }).catch(e => console.error(e) || setLoading(false))
    }
  }, [props.communityId])


  return (
    <Spin spinning={loading}>
      <Row gutter={16}>
        <Col span={4}>
          {/* <Statistic title={<div><Icon type="bell" style={{fontSize: '1.2em'}} /> 工单 </div>} value={112893} /> */}
        </Col>
        <Col span={10}>
          <Statistic title={<div><Icon type="home" style={{fontSize: '1.2em'}} /> 已认证(户) </div>} value={data.valid} />
        </Col>
        <Col span={10}>
          <Statistic title={<div><Icon type="home" style={{fontSize: '1.2em'}} /> 未认证(户) </div>} value={data.total - data.valid} />
        </Col>
      </Row>
    </Spin>
  )
}
