diff --git a/nextjs/src/app/api/courses/[courseName]/settings/route.ts b/nextjs/src/app/api/courses/[courseName]/settings/route.ts deleted file mode 100644 index 4ed7fb9..0000000 --- a/nextjs/src/app/api/courses/[courseName]/settings/route.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { fileStorageService } from "@/services/fileStorage/fileStorageService"; -import { withErrorHandling } from "@/services/withErrorHandling"; - -export const GET = async ( - _request: Request, - { params: { courseName } }: { params: { courseName: string } } -) => - await withErrorHandling(async () => { - if (courseName.includes(".js.map")) { - return Response.json({}); - } - const settings = await fileStorageService.settings.getCourseSettings(courseName); - return Response.json(settings); - }); - -export const PUT = async ( - request: Request, - { params: { courseName } }: { params: { courseName: string } } -) => - await withErrorHandling(async () => { - const settings = await request.json(); - - await fileStorageService.settings.updateCourseSettings(courseName, settings); - - return Response.json({}); - }); diff --git a/nextjs/src/app/api/courses/route.ts b/nextjs/src/app/api/courses/route.ts deleted file mode 100644 index 6c236c3..0000000 --- a/nextjs/src/app/api/courses/route.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { LocalCourse } from "@/models/local/localCourse"; -import { fileStorageService } from "@/services/fileStorage/fileStorageService"; -import { withErrorHandling } from "@/services/withErrorHandling"; - -// replace with get all settings -// export const GET = async () => -// await withErrorHandling(async () => { -// const courses = await fileStorageService.getCourseNames(); -// return Response.json(courses); -// }); - -export const POST = async (request: Request) => - await withErrorHandling(async () => { - const newCourse: LocalCourse = await request.json(); - await fileStorageService.settings.updateCourseSettings( - newCourse.settings.name, - newCourse.settings - ); - return Response.json({}); - }); diff --git a/nextjs/src/app/api/courses/settings/route.ts b/nextjs/src/app/api/courses/settings/route.ts deleted file mode 100644 index 163a614..0000000 --- a/nextjs/src/app/api/courses/settings/route.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { fileStorageService } from "@/services/fileStorage/fileStorageService"; -import { withErrorHandling } from "@/services/withErrorHandling"; - -export const GET = async () => - await withErrorHandling(async () => { - const settings = await fileStorageService.settings.getAllCoursesSettings(); - - return Response.json(settings); - }); diff --git a/nextjs/src/app/api/directories/empty/route.ts b/nextjs/src/app/api/directories/empty/route.ts deleted file mode 100644 index 89c1ace..0000000 --- a/nextjs/src/app/api/directories/empty/route.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { fileStorageService } from "@/services/fileStorage/fileStorageService"; -import { withErrorHandling } from "@/services/withErrorHandling"; - -// export const GET = async () => -// await withErrorHandling(async () => { -// const directories = await fileStorageService.getEmptyDirectories(); -// return Response.json(directories); -// }); - \ No newline at end of file diff --git a/nextjs/src/hooks/localCourse/courseItemHooks.ts b/nextjs/src/hooks/localCourse/courseItemHooks.ts index d7422ad..b9d596f 100644 --- a/nextjs/src/hooks/localCourse/courseItemHooks.ts +++ b/nextjs/src/hooks/localCourse/courseItemHooks.ts @@ -1,9 +1,7 @@ -import { axiosClient } from "@/services/axiosUtils"; import { localCourseKeys } from "./localCourseKeys"; import { CourseItemReturnType, CourseItemType, - typeToFolder, } from "@/models/local/courseItemTypes"; import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; import { @@ -19,7 +17,6 @@ import { getItemFromServer, updateItemOnServer, } from "./courseItemServerActions"; -import { useRouter } from "next/navigation"; export const getAllItemsQueryConfig = ( courseName: string, @@ -28,15 +25,6 @@ export const getAllItemsQueryConfig = ( ) => ({ queryKey: localCourseKeys.allItemsOfType(courseName, moduleName, type), queryFn: async (): Promise[]> => { - // const url = - // "/api/courses/" + - // encodeURIComponent(courseName) + - // "/modules/" + - // encodeURIComponent(moduleName) + - // "/" + - // typeToFolder[type]; - // const response = await axiosClient.get(url); - // return response.data; return await getAllItemsFromServer({ courseName, moduleName, @@ -54,17 +42,6 @@ export const getItemQueryConfig = ( return { queryKey: localCourseKeys.itemOfType(courseName, moduleName, name, type), queryFn: async () => { - // const url = - // "/api/courses/" + - // encodeURIComponent(courseName) + - // "/modules/" + - // encodeURIComponent(moduleName) + - // "/" + - // typeToFolder[type] + - // "/" + - // encodeURIComponent(name); - // const response = await axiosClient.get>(url); - // return response.data; return await getItemFromServer({ moduleName, courseName, @@ -159,33 +136,6 @@ export const useUpdateItemMutation = (type: T) => { previousModuleName, itemName, }); - // const url = - // "/api/courses/" + - // encodeURIComponent(courseName) + - // "/modules/" + - // encodeURIComponent(moduleName) + - // "/" + - // typeToFolder[type] + - // "/" + - // encodeURIComponent(itemName); - // if (type === "Assignment") - // await axiosClient.put(url, { - // assignment: item, - // previousModuleName, - // previousAssignmentName: previousItemName, - // }); - // if (type === "Quiz") - // await axiosClient.put(url, { - // quiz: item, - // previousModuleName, - // previousQuizName: previousItemName, - // }); - // if (type === "Page") - // await axiosClient.put(url, { - // page: item, - // previousModuleName, - // previousPageName: previousItemName, - // }); }, onSuccess: async (_, { moduleName, itemName }) => { await queryClient.invalidateQueries({ @@ -222,16 +172,6 @@ export const useCreateItemMutation = (type: T) => { localCourseKeys.itemOfType(courseName, moduleName, itemName, type), item ); - // const url = - // "/api/courses/" + - // encodeURIComponent(courseName) + - // "/modules/" + - // encodeURIComponent(moduleName) + - // "/" + - // typeToFolder[type] + - // "/" + - // encodeURIComponent(itemName); - // await axiosClient.post(url, item); await createItemOnServer({ courseName, moduleName, @@ -267,16 +207,6 @@ export const useDeleteItemMutation = (type: T) => { moduleName: string; itemName: string; }) => { - // const url = - // "/api/courses/" + - // encodeURIComponent(courseName) + - // "/modules/" + - // encodeURIComponent(moduleName) + - // "/" + - // typeToFolder[type] + - // "/" + - // encodeURIComponent(itemName); - // await axiosClient.delete(url); await deleteItemOnServer({ courseName, itemName, diff --git a/nextjs/src/hooks/localCourse/localCourseModuleHooks.ts b/nextjs/src/hooks/localCourse/localCourseModuleHooks.ts index aaa93a4..b27e085 100644 --- a/nextjs/src/hooks/localCourse/localCourseModuleHooks.ts +++ b/nextjs/src/hooks/localCourse/localCourseModuleHooks.ts @@ -19,9 +19,6 @@ export const useModuleNamesQuery = () => { return useSuspenseQuery({ queryKey: localCourseKeys.moduleNames(courseName), queryFn: async (): Promise => { - // const url = `/api/courses/${courseName}/modules`; - // const response = await axiosClient.get(url); - // return response.data; return await getModuleNamesFromServer({ courseName }); }, }); @@ -32,9 +29,6 @@ export const useCreateModuleMutation = () => { const queryClient = useQueryClient(); return useMutation({ mutationFn: async (moduleName: string) => { - // const url = `/api/courses/${courseName}/modules`; - // const response = await axiosClient.post(url, { moduleName }); - // return response.data; await createModuleOnServer({ courseName, moduleName }); }, onSuccess: () => { diff --git a/nextjs/src/hooks/localCourse/localCoursesHooks.ts b/nextjs/src/hooks/localCourse/localCoursesHooks.ts index 5501d42..a1e9b5a 100644 --- a/nextjs/src/hooks/localCourse/localCoursesHooks.ts +++ b/nextjs/src/hooks/localCourse/localCoursesHooks.ts @@ -6,12 +6,10 @@ import { useSuspenseQuery, } from "@tanstack/react-query"; import { localCourseKeys } from "./localCourseKeys"; -import { axiosClient } from "@/services/axiosUtils"; import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; import { createCourseOnServer, getAllCoursesSettingsFromServer, - getCourseSettingsFromServer, updateCourseSettingsOnServer, } from "./localCoursesServerActions"; @@ -19,9 +17,6 @@ export const useLocalCoursesSettingsQuery = () => useSuspenseQuery({ queryKey: localCourseKeys.allCoursesSettings, queryFn: async () => { - // const url = `/api/courses/settings`; - // const response = await axiosClient.get(url); - // return response.data; return await getAllCoursesSettingsFromServer(); }, }); @@ -46,8 +41,6 @@ export const useCreateLocalCourseMutation = () => { const queryClient = useQueryClient(); return useMutation({ mutationFn: async (newCourse: LocalCourse) => { - // const url = `/api/courses`; - // await axiosClient.post(url, newCourse); await createCourseOnServer({ course: newCourse }); }, onSuccess: () => { @@ -67,8 +60,6 @@ export const useUpdateLocalCourseSettingsMutation = () => { localCourseKeys.settings(courseName), updatedSettings ); - // const url = `/api/courses/${courseName}/settings`; - // await axiosClient.put(url, updatedSettings); await updateCourseSettingsOnServer({ courseName, settings: updatedSettings }); }, onSuccess: () => {