diff --git a/frontend/src/queries/Project.ts b/frontend/src/queries/Project.ts index 921056cf..c4543867 100644 --- a/frontend/src/queries/Project.ts +++ b/frontend/src/queries/Project.ts @@ -9,9 +9,9 @@ import { getProject, createProject, getProjects, - uploadProjectFiles, + uploadTestFiles, updateProject, - fetchProjectFiles, + fetchTestFiles, } from "@/services/project"; function PROJECT_QUERY_KEY(projectId: number): (string | number)[] { @@ -27,7 +27,7 @@ function PROJECTS_QUERY_KEY(): string[] { */ function TEST_FILES_QUERY_KEY(projectId: number): (string | number)[] { - return ["projectFiles", projectId]; + return ["testFiles", projectId]; } // Hook for fetching project details @@ -51,18 +51,6 @@ export function useProjectsQuery(): UseQueryReturnType { }); } -// Hook for creating a new submission -export function useCreateSubmissionMutation( - groupId: Ref -): UseMutationReturnType { - return useMutation({ - mutationFn: (formData) => createSubmission(groupId.value!, formData), - onError: (error) => { - console.error("Submission creation failed", error); - alert("Could not create submission. Please try again."); - }, - }); -} /** * Mutation composable for creating a project */ @@ -112,17 +100,17 @@ export function useUpdateProjectMutation(): UseMutationReturnType< }); } -export function useProjectFilesQuery( +export function useTestFilesQuery( projectId: MaybeRefOrGetter ): UseQueryReturnType { return useQuery({ queryKey: TEST_FILES_QUERY_KEY(toValue(projectId)!), - queryFn: () => fetchProjectFiles(toValue(projectId)!), + queryFn: () => fetchTestFiles(toValue(projectId)!), enabled: () => !!toValue(projectId), // Only fetch when a projectId is provided }); } // Hook for uploading files to a project -export function useUploadProjectFilesMutation(): UseMutationReturnType< +export function useUploadTestFilesMutation(): UseMutationReturnType< void, // Type of data returned on success Error, // Type of error { projectId: number; formData: FormData }, @@ -130,7 +118,7 @@ export function useUploadProjectFilesMutation(): UseMutationReturnType< > { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ projectId, formData }) => uploadProjectFiles(projectId, formData), + mutationFn: ({ projectId, formData }) => uploadTestFiles(projectId, formData), onSuccess: (_, { projectId }) => { queryClient.invalidateQueries({ queryKey: PROJECT_QUERY_KEY(projectId) }); console.log("Files uploaded successfully"); diff --git a/frontend/src/services/project.ts b/frontend/src/services/project.ts index fbfdfdf1..310ce65f 100644 --- a/frontend/src/services/project.ts +++ b/frontend/src/services/project.ts @@ -62,7 +62,7 @@ export async function updateProject( } // Function to upload test files to a specific project -export async function uploadProjectFiles(projectId: number, formData: FormData): Promise { +export async function uploadTestFiles(projectId: number, formData: FormData): Promise { await authorized_fetch( `/api/projects/${projectId}/test_files`, { @@ -73,7 +73,7 @@ export async function uploadProjectFiles(projectId: number, formData: FormData): ); } -export async function fetchProjectFiles(projectId: number): Promise { +export async function fetchTestFiles(projectId: number): Promise { return authorized_fetch(`/api/projects/${projectId}/test_files`, { method: "GET", }); diff --git a/frontend/src/views/CreateProjectView.vue b/frontend/src/views/CreateProjectView.vue index 8fff8fa9..648e6fab 100644 --- a/frontend/src/views/CreateProjectView.vue +++ b/frontend/src/views/CreateProjectView.vue @@ -141,10 +141,10 @@ import { useCreateGroupsMutation, useAddToGroupMutation } from "@/queries/Group" import { ref, reactive, computed } from "vue"; import { useCreateProjectMutation, - useProjectFilesQuery, + useTestFilesQuery, useProjectQuery, useUpdateProjectMutation, - useUploadProjectFilesMutation, + useUploadTestFilesMutation, } from "@/queries/Project"; import type User from "@/models/User"; import DisplayTestFiles from "@/components/project/DisplayTestFiles.vue"; @@ -177,7 +177,7 @@ const isEditMode = computed(() => projectId.value !== undefined); const createProjectMutation = useCreateProjectMutation(); const createGroupsMutation = useCreateGroupsMutation(); const joinGroupMutation = useAddToGroupMutation(); -const uploadProjectFilesMutation = useUploadProjectFilesMutation(); +const uploadProjectFilesMutation = useUploadTestFilesMutation(); const updateProjectMutation = useUpdateProjectMutation(); // Query to fetch and handle files associated with a project @@ -185,7 +185,7 @@ const { data: filesData, isError: filesError, isLoading: filesLoading, -} = useProjectFilesQuery(projectId.value); +} = useTestFilesQuery(projectId.value); // Query to fetch and handle project details const {