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

export default function Room(props) {
  const { roomName, price, apartmentName, status, heat, realHeat } = props.dataset || {}
  let personNum = props.hotType === 1 ? (heat || 0) : (realHeat || 0)
  if (props.hotType === 3) {
    personNum = 0 + heat + realHeat
  }

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

  const wanY = Number(price - 0).toFixed(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}人)`}</div>
        <div className={Style.info}>{`${wanY} 万`}</div>
        <div className={Style.info}>{apartmentName}</div>
      </div>
    </HotBlock>
  )
}
