mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-27 07:58:31 -06:00
back to the good old days
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
"use client"
|
||||
import { ReactNode } from "react";
|
||||
import { CourseContext } from "./courseContext";
|
||||
import { useLocalCourseDetailsQuery } from "@/hooks/localCoursesHooks";
|
||||
|
||||
export default function CourseContextProvider({
|
||||
localCourseName,
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
localCourseName: string;
|
||||
}) {
|
||||
const { data: course } = useLocalCourseDetailsQuery(localCourseName);
|
||||
return (
|
||||
<CourseContext.Provider value={{ localCourse: course }}>
|
||||
{children}
|
||||
</CourseContext.Provider>
|
||||
);
|
||||
}
|
||||
31
nextjs/src/app/course/[courseName]/context/courseContext.ts
Normal file
31
nextjs/src/app/course/[courseName]/context/courseContext.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
import { LocalCourse } from "@/models/local/localCourse";
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
export interface CourseContextInterface {
|
||||
localCourse: LocalCourse;
|
||||
}
|
||||
|
||||
const defaultValue: CourseContextInterface = {
|
||||
localCourse: {
|
||||
modules: [],
|
||||
settings: {
|
||||
name: "",
|
||||
assignmentGroups: [],
|
||||
daysOfWeek: [],
|
||||
startDate: "",
|
||||
endDate: "",
|
||||
defaultDueTime: {
|
||||
hour: 0,
|
||||
minute: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const CourseContext =
|
||||
createContext<CourseContextInterface>(defaultValue);
|
||||
|
||||
export function useCourseContext() {
|
||||
return useContext(CourseContext);
|
||||
}
|
||||
Reference in New Issue
Block a user