import React from 'react'
import classNames from 'classnames'
import HotBlock from "../HotBlock"
import Style from './style.less'

export default function Room(props) {
  console.log(props.dataset, 'propsDataSet')
  const { roomName, price, apartmentName, status, raiseHeat, raiseRealHeat } = props.dataset || {}
  let personNum = props.hotType === 1 ? (raiseHeat || 0) : (raiseRealHeat || 0)
  if (props.hotType === 2){
    personNum = isNaN(raiseRealHeat) ? 0 : raiseRealHeat
  }  
  if (props.hotType === 3) {
    personNum = !isNaN(raiseHeat) && !isNaN(raiseRealHeat) ?  raiseHeat+raiseRealHeat : isNaN(raiseHeat) && !isNaN(raiseRealHeat) ? raiseRealHeat : !isNaN(raiseHeat) && isNaN(raiseRealHeat) ? raiseHeat : 0
  }

  const handleClick = () => {
    if (props.onClick) {
      props.onClick(props.dataset || {})
    }
  }

  const wanY = Number(price - 0)

  return (
    <HotBlock number={personNum}>
      <div className={classNames(Style.room, { [`${Style.offline}`]: status !== 1 })} onClick={handleClick}>
        <div className={Style.warn}>{roomName}</div>
        <div className={Style.warn}>{`(${personNum === null ? 0 : personNum}人)`}</div>
        <div className={Style.info}>{`${wanY} 万`}</div>
        <div className={Style.info}>{apartmentName}</div>
      </div>
    </HotBlock>
  )
}
