Skip to content

Commit 6ee4a2b

Browse files
author
vidigi
committed
fix: filter assignments to include only those in the current school year
1 parent 3d4ceae commit 6ee4a2b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

apps/frontend/src/routes/opgaver/+page.svelte

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@
3232
3333
onMount(async () => {
3434
await assignmentStore.fetch();
35+
if ($assignmentsPageSettingsStore) {
36+
// filter to only include assignments that are in the current school year
37+
// school year is not the same as calendar year
38+
// each school year starts in august and ends in august the following year
39+
const now = DateTime.now();
40+
const currentYear = now.month >= 8 ? now.year : now.year - 1;
41+
$assignmentStore ??= [];
42+
$assignmentStore = $assignmentStore.filter((opgave) => {
43+
const frist = DateTime.fromFormat(opgave.frist, 'd/M-yyyy HH:mm');
44+
const fristYear = frist.month >= 8 ? frist.year : frist.year - 1;
45+
return fristYear === currentYear;
46+
});
47+
}
3548
originalOpgaver = $assignmentStore || [];
3649
search();
3750
});
@@ -47,19 +60,6 @@
4760
return opgave.status === 'Afleveret' || opgave.status === 'Afsluttet';
4861
}
4962
});
50-
51-
if ($assignmentsPageSettingsStore) {
52-
// filter to only include assignments that are in the current school year
53-
// school year is not the same as calendar year
54-
// each school year starts in august and ends in august the following year
55-
const now = DateTime.now();
56-
const currentYear = now.month >= 8 ? now.year : now.year - 1;
57-
filteredOpgaver = filteredOpgaver.filter((opgave) => {
58-
const frist = DateTime.fromFormat(opgave.frist, 'd/M-yyyy HH:mm');
59-
const fristYear = frist.month >= 8 ? frist.year : frist.year - 1;
60-
return fristYear === currentYear;
61-
});
62-
}
6363
}
6464
6565
function search() {

0 commit comments

Comments
 (0)