diff --git a/frontend/src/pages/VacationPlanner.tsx b/frontend/src/pages/VacationPlanner.tsx index c47fa29c..1ec176c6 100644 --- a/frontend/src/pages/VacationPlanner.tsx +++ b/frontend/src/pages/VacationPlanner.tsx @@ -46,11 +46,27 @@ export const VacationPlanner = () => { const [redmineGroups, setRedmineGroups] = useState<[]>([]); const [isLoading, setIsLoading] = useState(false); + const [tableData, setTableData] = useState< + { startDate: Date; endDate: Date; userName: string; entryIds: number[] }[] + >([]); + const vacationFrom: Date = getVacationFrom(); + const vacationTo: Date = getVacationTo(); + + function getVacationFrom() { + let today = new Date(); + + return new Date(today.setMonth(today.getMonth() - 1)); + } + function getVacationTo() { + let today = new Date(); + + return new Date(today.setMonth(today.getMonth() + 12)); + } const timelineOptions = { hAxis: { - minValue: new Date(2021, 11, 20), - maxValue: new Date(2021, 12, 30), + minValue: vacationFrom, + maxValue: vacationTo, }, avoidOverlappingGridLines: false, colors: ["#BFD6D8"], @@ -288,8 +304,8 @@ export const VacationPlanner = () => { for await (let user of sliced_users) { let entries = await getVacationTimeEntries( - new Date(2021, 10, 20), - new Date(2022, 2, 30), + vacationFrom, + vacationTo, user.toString() ); const vacationRanges: { @@ -325,6 +341,19 @@ export const VacationPlanner = () => { setVacationRows(vacationRows); }; + + const fetchTimeEntriesForUser = async () => { + let entries = await getVacationTimeEntries( + vacationFrom, + vacationTo, + "me" + ); + + const data = getVacationRanges(entries); + setTableData(data); + }; + + fetchTimeEntriesForUser(); fetchTimeEntriesFromGroups(); }, [selectedGroup]); @@ -523,11 +552,11 @@ export const VacationPlanner = () => {
{formatDate(element.startDate, dateFormat)} | +{formatDate(element.endDate, dateFormat)} | ++ + | ++ + | +