import React from 'react'; import {browserHistory} from 'react-router'; import 'whatwg-fetch'; import './SensorList.scss'; const options = { month: 'numeric', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric', hour12: true }; export default class SensorList extends React.Component { constructor(){ super(); this.openLink = this.openLink.bind(this); } openLink(location){ browserHistory.push(`/sensor/${location}`); this.props.toggleOff(); } insertSensorData = (sensor, index) => { const date = new Date(sensor.updated); return (
{this.openLink(sensor.location)}}>

{sensor.temperature}°f

{sensor.location}

Updated: {date.toLocaleString('en-us', options)} {Date.now() - date < 420000 ? Connected : Disconnected }
); } render() { const list = this.props.list; return (

Sensors

{list.map(this.insertSensorData)}
) } }