mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
moving data management to lots of queries
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
|
||||
export async function GET(
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, assignmentName },
|
||||
}: {
|
||||
params: { courseName: string; moduleName: string; assignmentName: string };
|
||||
}
|
||||
) {
|
||||
const settings = await fileStorageService.getAssignment(
|
||||
courseName,
|
||||
moduleName,
|
||||
assignmentName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
|
||||
export async function GET(
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName },
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getAssignmentNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
|
||||
export async function GET(
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, pageName },
|
||||
}: { params: { courseName: string; moduleName: string; pageName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getPage(
|
||||
courseName,
|
||||
moduleName,
|
||||
pageName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
|
||||
export async function GET(
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName },
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getPageNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
|
||||
export async function GET(
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, quizName },
|
||||
}: { params: { courseName: string; moduleName: string; quizName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getQuiz(
|
||||
courseName,
|
||||
moduleName,
|
||||
quizName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
|
||||
export async function GET(
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName },
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getQuizNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
@@ -1,12 +1,7 @@
|
||||
"use client";
|
||||
import { ReactNode, useState } from "react";
|
||||
import { CourseContext, DraggableItem } from "./courseContext";
|
||||
import {
|
||||
useLocalCourseSettingsQuery,
|
||||
useUpdateCourseMutation,
|
||||
} from "@/hooks/localCoursesHooks";
|
||||
import { LocalQuiz } from "@/models/local/quiz/localQuiz";
|
||||
import { LocalCourse } from "@/models/local/localCourse";
|
||||
import { dateToMarkdownString } from "@/models/local/timeUtils";
|
||||
|
||||
export default function CourseContextProvider({
|
||||
@@ -16,8 +11,6 @@ export default function CourseContextProvider({
|
||||
children: ReactNode;
|
||||
localCourseName: string;
|
||||
}) {
|
||||
const { data: settings } = useLocalCourseSettingsQuery(localCourseName);
|
||||
const updateCourseMutation = useUpdateCourseMutation(localCourseName);
|
||||
const [itemBeingDragged, setItemBeingDragged] = useState<
|
||||
DraggableItem | undefined
|
||||
>();
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import { getDehydratedClient } from "@/app/layout";
|
||||
import CourseContextProvider from "./context/CourseContextProvider";
|
||||
import CourseCalendar from "./calendar/CourseCalendar";
|
||||
import { HydrationBoundary } from "@tanstack/react-query";
|
||||
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||
import CourseSettings from "./CourseSettings";
|
||||
import ModuleList from "./modules/ModuleList";
|
||||
import { createQueryClientForServer } from "@/services/utils/queryClientServer";
|
||||
import { hydrateCourse } from "@/hooks/hookHydration";
|
||||
|
||||
export default async function CoursePage({
|
||||
params: { courseName },
|
||||
}: {
|
||||
params: { courseName: string };
|
||||
}) {
|
||||
const dehydratedState = await getDehydratedClient();
|
||||
const queryClient = createQueryClientForServer();
|
||||
|
||||
await hydrateCourse(queryClient, courseName);
|
||||
const dehydratedState = dehydrate(queryClient);
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydratedState}>
|
||||
<CourseContextProvider localCourseName={courseName}>
|
||||
|
||||
@@ -9,14 +9,6 @@ export const metadata: Metadata = {
|
||||
title: "Canvas Manager 2.0",
|
||||
};
|
||||
|
||||
export async function getDehydratedClient() {
|
||||
const queryClient = createQueryClientForServer();
|
||||
|
||||
await hydrateCourses(queryClient);
|
||||
const dehydratedState = dehydrate(queryClient);
|
||||
return dehydratedState;
|
||||
}
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import { HydrationBoundary } from "@tanstack/react-query";
|
||||
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||
import CourseList from "./CourseList";
|
||||
import { getDehydratedClient } from "./layout";
|
||||
import { createQueryClientForServer } from "@/services/utils/queryClientServer";
|
||||
import { hydrateCourses } from "@/hooks/hookHydration";
|
||||
|
||||
async function getDehydratedClient() {
|
||||
const queryClient = createQueryClientForServer();
|
||||
|
||||
await hydrateCourses(queryClient);
|
||||
const dehydratedState = dehydrate(queryClient);
|
||||
return dehydratedState;
|
||||
}
|
||||
|
||||
export default async function Home() {
|
||||
const dehydratedState = await getDehydratedClient();
|
||||
|
||||
@@ -12,7 +12,7 @@ function makeQueryClient() {
|
||||
queries: {
|
||||
// With SSR, we usually want to set some default staleTime
|
||||
// above 0 to avoid refetching immediately on the client
|
||||
staleTime: 60 * 1000,
|
||||
// staleTime: 1000,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user