Skip to content

Commit

Permalink
A couple of fixes for the data dashboard. (#2197)
Browse files Browse the repository at this point in the history
1. Make sure we use the timezone UTC when formatting the labels for the line chart, so it matches the data received from the backend.

2. Fix the links to articles: for now, it should be fact-checks instead of explainers.

Reference: CV2-4111.
  • Loading branch information
caiosba authored Nov 12, 2024
1 parent a9ccd8b commit 79525a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{
"id": "listTopArticlesSent.title",
"description": "Title for the top articles sent list widget",
"defaultMessage": "Top Articles Sent"
"defaultMessage": "Top Fact-Checks Sent"
}
]
9 changes: 7 additions & 2 deletions src/app/components/cds/charts/TimelineWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ const TimelineWidget = ({
tooltipFormatter,
}) => {
const tickFormatter = intl ?
value => intl.formatDate(value, { month: 'short', day: 'numeric' }) :
value => intl.formatDate(value, { month: 'short', day: 'numeric', timeZone: 'UTC' }) :
value => value;

const labelFormatter = intl ?
value => `${intl.formatDate(value, { month: 'long', day: 'numeric', year: 'numeric' })}:` :
value => `${intl.formatDate(value, {
month: 'long',
day: 'numeric',
year: 'numeric',
timeZone: 'UTC',
})}:` :
value => value;

return (
Expand Down
5 changes: 3 additions & 2 deletions src/app/components/dashboard/ListTopArticlesSent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { FormattedMessage } from 'react-intl';
import { createFragmentContainer, graphql } from 'react-relay/compat';
import ListWidget from '../cds/charts/ListWidget';

// FIXME: For now, it assumes the backend is returning only fact-checks - must update this component once the backend returns explainers too
const ListTopArticlesSent = ({ statistics }) => {
const teamSlug = window.location.pathname.split('/')[1];

const dataArray = statistics.top_articles_sent.map(a => ({
itemText: a.label,
itemValue: a.value,
itemLink: `/${teamSlug}/articles/explainers?explainerId=${a.id}`,
itemLink: `/${teamSlug}/articles/fact-checks?factCheckId=${a.id}`,
}));

return (
Expand All @@ -25,7 +26,7 @@ const ListTopArticlesSent = ({ statistics }) => {
items={dataArray}
title={
<FormattedMessage
defaultMessage="Top Articles Sent"
defaultMessage="Top Fact-Checks Sent"
description="Title for the top articles sent list widget"
id="listTopArticlesSent.title"
/>
Expand Down

0 comments on commit 79525a5

Please sign in to comment.