import React from 'react' import {connect} from 'react-redux' import moment from 'moment' import RelativeTime from 'components/datetime/relative' const RefreshState = function(props) { if (!props.cachedAt || !props.cacheTtl) { return null; } const cachedAt = moment.utc(props.cachedAt); const cacheTtl = moment.utc(props.cacheTtl); if (cacheTtl.isBefore(moment.utc())) { // This means cache is currently being rebuilt return (
  • Routes cache was built and is currently being refreshed.
  • ); } return (
  • Routes cache was built and will be refreshed .
  • ); } class ResultsBox extends React.Component { render() { if (this.props.query == '') { return null; } if (this.props.isLoading) { return null; } const queryDuration = this.props.queryDuration.toFixed(2); const cachedAt = this.props.cachedAt; const cacheTtl = this.props.cacheTtl; return (
    ); } } export default connect( (state) => { return { isLoading: state.lookup.isLoading, totalImported: state.lookup.totalRoutesImported, totalFiltered: state.lookup.totalRoutesFiltered, cachedAt: state.lookup.cachedAt, cacheTtl: state.lookup.cacheTtl, queryDuration: state.lookup.queryDurationMs } } )(ResultsBox)