import React from 'react';
import { AlarmCardFooter, AlarmCardEffective ,AlarmCardVecjile} from '../utils'
import './index.less';

import CaptureCard from '../AlarmCapture'


class ForeignCard extends React.Component {
  handleJumPage = (data, e) => {
    this.props.handlePageJump && this.props.handlePageJump(data, e);
  };

  getActionNAme = alarmType => {
    switch (alarmType) {
      case 5:
        return 'vehicleHandle';
      case 6:
        return 'vehicleTempHandle';
      case 'vehicleTags' :
        return 'vehicleTagsHandle'; // 车辆标签布控
      default:
        return '';
    }
  };

  render() {
    const { data = {}, isActual, handleChangeYN, libType, className, height ,defence=0,children } = this.props;
    let { isEffective, picPath, captureTime, isHandle, plateNo, plateNum, deviceName,  address, taskName } = data;
    return (
      <CaptureCard
        className={`vehicle-card ${className}`}
        style={{ height: `${height}px!important` }}
        onClick={e => this.handleJumPage(data, e)}
        plateNo={plateNo || plateNum}
        address={defence === 1 ?(address ? address :"暂无"):address }
        hoverScale={false}
        imgUrl={picPath}
        relativeIcon={''}
        captureTime={captureTime}
        deviceName={deviceName}
        taskName={taskName}
        alarmButton={children}
      >
        {isActual && +isHandle === 0 ? (
          <AlarmCardFooter actionName={this.getActionNAme(libType)} sourceData={data} handleChangeYN={handleChangeYN} defence={defence}/>
        ) :(
          <div className="card-footer" style={{ height: '0px' }} />
        )}

        {+isHandle === 1 && defence!==1 && <AlarmCardEffective isEffective={isEffective} />}
        {+isHandle === 1 && defence===1 &&<AlarmCardVecjile isEffective={isEffective} />}
      </CaptureCard>
    );
  }
}

export default ForeignCard;
