#8370: Change year param rely on month #1326

Merged
jon merged 4 commits from 8370-WorkerTimeControl into dev 2025-03-04 14:00:40 +00:00
1 changed files with 19 additions and 1 deletions
Showing only changes of commit ce5c21f4fa - Show all commits

View File

@ -345,17 +345,35 @@ const getMailStates = async (date) => {
const url = `WorkerTimeControls/${route.params.id}/getMailStates`;
alexm marked this conversation as resolved
Review

https://chatgpt.com/c/67a5bac7-c6cc-8011-be56-bf2ac23df374

const getMailStates = async (date) => {
    const url = `WorkerTimeControls/${route.params.id}/getMailStates`;
    const year = date.getFullYear();
    const month = date.getMonth() + 1;

    const getMonthStates = async (month, year) => {
        return (await axios.get(url, { params: { month, year } })).data;
    };

    const curMonthStates = await getMonthStates(month, year);
    const prevMonthStates = await getMonthStates(month === 1 ? 12 : month - 1, month === 1 ? year - 1 : year);
    const postMonthStates = await getMonthStates(month === 12 ? 1 : month + 1, month === 12 ? year + 1 : year);

    workerTimeControlMails.value = [...curMonthStates, ...prevMonthStates, ...postMonthStates];
};

https://chatgpt.com/c/67a5bac7-c6cc-8011-be56-bf2ac23df374 ``` const getMailStates = async (date) => { const url = `WorkerTimeControls/${route.params.id}/getMailStates`; const year = date.getFullYear(); const month = date.getMonth() + 1; const getMonthStates = async (month, year) => { return (await axios.get(url, { params: { month, year } })).data; }; const curMonthStates = await getMonthStates(month, year); const prevMonthStates = await getMonthStates(month === 1 ? 12 : month - 1, month === 1 ? year - 1 : year); const postMonthStates = await getMonthStates(month === 12 ? 1 : month + 1, month === 12 ? year + 1 : year); workerTimeControlMails.value = [...curMonthStates, ...prevMonthStates, ...postMonthStates]; }; ```
const month = date.getMonth() + 1;
const prevMonth = month == 1 ? 12 : month - 1;
const postMonth = month == 12 ? 1 : month + 1;
const params = {
month,
year: date.getFullYear(),
};
const curMonthStates = (await axios.get(url, { params })).data;
if (prevMonth == 12) {
params.year = params.year - 1;
}
const prevMonthStates = (
await axios.get(url, { params: { ...params, month: prevMonth } })
).data;
workerTimeControlMails.value = curMonthStates.concat(prevMonthStates);
if (postMonth == 1) {
params.year = date.getFullYear() + 1;
}
const postMonthStates = (
await axios.get(url, {
params: { ...params, month: postMonth },
})
).data;
workerTimeControlMails.value = curMonthStates.concat(
prevMonthStates,
postMonthStates
);
};
const showWorkerTimeForm = (propValue, formType) => {