import React from 'react'; import {connect} from 'react-redux'; import {getTimeObj} from '../utils'; import Character from './Character'; import {TOGGLE_TIME_MODE} from '../actionTypes'; class Time extends React.Component { constructor(props) { super(props); this.toggleTimeMode = this.toggleTimeMode.bind(this); } toggleTimeMode() { this.props.dispatch({type: TOGGLE_TIME_MODE}); } render() { const seconds = this.props.timeMode === 'ELAPSED' ? this.props.timeElapsed : this.props.length - this.props.timeElapsed; const timeObj = getTimeObj(seconds); return
{this.props.timeMode === 'REMAINING' ? '-' : ''} {timeObj.minutesFirstDigit} {timeObj.minutesSecondDigit} {timeObj.secondsFirstDigit} {timeObj.secondsSecondDigit}
; } } export default connect((state) => state.media)(Time);