refactor(reporting): clarify date parsing in allocation controller and frontend

- Updated comments to specify date parsing format as 'YYYY-MM-DD'.
- Modified date range handling in the frontend to format dates using date-fns for consistency.
This commit is contained in:
chamiakJ
2025-05-20 09:23:22 +05:30
parent 3b59a8560b
commit 14d8f43001
2 changed files with 9 additions and 2 deletions

View File

@@ -412,7 +412,7 @@ export default class ReportingAllocationController extends ReportingControllerBa
let startDate: moment.Moment;
let endDate: moment.Moment;
if (date_range && date_range.length === 2) {
// Parse dates without timezone
// Parse simple YYYY-MM-DD dates
startDate = moment(date_range[0]).startOf('day');
endDate = moment(date_range[1]).endOf('day');

View File

@@ -16,6 +16,7 @@ import { reportingTimesheetApiService } from '@/api/reporting/reporting.timeshee
import { IRPTTimeMember } from '@/types/reporting/reporting.types';
import logger from '@/utils/errorLogger';
import { useAppDispatch } from '@/hooks/useAppDispatch';
import { format } from 'date-fns';
ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ChartDataLabels);
@@ -141,12 +142,18 @@ const MembersTimeSheet = forwardRef<MembersTimeSheetRef>((_, ref) => {
const selectedProjects = filterProjects.filter(project => project.selected);
const selectedCategories = categories.filter(category => category.selected);
// Format dates using date-fns
const formattedDateRange = dateRange ? [
format(new Date(dateRange[0]), 'yyyy-MM-dd'),
format(new Date(dateRange[1]), 'yyyy-MM-dd')
] : undefined;
const body = {
teams: selectedTeams.map(t => t.id),
projects: selectedProjects.map(project => project.id),
categories: selectedCategories.map(category => category.id),
duration,
date_range: dateRange,
date_range: formattedDateRange,
billable,
};