forked from verdnatura/salix-front
refactor: refs #7828 wip
This commit is contained in:
parent
d072a11c1b
commit
6b79d70551
|
@ -271,44 +271,38 @@ const fetchWorkerTimeControlMails = async (filter) => {
|
|||
|
||||
const fetchWeekData = async () => {
|
||||
try {
|
||||
const filter = {
|
||||
where: {
|
||||
workerFk: route.params.id,
|
||||
year: selectedDate.value ? selectedDate.value?.getFullYear() : null,
|
||||
week: selectedWeekNumber.value,
|
||||
},
|
||||
};
|
||||
|
||||
const data = await fetchWorkerTimeControlMails(filter);
|
||||
if (!data.length) {
|
||||
state.value = null;
|
||||
} else {
|
||||
const data = (
|
||||
await axios.get(`WorkerTimeControlMails/${route.params.id}/getWeeklyMail`, {
|
||||
params: {
|
||||
workerFk: route.params.id,
|
||||
year: selectedDate.value.getFullYear(),
|
||||
week: selectedWeekNumber.value,
|
||||
},
|
||||
})
|
||||
).data;
|
||||
if (!data.length) state.value = null;
|
||||
else {
|
||||
const [mail] = data;
|
||||
state.value = mail.state;
|
||||
reason.value = mail.reason;
|
||||
}
|
||||
|
||||
await canBeResend();
|
||||
canResend.value = !!(
|
||||
await axios.get('WorkerTimeControlMails/count', {
|
||||
filter: {
|
||||
where: {
|
||||
year: selectedDate.value.getFullYear(),
|
||||
week: selectedWeekNumber.value,
|
||||
limit: 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
).data.count;
|
||||
} catch (err) {
|
||||
console.error('Error fetching week data');
|
||||
}
|
||||
};
|
||||
|
||||
const canBeResend = async () => {
|
||||
canResend.value = false;
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
year: selectedDate.value.getFullYear(),
|
||||
week: selectedWeekNumber.value,
|
||||
},
|
||||
limit: 1,
|
||||
};
|
||||
|
||||
const data = await fetchWorkerTimeControlMails(filter);
|
||||
if (data.length) canResend.value = true;
|
||||
};
|
||||
|
||||
const setHours = (data) => {
|
||||
for (const weekDay of weekDays.value) {
|
||||
if (data) {
|
||||
|
|
Loading…
Reference in New Issue