diff --git a/nextjs/src/app/course/[courseName]/context/drag/useItemDropOnDay.ts b/nextjs/src/app/course/[courseName]/context/drag/useItemDropOnDay.ts
index 027284b..2f1c43d 100644
--- a/nextjs/src/app/course/[courseName]/context/drag/useItemDropOnDay.ts
+++ b/nextjs/src/app/course/[courseName]/context/drag/useItemDropOnDay.ts
@@ -195,14 +195,13 @@ export function useItemDropOnDay({
}
},
[
+ courseName,
modal,
setIsDragging,
setIsLoading,
setModalCallback,
setModalText,
- settings.defaultDueTime.hour,
- settings.defaultDueTime.minute,
- settings.name,
+ settings,
updateAssignmentMutation,
updateLectureMutation,
updatePageMutation,
diff --git a/nextjs/src/app/course/[courseName]/layout.tsx b/nextjs/src/app/course/[courseName]/layout.tsx
index 58279a4..656204a 100644
--- a/nextjs/src/app/course/[courseName]/layout.tsx
+++ b/nextjs/src/app/course/[courseName]/layout.tsx
@@ -1,12 +1,4 @@
-import { fileStorageService } from "@/services/fileStorage/fileStorageService";
import { Suspense } from "react";
-import { getQueryClient } from "@/app/providersQueryClientUtils";
-import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
-import { hydrateCanvasCourse } from "@/hooks/hookHydration";
-import { createServerSideHelpers } from "@trpc/react-query/server";
-import { trpcAppRouter } from "@/services/trpc/router/app";
-import { createTrpcContext } from "@/services/trpc/context";
-import superjson from "superjson";
import CourseContextProvider from "./context/CourseContextProvider";
export default async function CourseLayout({
@@ -22,20 +14,11 @@ export default async function CourseLayout({
console.log("cannot load course that is .js.map " + decodedCourseName);
return
;
}
- // const settings = await fileStorageService.settings.getCourseSettings(
- // decodedCourseName
- // );
- // const queryClient = getQueryClient();
- // await hydrateCanvasCourse(settings.canvasId, queryClient);
- // const dehydratedState = dehydrate(queryClient);
-
return (
- {/* */}
{children}
- {/* */}
);
}
diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLecture.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLecture.tsx
index 1c1a746..429f353 100644
--- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLecture.tsx
+++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLecture.tsx
@@ -52,7 +52,7 @@ Date: ${lectureDay}
return () => {
clearTimeout(handler);
};
- }, [lecture, text, updateLecture]);
+ }, [courseName, lecture, settings, text, updateLecture]);
return (
diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/LectureButtons.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/LectureButtons.tsx
index f9222ad..43b8c8a 100644
--- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/LectureButtons.tsx
+++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/LectureButtons.tsx
@@ -7,9 +7,8 @@ import { useQueryClient } from "@tanstack/react-query";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { useCourseContext } from "../../context/courseContext";
-import { deleteLecture } from "@/services/fileStorage/lectureFileStorageService";
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
-import { lectureKeys } from "@/hooks/localCourse/lectureKeys";
+import { useDeleteLectureMutation } from "@/hooks/localCourse/lectureHooks";
export default function LectureButtons({ lectureDay }: { lectureDay: string }) {
const queryClient = useQueryClient();
@@ -18,6 +17,7 @@ export default function LectureButtons({ lectureDay }: { lectureDay: string }) {
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
const modal = useModal();
+ const deleteLecture = useDeleteLectureMutation();
return (
@@ -39,9 +39,10 @@ export default function LectureButtons({ lectureDay }: { lectureDay: string }) {
onClick={async () => {
setIsLoading(true);
router.push(getCourseUrl(courseName));
- await deleteLecture(courseName, settings, lectureDay);
- await queryClient.invalidateQueries({
- queryKey: lectureKeys.allLectures(courseName),
+ await deleteLecture.mutateAsync({
+ courseName,
+ settings,
+ lectureDay,
});
}}
disabled={isLoading}
diff --git a/nextjs/src/app/newCourse/NewCourseForm.tsx b/nextjs/src/app/newCourse/NewCourseForm.tsx
index 7c6511b..3eddd72 100644
--- a/nextjs/src/app/newCourse/NewCourseForm.tsx
+++ b/nextjs/src/app/newCourse/NewCourseForm.tsx
@@ -140,7 +140,7 @@ function OtherSettings({
}) {
const { data: canvasCourses } = useCourseListInTermQuery(selectedTerm.id);
const [allSettings] = useLocalCoursesSettingsQuery();
- const { data: emptyDirectories } = useEmptyDirectoriesQuery();
+ const [emptyDirectories] = useEmptyDirectoriesQuery();
const populatedCanvasCourseIds = allSettings.map((s) => s.canvasId);
const availableCourses = canvasCourses.filter(
diff --git a/nextjs/src/hooks/localCourse/lectureHooks.ts b/nextjs/src/hooks/localCourse/lectureHooks.ts
index 84a6d50..fa481ac 100644
--- a/nextjs/src/hooks/localCourse/lectureHooks.ts
+++ b/nextjs/src/hooks/localCourse/lectureHooks.ts
@@ -8,3 +8,12 @@ export const useLectureUpdateMutation = () => {
},
});
};
+
+export const useDeleteLectureMutation = () => {
+ const utils = trpc.useUtils();
+ return trpc.lectures.deleteLecture.useMutation({
+ onSuccess: () => {
+ utils.lectures.getLectures.invalidate();
+ },
+ });
+};
diff --git a/nextjs/src/services/trpc/router/app.ts b/nextjs/src/services/trpc/router/app.ts
index 4e59a68..18d5a2d 100644
--- a/nextjs/src/services/trpc/router/app.ts
+++ b/nextjs/src/services/trpc/router/app.ts
@@ -9,16 +9,8 @@ import { pageRouter } from "./pageRouter";
import { quizRouter } from "./quizRouter";
import { settingsRouter } from "./settingsRouter";
-export const helloRouter = router({
- sayHello: publicProcedure.query(() => {
- // runs on the server I think
- console.log("hello world router on the server?");
- return { greeting: `Hello World!` };
- }),
-});
export const trpcAppRouter = router({
- hello: helloRouter,
assignment: assignmentRouter,
lectures: lectureRouter,
settings: settingsRouter,
diff --git a/nextjs/src/services/trpc/router/lectureRouter.ts b/nextjs/src/services/trpc/router/lectureRouter.ts
index 931b6a4..892581a 100644
--- a/nextjs/src/services/trpc/router/lectureRouter.ts
+++ b/nextjs/src/services/trpc/router/lectureRouter.ts
@@ -37,4 +37,15 @@ export const lectureRouter = router({
}
}
),
+ deleteLecture: publicProcedure
+ .input(
+ z.object({
+ courseName: z.string(),
+ lectureDay: z.string(),
+ settings: zodLocalCourseSettings,
+ })
+ )
+ .mutation(async ({ input: { courseName, settings, lectureDay } }) => {
+ await deleteLecture(courseName, settings, lectureDay);
+ }),
});