Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save imsickofmaps/7231335fb39f031323c5ad621d1dcd4e to your computer and use it in GitHub Desktop.
Save imsickofmaps/7231335fb39f031323c5ad621d1dcd4e to your computer and use it in GitHub Desktop.
diff --git a/web_internal/src/components_v2/impact-report-investments-section/index.js b/web_internal/src/components_v2/impact-report-investments-section/index.js
index fb84181..c9c23a4 100644
--- a/web_internal/src/components_v2/impact-report-investments-section/index.js
+++ b/web_internal/src/components_v2/impact-report-investments-section/index.js
@@ -14,7 +14,6 @@ import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'
-import moment from 'moment'
import {
ReportSection
@@ -35,7 +34,7 @@ class ImpactReportInvestmentsSection extends React.Component {
metricsDate: PropTypes.string.isRequired
}
- getLatestMetricsAsObject = (metricsArray, metricsDate) => (
+ getLatestMetricsAsObject = (metricsArray) => (
metricsArray.map((metric) => (
JSON.parse(metric.node.result)
))
@@ -55,8 +54,7 @@ class ImpactReportInvestmentsSection extends React.Component {
return <div>We&rsquo;re experiencing a problem loading the required investment report data</div>
}
- let metricsDate = this.props.metricsDate
- let metrics = this.getLatestMetricsAsObject(this.props.data.metrics.edges, metricsDate)
+ let metrics = this.getLatestMetricsAsObject(this.props.data.metrics.edges)
return (
<ReportSection
@@ -90,8 +88,8 @@ const withData =
options: (ownProps) => ({
variables: {
employer: decodeBase64UUID(ownProps.employer),
- from: moment(ownProps.metricsDate).startOf('day').toISOString(),
- to: moment(ownProps.metricsDate).endOf('day').toISOString()
+ from: ownProps.metricsDate.startOf('day').toISOString(),
+ to: ownProps.metricsDate.endOf('day').toISOString()
}
})
})
diff --git a/web_internal/src/components_v2/impact-report-loans-section/index.js b/web_internal/src/components_v2/impact-report-loans-section/index.js
index 17fa3a3..cd3d4d9 100644
--- a/web_internal/src/components_v2/impact-report-loans-section/index.js
+++ b/web_internal/src/components_v2/impact-report-loans-section/index.js
@@ -14,7 +14,6 @@ import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'
-import moment from 'moment'
import {
ReportSectionWithTable
@@ -167,8 +166,8 @@ const withData =
options: (ownProps) => ({
variables: {
employer: decodeBase64UUID(ownProps.employer),
- from: moment(ownProps.metricsDate).startOf('day').toISOString(),
- to: moment(ownProps.metricsDate).endOf('day').toISOString()
+ from: ownProps.metricsDate.startOf('day').toISOString(),
+ to: ownProps.metricsDate.endOf('day').toISOString()
}
})
})
diff --git a/web_internal/src/containers/ImpactReport.js b/web_internal/src/containers/ImpactReport.js
index 7d19449..c206456 100644
--- a/web_internal/src/containers/ImpactReport.js
+++ b/web_internal/src/containers/ImpactReport.js
@@ -55,20 +55,6 @@ class ImpactReport extends React.Component {
}
}
- getLatestMetricsAsObject = (metricsArray, latestMetricsDate) => (
- metricsArray.filter((metric) => ( // filter on latest date
- moment(metric.node.createdAt).isSame(moment(latestMetricsDate), 'day')
- ))
- .map((metric) => (
- JSON.parse(metric.node.result)
- ))
- .reduce((obj, metricObj) => { // convert array to object
- let key = Object.keys(metricObj)[0]
- obj[key] = metricObj[key]
- return obj
- }, {})
- )
-
render () {
if (this.props.data.loading) {
return <Spinner type="brand" size="large" />
@@ -82,18 +68,20 @@ class ImpactReport extends React.Component {
let queryParams = qs.parse(this.props.location.search)
// Allows for overriding the date to show alternative dates for internal review before updating envvar
- let latestMetricsDate =
+ let metricsDate =
queryParams.date
? queryParams.date
: process.env.REACT_APP_IMPACT_REPORT_DATE
+ let latestMetricsDate = moment.utc(metricsDate)
+
return (
<div className="stage-main slds-size_1-of-1">
<Report
header={
<ReportHeader
heading="Impact report"
- date={moment(latestMetricsDate).format("MMMM YYYY")}
+ date={latestMetricsDate.format("MMMM YYYY")}
subheading1={<ImpactReportEmployerSwitcher
value={this.state.employer}
onChange={(e) => this.props.history.push({
@@ -105,7 +93,7 @@ class ImpactReport extends React.Component {
? employer.employergroup.friendlyName
: ''
}
- valuesAtDate={moment(latestMetricsDate).format("DD MMMM YYYY")} // TODO: use correct date
+ valuesAtDate={latestMetricsDate.format("DD MMMM YYYY")} // TODO: use correct date
/>
}
content={[
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment