Simplify date range and department selection logic in DepartmentDailyReport.
This commit is contained in:
+3
-7
@@ -49,7 +49,6 @@ const accessibleDepartments = (departments) => {
|
||||
*/
|
||||
const selectAllDepartments = (value) => {
|
||||
if (!props.departmentSpecific) {
|
||||
console.warn('Selecting all accessible departments for non-department-specific daily report');
|
||||
// Select all accessible departments
|
||||
selectDepartments(accessibleDepartments(departments));
|
||||
}
|
||||
@@ -59,15 +58,12 @@ onMounted(() => {
|
||||
selectAllDepartments(props.departmentSpecific);
|
||||
// Check if query parameters date-from and date-to are set
|
||||
const query = router.currentRoute.value.query;
|
||||
if (query.dateFrom) {
|
||||
const dateFrom = String(query.dateFrom);
|
||||
}
|
||||
if (query.dateTo) {
|
||||
const dateTo = String(query.dateTo);
|
||||
}
|
||||
if (query.dateFrom && query.dateTo) {
|
||||
console.warn('Selecting date range from query parameters:', query.dateFrom, query.dateTo);
|
||||
selectDate(String(query.dateFrom), String(query.dateTo));
|
||||
} else {
|
||||
// Pick "today" as default
|
||||
selectDate(new Date().toISOString().split('T')[0], new Date().toISOString().split('T')[0]);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user