Skip to content

Commit

Permalink
Merge pull request #1362 from fedspendingtransparency/FDG-9519
Browse files Browse the repository at this point in the history
FDG-9519 DTS Published reports when selected for the month of July it is not displaying all the published reports
  • Loading branch information
nicweidner authored Aug 27, 2024
2 parents 864169a + b1015fb commit 84be6e3
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { FunctionComponent } from 'react';
import DownloadReportTable from '../download-report-table/download-report-table';
import { reportsTip, note, publishDate } from './reports-section.module.scss';
import { reportsTip, note } from './reports-section.module.scss';
import DatasetSectionContainer from '../../dataset-section-container/dataset-section-container';
import { getPublishedDates } from '../../../helpers/dataset-detail/report-helpers';
import ReportDatePicker from '../report-date-picker/report-date-picker';
Expand Down Expand Up @@ -57,13 +57,16 @@ const ReportsSection: FunctionComponent<{ publishedReportsProp: IReports[]; data

const updateReportSelection = (date, isDaily, sortedReports) => {
if (date) {
const day = date.getDate();
const month = date.toLocaleString('default', { month: 'short' });
const year = date.getFullYear();
const selectedDay = date.getDate();
const selectedMonth = date.toLocaleString('default', { month: 'short' });
const selectedYear = date.getFullYear();

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

0 comments on commit 84be6e3

Please sign in to comment.