Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix projects page #219

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading