diff --git a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/assignments/[assignmentName]/route.ts b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/assignments/[assignmentName]/route.ts index f5ba2ba..7c76946 100644 --- a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/assignments/[assignmentName]/route.ts +++ b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/assignments/[assignmentName]/route.ts @@ -10,7 +10,7 @@ export const GET = async ( } ) => await withErrorHandling(async () => { - const settings = await fileStorageService.getAssignment( + const settings = await fileStorageService.assignments.getAssignment( courseName, moduleName, assignmentName @@ -28,7 +28,7 @@ export const PUT = async ( ) => await withErrorHandling(async () => { const assignment = await request.json(); - await fileStorageService.updateAssignment( + await fileStorageService.assignments.updateAssignment( courseName, moduleName, assignmentName, diff --git a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/assignments/route.ts b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/assignments/route.ts index 9e64e13..16b435e 100644 --- a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/assignments/route.ts +++ b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/assignments/route.ts @@ -7,7 +7,7 @@ export const GET = async ( params: { courseName, moduleName }, }: { params: { courseName: string; moduleName: string } } ) => await withErrorHandling(async () => { - const settings = await fileStorageService.getAssignmentNames( + const settings = await fileStorageService.assignments.getAssignmentNames( courseName, moduleName ); diff --git a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/pages/[pageName]/route.ts b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/pages/[pageName]/route.ts index d8a0b10..094e28c 100644 --- a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/pages/[pageName]/route.ts +++ b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/pages/[pageName]/route.ts @@ -8,7 +8,7 @@ export const GET = async ( }: { params: { courseName: string; moduleName: string; pageName: string } } ) => await withErrorHandling(async () => { - const settings = await fileStorageService.getPage( + const settings = await fileStorageService.pages.getPage( courseName, moduleName, pageName @@ -24,6 +24,6 @@ export const PUT = async ( ) => await withErrorHandling(async () => { const page = await request.json(); - await fileStorageService.updatePage(courseName, moduleName, pageName, page); + await fileStorageService.pages.updatePage(courseName, moduleName, pageName, page); return Response.json({}); }); diff --git a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/pages/route.ts b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/pages/route.ts index 38e22f8..f41fa24 100644 --- a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/pages/route.ts +++ b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/pages/route.ts @@ -8,7 +8,7 @@ export const GET = async ( }: { params: { courseName: string; moduleName: string } } ) => await withErrorHandling(async () => { - const settings = await fileStorageService.getPageNames( + const settings = await fileStorageService.pages.getPageNames( courseName, moduleName ); diff --git a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/quizzes/[quizName]/route.ts b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/quizzes/[quizName]/route.ts index 834ec1f..f7afbfc 100644 --- a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/quizzes/[quizName]/route.ts +++ b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/quizzes/[quizName]/route.ts @@ -7,7 +7,7 @@ export const GET = async ( params: { courseName, moduleName, quizName }, }: { params: { courseName: string; moduleName: string; quizName: string } } ) => await withErrorHandling(async () => { - const quiz = await fileStorageService.getQuiz( + const quiz = await fileStorageService.quizzes.getQuiz( courseName, moduleName, quizName @@ -22,7 +22,7 @@ export const PUT = async ( }: { params: { courseName: string; moduleName: string; quizName: string } } ) => await withErrorHandling(async () => { const quiz = await request.json() - await fileStorageService.updateQuiz( + await fileStorageService.quizzes.updateQuiz( courseName, moduleName, quizName, diff --git a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/quizzes/route.ts b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/quizzes/route.ts index b105a50..6e0d39e 100644 --- a/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/quizzes/route.ts +++ b/nextjs/src/app/api/courses/[courseName]/modules/[moduleName]/quizzes/route.ts @@ -8,7 +8,7 @@ export const GET = async ( }: { params: { courseName: string; moduleName: string } } ) => await withErrorHandling(async () => { - const settings = await fileStorageService.getQuizNames( + const settings = await fileStorageService.quizzes.getQuizNames( courseName, moduleName ); diff --git a/nextjs/src/app/api/courses/[courseName]/modules/route.ts b/nextjs/src/app/api/courses/[courseName]/modules/route.ts index b155d31..af884ed 100644 --- a/nextjs/src/app/api/courses/[courseName]/modules/route.ts +++ b/nextjs/src/app/api/courses/[courseName]/modules/route.ts @@ -6,6 +6,16 @@ export const GET = async ( { params: { courseName } }: { params: { courseName: string } } ) => await withErrorHandling(async () => { - const settings = await fileStorageService.getModuleNames(courseName); + const settings = await fileStorageService.modules.getModuleNames(courseName); return Response.json(settings); }); + +export const POST = async ( + request: Request, + { params: { courseName } }: { params: { courseName: string } } +) => + await withErrorHandling(async () => { + const { moduleName } = await request.json(); + await fileStorageService.modules.createModule(courseName, moduleName); + return Response.json({}); + }); diff --git a/nextjs/src/app/api/courses/[courseName]/settings/route.ts b/nextjs/src/app/api/courses/[courseName]/settings/route.ts index f581164..4ed7fb9 100644 --- a/nextjs/src/app/api/courses/[courseName]/settings/route.ts +++ b/nextjs/src/app/api/courses/[courseName]/settings/route.ts @@ -9,7 +9,7 @@ export const GET = async ( if (courseName.includes(".js.map")) { return Response.json({}); } - const settings = await fileStorageService.getCourseSettings(courseName); + const settings = await fileStorageService.settings.getCourseSettings(courseName); return Response.json(settings); }); @@ -20,7 +20,7 @@ export const PUT = async ( await withErrorHandling(async () => { const settings = await request.json(); - await fileStorageService.updateCourseSettings(courseName, settings); + 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 index adb13e2..f4fb91d 100644 --- a/nextjs/src/app/api/courses/route.ts +++ b/nextjs/src/app/api/courses/route.ts @@ -11,7 +11,7 @@ export const GET = async () => export const POST = async (request: Request) => await withErrorHandling(async () => { const newCourse: LocalCourse = await request.json(); - await fileStorageService.updateCourseSettings( + await fileStorageService.settings.updateCourseSettings( newCourse.settings.name, newCourse.settings ); diff --git a/nextjs/src/app/api/courses/settings/route.ts b/nextjs/src/app/api/courses/settings/route.ts index 9894e39..163a614 100644 --- a/nextjs/src/app/api/courses/settings/route.ts +++ b/nextjs/src/app/api/courses/settings/route.ts @@ -3,7 +3,7 @@ import { withErrorHandling } from "@/services/withErrorHandling"; export const GET = async () => await withErrorHandling(async () => { - const settings = await fileStorageService.getAllCoursesSettings(); + const settings = await fileStorageService.settings.getAllCoursesSettings(); return Response.json(settings); }); diff --git a/nextjs/src/app/course/[courseName]/CourseSettingsLink.tsx b/nextjs/src/app/course/[courseName]/CourseSettingsLink.tsx index d486668..5075e28 100644 --- a/nextjs/src/app/course/[courseName]/CourseSettingsLink.tsx +++ b/nextjs/src/app/course/[courseName]/CourseSettingsLink.tsx @@ -12,7 +12,7 @@ export default function CourseSettingsLink() {
{settings.name} - + Course Settings
diff --git a/nextjs/src/app/course/[courseName]/CourseTitle.tsx b/nextjs/src/app/course/[courseName]/CourseTitle.tsx new file mode 100644 index 0000000..6770d39 --- /dev/null +++ b/nextjs/src/app/course/[courseName]/CourseTitle.tsx @@ -0,0 +1,10 @@ +"use client" + +import { useCourseContext } from "./context/courseContext" + +export default function CourseTitle() { + const {courseName}= useCourseContext() + return ( + {courseName} + ) +} diff --git a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx index fbd38d2..f2d96c7 100644 --- a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx @@ -25,7 +25,7 @@ export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => {

{
{weekDaysList.map((day) => ( diff --git a/nextjs/src/app/course/[courseName]/calendar/Day.tsx b/nextjs/src/app/course/[courseName]/calendar/Day.tsx index 250c3d5..299bf90 100644 --- a/nextjs/src/app/course/[courseName]/calendar/Day.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/Day.tsx @@ -11,6 +11,9 @@ import { IModuleItem } from "@/models/local/IModuleItem"; import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks"; import { getDayOfWeek } from "@/models/local/localCourse"; import { getModuleItemUrl } from "@/services/urlUtils"; +import { LocalAssignment } from "@/models/local/assignment/localAssignment"; +import { LocalQuiz } from "@/models/local/quiz/localQuiz"; +import { LocalCoursePage } from "@/models/local/page/localCoursePage"; export default function Day({ day, month }: { day: string; month: number }) { const dayAsDate = getDateFromStringOrThrow( @@ -74,9 +77,9 @@ export default function Day({ day, month }: { day: string; month: number }) { function getTodaysItems(todaysModules: { [moduleName: string]: { - assignments: import("/home/alexm/projects/canvasManagement/nextjs/src/models/local/assignment/localAssignment").LocalAssignment[]; - quizzes: import("/home/alexm/projects/canvasManagement/nextjs/src/models/local/quiz/localQuiz").LocalQuiz[]; - pages: import("/home/alexm/projects/canvasManagement/nextjs/src/models/local/page/localCoursePage").LocalCoursePage[]; + assignments: LocalAssignment[]; + quizzes: LocalQuiz[]; + pages: LocalCoursePage[]; }; }) { const todaysAssignments = todaysModules diff --git a/nextjs/src/app/course/[courseName]/context/CalendarItemsContextProvider.tsx b/nextjs/src/app/course/[courseName]/context/CalendarItemsContextProvider.tsx index 4ba0fb3..1412c4a 100644 --- a/nextjs/src/app/course/[courseName]/context/CalendarItemsContextProvider.tsx +++ b/nextjs/src/app/course/[courseName]/context/CalendarItemsContextProvider.tsx @@ -1,20 +1,13 @@ import { ReactNode } from "react"; -import { useCourseContext } from "./courseContext"; -import { - useAllCourseDataQuery, -} from "@/hooks/localCourse/localCoursesHooks"; import { CalendarItemsContext, CalendarItemsInterface, } from "./calendarItemsContext"; import { - dateToMarkdownString, getDateFromStringOrThrow, getDateOnlyMarkdownString, } from "@/models/local/timeUtils"; -import { LocalAssignment } from "@/models/local/assignment/localAssignment"; -import { LocalQuiz } from "@/models/local/quiz/localQuiz"; -import { LocalCoursePage } from "@/models/local/page/localCoursePage"; +import { useAllCourseDataQuery } from "@/hooks/localCourse/localCourseModuleHooks"; export default function CalendarItemsContextProvider({ children, diff --git a/nextjs/src/app/course/[courseName]/modules/CreateModule.tsx b/nextjs/src/app/course/[courseName]/modules/CreateModule.tsx new file mode 100644 index 0000000..1bcb4ec --- /dev/null +++ b/nextjs/src/app/course/[courseName]/modules/CreateModule.tsx @@ -0,0 +1,36 @@ +import TextInput from "@/components/form/TextInput"; +import { useCreateModuleMutation } from "@/hooks/localCourse/localCourseModuleHooks"; +import React, { useState } from "react"; + +export default function CreateModule() { + const createModule = useCreateModuleMutation(); + const [showForm, setShowForm] = useState(false); + const [moduleName, setModuleName] = useState(""); + return ( + <> + +
+
{ + e.preventDefault(); + if (moduleName) { + await createModule.mutateAsync(moduleName); + setModuleName(""); + } + }} + className="p-1 border border-slate-500 rounded-md my-1 flex flex-row gap-3 justify-between" + > + + + +
+ + ); +} diff --git a/nextjs/src/app/course/[courseName]/modules/ModuleList.tsx b/nextjs/src/app/course/[courseName]/modules/ModuleList.tsx index ab389a8..0221ee8 100644 --- a/nextjs/src/app/course/[courseName]/modules/ModuleList.tsx +++ b/nextjs/src/app/course/[courseName]/modules/ModuleList.tsx @@ -1,13 +1,15 @@ "use client"; -import { useModuleNamesQuery } from "@/hooks/localCourse/localCoursesHooks"; +import { useModuleNamesQuery } from "@/hooks/localCourse/localCourseModuleHooks"; import ExpandableModule from "./ExpandableModule"; +import CreateModule from "./CreateModule"; export default function ModuleList() { const { data: moduleNames } = useModuleNamesQuery(); return (
+ {moduleNames.map((m) => ( - + ))}
); diff --git a/nextjs/src/app/course/[courseName]/page.tsx b/nextjs/src/app/course/[courseName]/page.tsx index 32ef123..cd543f8 100644 --- a/nextjs/src/app/course/[courseName]/page.tsx +++ b/nextjs/src/app/course/[courseName]/page.tsx @@ -3,27 +3,31 @@ import CourseSettingsLink from "./CourseSettingsLink"; import ModuleList from "./modules/ModuleList"; import DraggingContextProvider from "./context/DraggingContextProvider"; import Link from "next/link"; +import CourseTitle from "./CourseTitle"; export default async function CoursePage({}: {}) { return ( -
-
- -
-
- - Back to Course List - -
+ <> + +
+
+ +
+
+ + Back to Course List + +
- -
-
- - -
-
+ +
+
+ + +
+ +
-
+ ); } diff --git a/nextjs/src/app/globals.css b/nextjs/src/app/globals.css index 244cbea..4f80813 100644 --- a/nextjs/src/app/globals.css +++ b/nextjs/src/app/globals.css @@ -90,12 +90,12 @@ select { } -.collapsable { +.collapsible { max-height: 0; overflow: hidden; transition: max-height .5s ease-out; } -.collapsable.expand { +.collapsible.expand { max-height: 100vh; } \ No newline at end of file diff --git a/nextjs/src/app/newCourse/AddNewCourse.tsx b/nextjs/src/app/newCourse/AddNewCourse.tsx index a0b6275..18bbecb 100644 --- a/nextjs/src/app/newCourse/AddNewCourse.tsx +++ b/nextjs/src/app/newCourse/AddNewCourse.tsx @@ -10,7 +10,7 @@ export default function AddNewCourse() {
-
+
{showForm && } diff --git a/nextjs/src/components/form/TextInput.tsx b/nextjs/src/components/form/TextInput.tsx index 465a543..bfb2494 100644 --- a/nextjs/src/components/form/TextInput.tsx +++ b/nextjs/src/components/form/TextInput.tsx @@ -4,17 +4,19 @@ export default function TextInput({ value, setValue, label, + className, }: { value: string; setValue: (newValue: string) => void; label: string; + className?: string; }) { return ( -