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
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:
commit
0703a8c105
|
@ -208,13 +208,30 @@ const getWorkedHours = async (from, to) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAbsences = async () => {
|
const getAbsences = async () => {
|
||||||
const params = {
|
const startYear = startOfWeek.value.getFullYear();
|
||||||
workerFk: route.params.id,
|
const endYear = endOfWeek.value.getFullYear();
|
||||||
businessFk: null,
|
const defaultParams = { workerFk: route.params.id, businessFk: null };
|
||||||
year: startOfWeek.value.getFullYear(),
|
|
||||||
|
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);
|
if (data) addEvents(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue