Skip to content

Commit

Permalink
Fix projects page (#219)
Browse files Browse the repository at this point in the history
* fix #218

* fix tests
  • Loading branch information
pieterjanin authored May 18, 2024
1 parent 7a4642d commit 1ff5dbc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions frontend/src/views/ProjectsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ import { computed, ref } from "vue";
import type Project from "@/models/Project";
const { data: projects, isLoading, isError } = useProjectsQuery();
const noProjectsFound = computed(() => projects.value?.length === 0);
const allProjects = computed(() =>
isLoading.value ? [] : [...projects.value!.as_student, ...projects.value!.as_instructor]
);
const noProjectsFound = computed(() => allProjects.value.length === 0);
const activeButton = ref("notFinished");
const filteredProjects = computed(() => {
if (!projects.value) return [];
const now = new Date();
const sortedProjects = projects.value
const sortedProjects = allProjects.value
.slice()
.sort(
(a: Project, b: Project) =>
Expand Down
7 changes: 4 additions & 3 deletions frontend/tests/views/ProjectsView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import {expect, describe, it, vi} from "vitest";
import ProjectsView from "@/views/ProjectsView.vue"
import {ref} from "vue";

const mockProjects = [
{id: 1}
]
const mockProjects = {
as_student: [{id: 1}],
as_instructor: [{id: 2}],
};

const testProjectsQuery = {
data: ref(mockProjects),
Expand Down

0 comments on commit 1ff5dbc

Please sign in to comment.