Skip to content

Commit 84be6e3

Browse files
authored
Merge pull request #1362 from fedspendingtransparency/FDG-9519
FDG-9519 DTS Published reports when selected for the month of July it is not displaying all the published reports
2 parents 864169a + b1015fb commit 84be6e3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/components/published-reports/reports-section/reports-section.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState } from 'react';
22
import { FunctionComponent } from 'react';
33
import DownloadReportTable from '../download-report-table/download-report-table';
4-
import { reportsTip, note, publishDate } from './reports-section.module.scss';
4+
import { reportsTip, note } from './reports-section.module.scss';
55
import DatasetSectionContainer from '../../dataset-section-container/dataset-section-container';
66
import { getPublishedDates } from '../../../helpers/dataset-detail/report-helpers';
77
import ReportDatePicker from '../report-date-picker/report-date-picker';
@@ -57,13 +57,16 @@ const ReportsSection: FunctionComponent<{ publishedReportsProp: IReports[]; data
5757

5858
const updateReportSelection = (date, isDaily, sortedReports) => {
5959
if (date) {
60-
const day = date.getDate();
61-
const month = date.toLocaleString('default', { month: 'short' });
62-
const year = date.getFullYear();
60+
const selectedDay = date.getDate();
61+
const selectedMonth = date.toLocaleString('default', { month: 'short' });
62+
const selectedYear = date.getFullYear();
6363

6464
const filteredReports = sortedReports.filter((report: IReports) => {
65-
const dateStr = report.report_date.toString();
66-
return dateStr.includes(month) && dateStr.includes(year) && ((isDaily && dateStr.includes(day)) || !isDaily);
65+
const reportDate = new Date(report.report_date);
66+
const reportDay = reportDate.getDate();
67+
const reportMonth = reportDate.toLocaleString('default', { month: 'short' });
68+
const reportYear = reportDate.getFullYear();
69+
return selectedMonth === reportMonth && selectedYear === reportYear && ((isDaily && selectedDay === reportDay) || !isDaily);
6770
});
6871
filteredReports.sort((a, b) => a.report_group_sort_order_nbr - b.report_group_sort_order_nbr);
6972
if (filteredReports.length > 0) {

0 commit comments

Comments
 (0)