Merge pull request 'fix: refs #7323 update getAbsences to handle multiple years for absence data' (!1181) from 7323-hotfix-getNextYearAbsences into master
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1181
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Jorge Penadés 2025-01-07 11:05:20 +00:00
commit 0703a8c105
1 changed files with 22 additions and 5 deletions

View File

@ -208,13 +208,30 @@ const getWorkedHours = async (from, to) => {
};
const getAbsences = async () => {
const params = {
workerFk: route.params.id,
businessFk: null,
year: startOfWeek.value.getFullYear(),
const startYear = startOfWeek.value.getFullYear();
const endYear = endOfWeek.value.getFullYear();
const defaultParams = { workerFk: route.params.id, businessFk: null };
const startData = (
await axios.get('Calendars/absences', {
params: { ...defaultParams, year: startYear },
})
).data;
let endData;
if (startYear !== endYear) {
endData = (
await axios.get('Calendars/absences', {
params: { ...defaultParams, year: endYear },
})
).data;
}
const data = {
holidays: [...(startData?.holidays || []), ...(endData?.holidays || [])],
absences: [...(startData?.absences || []), ...(endData?.absences || [])],
};
const { data } = await axios.get('Calendars/absences', { params });
if (data) addEvents(data);
};