mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
doing more trpc, still working on preloading
This commit is contained in:
@@ -13,7 +13,6 @@
|
|||||||
"@next/env": "^15.0.3",
|
"@next/env": "^15.0.3",
|
||||||
"@tanstack/react-query": "^5.59.20",
|
"@tanstack/react-query": "^5.59.20",
|
||||||
"@trpc/client": "11.0.0-rc.608",
|
"@trpc/client": "11.0.0-rc.608",
|
||||||
"@trpc/next": "11.0.0-rc.608",
|
|
||||||
"@trpc/react-query": "11.0.0-rc.608",
|
"@trpc/react-query": "11.0.0-rc.608",
|
||||||
"@trpc/server": "11.0.0-rc.608",
|
"@trpc/server": "11.0.0-rc.608",
|
||||||
"jsdom": "^25.0.0",
|
"jsdom": "^25.0.0",
|
||||||
|
|||||||
30
nextjs/pnpm-lock.yaml
generated
30
nextjs/pnpm-lock.yaml
generated
@@ -17,9 +17,6 @@ importers:
|
|||||||
'@trpc/client':
|
'@trpc/client':
|
||||||
specifier: 11.0.0-rc.608
|
specifier: 11.0.0-rc.608
|
||||||
version: 11.0.0-rc.608(@trpc/server@11.0.0-rc.608)
|
version: 11.0.0-rc.608(@trpc/server@11.0.0-rc.608)
|
||||||
'@trpc/next':
|
|
||||||
specifier: 11.0.0-rc.608
|
|
||||||
version: 11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/react-query@11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/server@11.0.0-rc.608)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@trpc/server@11.0.0-rc.608)(next@15.0.2(@babel/core@7.26.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
|
||||||
'@trpc/react-query':
|
'@trpc/react-query':
|
||||||
specifier: 11.0.0-rc.608
|
specifier: 11.0.0-rc.608
|
||||||
version: 11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/server@11.0.0-rc.608)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/server@11.0.0-rc.608)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
@@ -721,22 +718,6 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@trpc/server': 11.0.0-rc.608+f75de97b3
|
'@trpc/server': 11.0.0-rc.608+f75de97b3
|
||||||
|
|
||||||
'@trpc/next@11.0.0-rc.608':
|
|
||||||
resolution: {integrity: sha512-dL+ifSaJIl+21P3LZ1JEl1uzqDD7pZ3iCs9uEnf3tjyZhbCuavnTL7faRDV6wZ6+L6opzKxIzeVNC4e490Ys0Q==}
|
|
||||||
peerDependencies:
|
|
||||||
'@tanstack/react-query': ^5.59.15
|
|
||||||
'@trpc/client': 11.0.0-rc.608+f75de97b3
|
|
||||||
'@trpc/react-query': 11.0.0-rc.608+f75de97b3
|
|
||||||
'@trpc/server': 11.0.0-rc.608+f75de97b3
|
|
||||||
next: 15.0.2
|
|
||||||
react: '>=16.8.0'
|
|
||||||
react-dom: '>=16.8.0'
|
|
||||||
peerDependenciesMeta:
|
|
||||||
'@tanstack/react-query':
|
|
||||||
optional: true
|
|
||||||
'@trpc/react-query':
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
'@trpc/react-query@11.0.0-rc.608':
|
'@trpc/react-query@11.0.0-rc.608':
|
||||||
resolution: {integrity: sha512-V0UJltzCfdn3PqePqbB8TK64aNXVBpdoLEC4OdMtTYiZTsAnH1jTwrNOBji3Xwm8Q0n4jaUDrIz5M/5IPjYrGg==}
|
resolution: {integrity: sha512-V0UJltzCfdn3PqePqbB8TK64aNXVBpdoLEC4OdMtTYiZTsAnH1jTwrNOBji3Xwm8Q0n4jaUDrIz5M/5IPjYrGg==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3075,17 +3056,6 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@trpc/server': 11.0.0-rc.608
|
'@trpc/server': 11.0.0-rc.608
|
||||||
|
|
||||||
'@trpc/next@11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/react-query@11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/server@11.0.0-rc.608)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@trpc/server@11.0.0-rc.608)(next@15.0.2(@babel/core@7.26.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
|
||||||
dependencies:
|
|
||||||
'@trpc/client': 11.0.0-rc.608(@trpc/server@11.0.0-rc.608)
|
|
||||||
'@trpc/server': 11.0.0-rc.608
|
|
||||||
next: 15.0.2(@babel/core@7.26.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
|
||||||
react: 18.3.1
|
|
||||||
react-dom: 18.3.1(react@18.3.1)
|
|
||||||
optionalDependencies:
|
|
||||||
'@tanstack/react-query': 5.59.20(react@18.3.1)
|
|
||||||
'@trpc/react-query': 11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/server@11.0.0-rc.608)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
|
||||||
|
|
||||||
'@trpc/react-query@11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/server@11.0.0-rc.608)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
'@trpc/react-query@11.0.0-rc.608(@tanstack/react-query@5.59.20(react@18.3.1))(@trpc/client@11.0.0-rc.608(@trpc/server@11.0.0-rc.608))(@trpc/server@11.0.0-rc.608)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tanstack/react-query': 5.59.20(react@18.3.1)
|
'@tanstack/react-query': 5.59.20(react@18.3.1)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { getCourseUrl } from "@/services/urlUtils";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
export default function CourseList() {
|
export default function CourseList() {
|
||||||
const { data: allSettings } = useLocalCoursesSettingsQuery();
|
const [allSettings] = useLocalCoursesSettingsQuery();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { CalendarMonthModel } from "./calendarMonthUtils";
|
import { CalendarMonthModel } from "./calendarMonthUtils";
|
||||||
import { DayOfWeek } from "@/models/local/localCourse";
|
import { DayOfWeek } from "@/models/local/localCourseSettings";
|
||||||
import { Expandable } from "@/components/Expandable";
|
import { Expandable } from "@/components/Expandable";
|
||||||
import { CalendarWeek } from "./CalendarWeek";
|
import { CalendarWeek } from "./CalendarWeek";
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
} from "@/models/local/timeUtils";
|
} from "@/models/local/timeUtils";
|
||||||
import { useDraggingContext } from "../../context/drag/draggingContext";
|
import { useDraggingContext } from "../../context/drag/draggingContext";
|
||||||
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
|
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
|
||||||
import { getDayOfWeek } from "@/models/local/localCourse";
|
import { getDayOfWeek } from "@/models/local/localCourseSettings";
|
||||||
import { ItemInDay } from "./ItemInDay";
|
import { ItemInDay } from "./ItemInDay";
|
||||||
import { useTodaysItems } from "./useTodaysItems";
|
import { useTodaysItems } from "./useTodaysItems";
|
||||||
import { DayTitle } from "./DayTitle";
|
import { DayTitle } from "./DayTitle";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
|
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
|
||||||
import { getDayOfWeek } from "@/models/local/localCourse";
|
import { getDayOfWeek } from "@/models/local/localCourseSettings";
|
||||||
import { getDateFromString } from "@/models/local/timeUtils";
|
import { getDateFromString } from "@/models/local/timeUtils";
|
||||||
import { getLectureWeekName } from "@/services/fileStorage/utils/lectureUtils";
|
import { getLectureWeekName } from "@/services/fileStorage/utils/lectureUtils";
|
||||||
import { getCourseUrl, getLecturePreviewUrl } from "@/services/urlUtils";
|
import { getCourseUrl, getLecturePreviewUrl } from "@/services/urlUtils";
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ import CourseContextProvider from "../../context/CourseContextProvider";
|
|||||||
|
|
||||||
export default async function LectureLayout({
|
export default async function LectureLayout({
|
||||||
children,
|
children,
|
||||||
params: { courseName, lectureDay },
|
params,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: { courseName: string; lectureDay: string };
|
params: Promise<{ courseName: string; lectureDay: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
const { courseName, lectureDay } = await params;
|
||||||
const decodedCourseName = decodeURIComponent(courseName);
|
const decodedCourseName = decodeURIComponent(courseName);
|
||||||
if (courseName.includes(".js.map")) {
|
if (courseName.includes(".js.map")) {
|
||||||
console.log("cannot load course that is .js.map " + decodedCourseName);
|
console.log("cannot load course that is .js.map " + decodedCourseName);
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import {
|
|||||||
getDateOnlyMarkdownString,
|
getDateOnlyMarkdownString,
|
||||||
} from "@/models/local/timeUtils";
|
} from "@/models/local/timeUtils";
|
||||||
|
|
||||||
export default function page({
|
export default async function page({
|
||||||
params: { lectureDay },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { lectureDay: string };
|
params: Promise<{ lectureDay: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
const { lectureDay } = await params;
|
||||||
const decodedLectureDay = decodeURIComponent(lectureDay);
|
const decodedLectureDay = decodeURIComponent(lectureDay);
|
||||||
console.log(decodedLectureDay);
|
console.log(decodedLectureDay);
|
||||||
const lectureDate = getDateFromStringOrThrow(
|
const lectureDate = getDateFromStringOrThrow(
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import {
|
|||||||
} from "@/models/local/timeUtils";
|
} from "@/models/local/timeUtils";
|
||||||
import LecturePreviewPage from "./LecturePreviewPage";
|
import LecturePreviewPage from "./LecturePreviewPage";
|
||||||
|
|
||||||
export default function Page({
|
export default async function Page({
|
||||||
params: { lectureDay },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { lectureDay: string };
|
params: Promise<{ lectureDay: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
const { lectureDay } = await params;
|
||||||
const decodedLectureDay = decodeURIComponent(lectureDay);
|
const decodedLectureDay = decodeURIComponent(lectureDay);
|
||||||
console.log(decodedLectureDay);
|
console.log(decodedLectureDay);
|
||||||
const lectureDate = getDateFromStringOrThrow(
|
const lectureDate = getDateFromStringOrThrow(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHoo
|
|||||||
import ClientOnly from "@/components/ClientOnly";
|
import ClientOnly from "@/components/ClientOnly";
|
||||||
import { SuspenseAndErrorHandling } from "@/components/SuspenseAndErrorHandling";
|
import { SuspenseAndErrorHandling } from "@/components/SuspenseAndErrorHandling";
|
||||||
import { AssignmentSubmissionType } from "@/models/local/assignment/assignmentSubmissionType";
|
import { AssignmentSubmissionType } from "@/models/local/assignment/assignmentSubmissionType";
|
||||||
import { LocalCourseSettings } from "@/models/local/localCourse";
|
import { LocalCourseSettings } from "@/models/local/localCourseSettings";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { AssignmentButtons } from "./AssignmentButtons";
|
import { AssignmentButtons } from "./AssignmentButtons";
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import EditAssignment from "./EditAssignment";
|
import EditAssignment from "./EditAssignment";
|
||||||
import ClientOnly from "@/components/ClientOnly";
|
|
||||||
|
|
||||||
export default function Page({
|
export default async function Page({
|
||||||
params: { moduleName, assignmentName },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { assignmentName: string; moduleName: string };
|
params: Promise<{ assignmentName: string; moduleName: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
const { moduleName, assignmentName } = await params;
|
||||||
const decodedAssignmentName = decodeURIComponent(assignmentName);
|
const decodedAssignmentName = decodeURIComponent(assignmentName);
|
||||||
const decodedModuleName = decodeURIComponent(moduleName);
|
const decodedModuleName = decodeURIComponent(moduleName);
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ import React from "react";
|
|||||||
import EditPage from "./EditPage";
|
import EditPage from "./EditPage";
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
params: { moduleName, pageName },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { pageName: string; moduleName: string };
|
params: Promise<{ pageName: string; moduleName: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
const { moduleName, pageName } = await params;
|
||||||
const decodedPageName = decodeURIComponent(pageName);
|
const decodedPageName = decodeURIComponent(pageName);
|
||||||
const decodedModuleName = decodeURIComponent(moduleName);
|
const decodedModuleName = decodeURIComponent(moduleName);
|
||||||
return <EditPage pageName={decodedPageName} moduleName={decodedModuleName} />;
|
return <EditPage pageName={decodedPageName} moduleName={decodedModuleName} />;
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ import React from "react";
|
|||||||
import EditQuiz from "./EditQuiz";
|
import EditQuiz from "./EditQuiz";
|
||||||
|
|
||||||
export default async function Page({
|
export default async function Page({
|
||||||
params: { moduleName, quizName },
|
params,
|
||||||
}: {
|
}: {
|
||||||
params: { quizName: string; moduleName: string };
|
params: Promise<{ quizName: string; moduleName: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
const { moduleName, quizName } = await params;
|
||||||
const decodedQuizName = decodeURIComponent(quizName)
|
const decodedQuizName = decodeURIComponent(quizName)
|
||||||
const decodedModuleName = decodeURIComponent(moduleName)
|
const decodedModuleName = decodeURIComponent(moduleName)
|
||||||
return <EditQuiz quizName={decodedQuizName} moduleName={decodedModuleName} />;
|
return <EditQuiz quizName={decodedQuizName} moduleName={decodedModuleName} />;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { useEmptyDirectoriesQuery } from "@/hooks/localCourse/storageDirectoryHo
|
|||||||
import { CanvasCourseModel } from "@/models/canvas/courses/canvasCourseModel";
|
import { CanvasCourseModel } from "@/models/canvas/courses/canvasCourseModel";
|
||||||
import { CanvasEnrollmentTermModel } from "@/models/canvas/enrollmentTerms/canvasEnrollmentTermModel";
|
import { CanvasEnrollmentTermModel } from "@/models/canvas/enrollmentTerms/canvasEnrollmentTermModel";
|
||||||
import { AssignmentSubmissionType } from "@/models/local/assignment/assignmentSubmissionType";
|
import { AssignmentSubmissionType } from "@/models/local/assignment/assignmentSubmissionType";
|
||||||
import { DayOfWeek } from "@/models/local/localCourse";
|
import { DayOfWeek } from "@/models/local/localCourseSettings";
|
||||||
import { getCourseUrl } from "@/services/urlUtils";
|
import { getCourseUrl } from "@/services/urlUtils";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import React, { useMemo, useState } from "react";
|
import React, { useMemo, useState } from "react";
|
||||||
@@ -81,7 +81,6 @@ export default function NewCourseForm() {
|
|||||||
if (formIsComplete) {
|
if (formIsComplete) {
|
||||||
createCourse
|
createCourse
|
||||||
.mutateAsync({
|
.mutateAsync({
|
||||||
modules: [],
|
|
||||||
settings: {
|
settings: {
|
||||||
name: selectedDirectory,
|
name: selectedDirectory,
|
||||||
assignmentGroups: [],
|
assignmentGroups: [],
|
||||||
@@ -96,7 +95,7 @@ export default function NewCourseForm() {
|
|||||||
],
|
],
|
||||||
defaultFileUploadTypes: ["pdf", "png", "jpg", "jpeg"],
|
defaultFileUploadTypes: ["pdf", "png", "jpg", "jpeg"],
|
||||||
defaultLockHoursOffset: 0,
|
defaultLockHoursOffset: 0,
|
||||||
holidays: []
|
holidays: [],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -140,7 +139,7 @@ function OtherSettings({
|
|||||||
setSelectedDaysOfWeek: React.Dispatch<React.SetStateAction<DayOfWeek[]>>;
|
setSelectedDaysOfWeek: React.Dispatch<React.SetStateAction<DayOfWeek[]>>;
|
||||||
}) {
|
}) {
|
||||||
const { data: canvasCourses } = useCourseListInTermQuery(selectedTerm.id);
|
const { data: canvasCourses } = useCourseListInTermQuery(selectedTerm.id);
|
||||||
const { data: allSettings } = useLocalCoursesSettingsQuery();
|
const [allSettings] = useLocalCoursesSettingsQuery();
|
||||||
const { data: emptyDirectories } = useEmptyDirectoriesQuery();
|
const { data: emptyDirectories } = useEmptyDirectoriesQuery();
|
||||||
|
|
||||||
const populatedCanvasCourseIds = allSettings.map((s) => s.canvasId);
|
const populatedCanvasCourseIds = allSettings.map((s) => s.canvasId);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import CourseContextProvider from "../course/[courseName]/context/CourseContextP
|
|||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
|
|
||||||
export default function TodaysLectures() {
|
export default function TodaysLectures() {
|
||||||
const { data: allSettings } = useLocalCoursesSettingsQuery();
|
const [allSettings] = useLocalCoursesSettingsQuery();
|
||||||
return (
|
return (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
{/* <h3 className="text-center text-slate-400">todays lectures</h3> */}
|
{/* <h3 className="text-center text-slate-400">todays lectures</h3> */}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { SimpleTimeOnly } from "@/models/local/localCourse";
|
import { SimpleTimeOnly } from "@/models/local/localCourseSettings";
|
||||||
import { FC, useState, useEffect } from "react";
|
import { FC, useState, useEffect } from "react";
|
||||||
|
|
||||||
export const TimePicker: FC<{
|
export const TimePicker: FC<{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DayOfWeek } from "@/models/local/localCourse";
|
import { DayOfWeek } from "@/models/local/localCourseSettings";
|
||||||
|
|
||||||
export function DayOfWeekInput({
|
export function DayOfWeekInput({
|
||||||
selectedDays,
|
selectedDays,
|
||||||
@@ -15,11 +15,7 @@ export function DayOfWeekInput({
|
|||||||
<button
|
<button
|
||||||
role="button"
|
role="button"
|
||||||
key={day}
|
key={day}
|
||||||
className={
|
className={hasDay ? "" : "unstyled btn-outline "}
|
||||||
hasDay
|
|
||||||
? ""
|
|
||||||
: "unstyled btn-outline "
|
|
||||||
}
|
|
||||||
onClick={() => updateSettings(day)}
|
onClick={() => updateSettings(day)}
|
||||||
>
|
>
|
||||||
{day}
|
{day}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { QueryClient } from "@tanstack/react-query";
|
import { QueryClient } from "@tanstack/react-query";
|
||||||
import { localCourseKeys } from "./localCourse/localCourseKeys";
|
import { localCourseKeys } from "./localCourse/localCourseKeys";
|
||||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||||
import { LocalCourseSettings } from "@/models/local/localCourse";
|
import { LocalCourseSettings } from "@/models/local/localCourseSettings";
|
||||||
import { canvasAssignmentService } from "@/services/canvas/canvasAssignmentService";
|
import { canvasAssignmentService } from "@/services/canvas/canvasAssignmentService";
|
||||||
import { canvasAssignmentKeys } from "./canvas/canvasAssignmentHooks";
|
import { canvasAssignmentKeys } from "./canvas/canvasAssignmentHooks";
|
||||||
import { LocalAssignment } from "@/models/local/assignment/localAssignment";
|
import { LocalAssignment } from "@/models/local/assignment/localAssignment";
|
||||||
@@ -32,7 +32,6 @@ export const hydrateCourse = async (
|
|||||||
queryClient: QueryClient,
|
queryClient: QueryClient,
|
||||||
courseSettings: LocalCourseSettings
|
courseSettings: LocalCourseSettings
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
const courseName = courseSettings.name;
|
const courseName = courseSettings.name;
|
||||||
const moduleNames = await fileStorageService.modules.getModuleNames(
|
const moduleNames = await fileStorageService.modules.getModuleNames(
|
||||||
courseName
|
courseName
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
getModuleNamesFromServer,
|
getModuleNamesFromServer,
|
||||||
} from "./localCourseModuleServerActions";
|
} from "./localCourseModuleServerActions";
|
||||||
import { trpc } from "@/services/trpc/utils";
|
import { trpc } from "@/services/trpc/utils";
|
||||||
|
import { LocalAssignment } from "@/models/local/assignment/localAssignment";
|
||||||
|
|
||||||
export const useModuleNamesQuery = () => {
|
export const useModuleNamesQuery = () => {
|
||||||
const { courseName } = useCourseContext();
|
const { courseName } = useCourseContext();
|
||||||
@@ -38,7 +39,14 @@ export const useCreateModuleMutation = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useAllCourseDataQuery = () => {
|
export const useAllCourseDataQuery = (): {
|
||||||
|
assignmentsAndModules: {
|
||||||
|
moduleName: string;
|
||||||
|
assignment: LocalAssignment;
|
||||||
|
}[];
|
||||||
|
quizzesAndModules: any[];
|
||||||
|
pagesAndModules: any[];
|
||||||
|
} => {
|
||||||
const { courseName } = useCourseContext();
|
const { courseName } = useCourseContext();
|
||||||
const { data: moduleNames } = useModuleNamesQuery();
|
const { data: moduleNames } = useModuleNamesQuery();
|
||||||
|
|
||||||
|
|||||||
@@ -1,101 +1,34 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { LocalCourse, LocalCourseSettings } from "@/models/local/localCourse";
|
|
||||||
import {
|
|
||||||
useMutation,
|
|
||||||
useQueryClient,
|
|
||||||
useSuspenseQuery,
|
|
||||||
} from "@tanstack/react-query";
|
|
||||||
import { localCourseKeys } from "./localCourseKeys";
|
|
||||||
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||||
import {
|
|
||||||
createCourseOnServer,
|
|
||||||
updateCourseSettingsOnServer,
|
|
||||||
} from "./localCoursesServerActions";
|
|
||||||
import { trpc } from "@/services/trpc/utils";
|
import { trpc } from "@/services/trpc/utils";
|
||||||
|
|
||||||
export const useLocalCoursesSettingsQuery = () =>
|
export const useLocalCoursesSettingsQuery = () =>
|
||||||
trpc.settings.allCoursesSettings.useSuspenseQuery();
|
trpc.settings.allCoursesSettings.useSuspenseQuery();
|
||||||
// useSuspenseQuery({
|
|
||||||
// queryKey: localCourseKeys.allCoursesSettings,
|
|
||||||
// queryFn: async () => {
|
|
||||||
// return await getAllCoursesSettingsFromServer();
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
export const useLocalCourseSettingsQuery = () => {
|
export const useLocalCourseSettingsQuery = () => {
|
||||||
const { courseName } = useCourseContext();
|
const { courseName } = useCourseContext();
|
||||||
// const { data: settingsList } = useLocalCoursesSettingsQuery();
|
|
||||||
return trpc.settings.courseSettings.useSuspenseQuery({ courseName });
|
return trpc.settings.courseSettings.useSuspenseQuery({ courseName });
|
||||||
// return useSuspenseQuery({
|
|
||||||
// queryKey: localCourseKeys.settings(courseName),
|
|
||||||
// queryFn: async () => {
|
|
||||||
// const settingsList = await getAllCoursesSettingsFromServer();
|
|
||||||
// const s = settingsList.find((s) => s.name === courseName);
|
|
||||||
// if (!s) {
|
|
||||||
// console.log(courseName, settingsList);
|
|
||||||
// throw Error("Could not find settings for course " + courseName);
|
|
||||||
// }
|
|
||||||
// return s;
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCreateLocalCourseMutation = () => {
|
export const useCreateLocalCourseMutation = () => {
|
||||||
const queryClient = useQueryClient();
|
const utils = trpc.useUtils();
|
||||||
return useMutation({
|
return trpc.settings.createCourse.useMutation({
|
||||||
mutationFn: async (newCourse: LocalCourse) => {
|
|
||||||
await createCourseOnServer({ course: newCourse });
|
|
||||||
},
|
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({
|
utils.settings.allCoursesSettings.invalidate();
|
||||||
queryKey: localCourseKeys.allCoursesSettings,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useUpdateLocalCourseSettingsMutation = () => {
|
export const useUpdateLocalCourseSettingsMutation = () => {
|
||||||
const { courseName } = useCourseContext();
|
const { courseName } = useCourseContext();
|
||||||
const queryClient = useQueryClient();
|
const utils = trpc.useUtils();
|
||||||
return useMutation({
|
|
||||||
mutationFn: async (updatedSettings: LocalCourseSettings) => {
|
return trpc.settings.createCourse.useMutation({
|
||||||
// queryClient.setQueryData(
|
onSuccess: () => {
|
||||||
// localCourseKeys.settings(courseName),
|
utils.settings.allCoursesSettings.invalidate();
|
||||||
// updatedSettings
|
utils.settings.courseSettings.invalidate({ courseName });
|
||||||
// );
|
|
||||||
await updateCourseSettingsOnServer({
|
|
||||||
courseName,
|
|
||||||
settings: updatedSettings,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onSuccess: async () => {
|
|
||||||
await queryClient.invalidateQueries({
|
|
||||||
queryKey: localCourseKeys.allCoursesSettings,
|
|
||||||
});
|
|
||||||
await queryClient.invalidateQueries({
|
|
||||||
queryKey: localCourseKeys.settings(courseName),
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// export const useUpdateCourseMutation = (courseName: string) => {
|
|
||||||
// const queryClient = useQueryClient();
|
|
||||||
// return useMutation({
|
|
||||||
// mutationFn: async (body: {
|
|
||||||
// updatedCourse: LocalCourse;
|
|
||||||
// previousCourse: LocalCourse;
|
|
||||||
// }) => {
|
|
||||||
// const url = `/api/courses/${courseName}`;
|
|
||||||
// await axiosClient.put(url, body);
|
|
||||||
// },
|
|
||||||
// onSuccess: () => {
|
|
||||||
// queryClient.invalidateQueries({
|
|
||||||
// queryKey: localCourseKeys.settings(courseName),
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// scope: {
|
|
||||||
// id: "all courses",
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
"use server";
|
"use server";
|
||||||
import { LocalCourse, LocalCourseSettings } from "@/models/local/localCourse";
|
import {
|
||||||
|
LocalCourseSettings,
|
||||||
|
} from "@/models/local/localCourseSettings";
|
||||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||||
|
|
||||||
export async function getCourseSettingsFromServer({
|
export async function getCourseSettingsFromServer({
|
||||||
@@ -13,23 +15,23 @@ export async function getAllCoursesSettingsFromServer() {
|
|||||||
return await fileStorageService.settings.getAllCoursesSettings();
|
return await fileStorageService.settings.getAllCoursesSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createCourseOnServer({
|
// export async function createCourseOnServer({
|
||||||
course,
|
// course,
|
||||||
}: {
|
// }: {
|
||||||
course: LocalCourse;
|
// course: LocalCourse;
|
||||||
}) {
|
// }) {
|
||||||
await fileStorageService.settings.updateCourseSettings(
|
// await fileStorageService.settings.updateCourseSettings(
|
||||||
course.settings.name,
|
// course.settings.name,
|
||||||
course.settings
|
// course.settings
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
export async function updateCourseSettingsOnServer({
|
// export async function updateCourseSettingsOnServer({
|
||||||
courseName,
|
// courseName,
|
||||||
settings,
|
// settings,
|
||||||
}: {
|
// }: {
|
||||||
courseName: string;
|
// courseName: string;
|
||||||
settings: LocalCourseSettings;
|
// settings: LocalCourseSettings;
|
||||||
}) {
|
// }) {
|
||||||
await fileStorageService.settings.updateCourseSettings(courseName, settings);
|
// await fileStorageService.settings.updateCourseSettings(courseName, settings);
|
||||||
}
|
// }
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
export interface LocalAssignmentGroup {
|
export interface LocalAssignmentGroup {
|
||||||
canvasId?: number;
|
canvasId?: number;
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
weight: number;
|
weight: number;
|
||||||
}
|
}
|
||||||
|
export const zodLocalAssignmentGroup = z.object({
|
||||||
|
canvasId: z.number().optional(), // canvasId is optional
|
||||||
|
id: z.string(), // id is a required string
|
||||||
|
name: z.string(), // name is a required string
|
||||||
|
weight: z.number(), // weight is a required number
|
||||||
|
});
|
||||||
@@ -1,17 +1,48 @@
|
|||||||
import { AssignmentSubmissionType } from "./assignment/assignmentSubmissionType";
|
import { z } from "zod";
|
||||||
import { LocalAssignmentGroup } from "./assignment/localAssignmentGroup";
|
import {
|
||||||
|
AssignmentSubmissionType,
|
||||||
|
zodAssignmentSubmissionType,
|
||||||
|
} from "./assignment/assignmentSubmissionType";
|
||||||
|
import {
|
||||||
|
LocalAssignmentGroup,
|
||||||
|
zodLocalAssignmentGroup,
|
||||||
|
} from "./assignment/localAssignmentGroup";
|
||||||
import { LocalModule } from "./localModules";
|
import { LocalModule } from "./localModules";
|
||||||
import { parse, stringify } from "yaml";
|
import { parse, stringify } from "yaml";
|
||||||
|
|
||||||
export interface LocalCourse {
|
// export interface LocalCourse {
|
||||||
modules: LocalModule[];
|
// modules: LocalModule[];
|
||||||
settings: LocalCourseSettings;
|
// settings: LocalCourseSettings;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export interface SimpleTimeOnly {
|
export interface SimpleTimeOnly {
|
||||||
hour: number;
|
hour: number;
|
||||||
minute: number;
|
minute: number;
|
||||||
}
|
}
|
||||||
|
export const zodSimpleTimeOnly = z.object({
|
||||||
|
hour: z.number().int().min(0).max(23), // hour should be an integer between 0 and 23
|
||||||
|
minute: z.number().int().min(0).max(59), // minute should be an integer between 0 and 59
|
||||||
|
});
|
||||||
|
|
||||||
|
export enum DayOfWeek {
|
||||||
|
Sunday = "Sunday",
|
||||||
|
Monday = "Monday",
|
||||||
|
Tuesday = "Tuesday",
|
||||||
|
Wednesday = "Wednesday",
|
||||||
|
Thursday = "Thursday",
|
||||||
|
Friday = "Friday",
|
||||||
|
Saturday = "Saturday",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const zodDayOfWeek = z.enum([
|
||||||
|
DayOfWeek.Sunday,
|
||||||
|
DayOfWeek.Monday,
|
||||||
|
DayOfWeek.Tuesday,
|
||||||
|
DayOfWeek.Wednesday,
|
||||||
|
DayOfWeek.Thursday,
|
||||||
|
DayOfWeek.Friday,
|
||||||
|
DayOfWeek.Saturday,
|
||||||
|
]);
|
||||||
|
|
||||||
export interface LocalCourseSettings {
|
export interface LocalCourseSettings {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -30,15 +61,24 @@ export interface LocalCourseSettings {
|
|||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DayOfWeek {
|
export const zodLocalCourseSettings = z.object({
|
||||||
Sunday = "Sunday",
|
name: z.string(),
|
||||||
Monday = "Monday",
|
assignmentGroups: zodLocalAssignmentGroup.array(),
|
||||||
Tuesday = "Tuesday",
|
daysOfWeek: zodDayOfWeek.array(),
|
||||||
Wednesday = "Wednesday",
|
canvasId: z.number(),
|
||||||
Thursday = "Thursday",
|
startDate: z.string(),
|
||||||
Friday = "Friday",
|
endDate: z.string(),
|
||||||
Saturday = "Saturday",
|
defaultDueTime: zodSimpleTimeOnly,
|
||||||
}
|
defaultLockHoursOffset: z.number().int().optional(),
|
||||||
|
defaultAssignmentSubmissionTypes: zodAssignmentSubmissionType.array(),
|
||||||
|
defaultFileUploadTypes: z.string().array(),
|
||||||
|
holidays: z
|
||||||
|
.object({
|
||||||
|
name: z.string(),
|
||||||
|
days: z.string().array(),
|
||||||
|
})
|
||||||
|
.array(),
|
||||||
|
});
|
||||||
|
|
||||||
export function getDayOfWeek(date: Date): DayOfWeek {
|
export function getDayOfWeek(date: Date): DayOfWeek {
|
||||||
const dayIndex = date.getDay(); // Returns 0 for Sunday, 1 for Monday, etc.
|
const dayIndex = date.getDay(); // Returns 0 for Sunday, 1 for Monday, etc.
|
||||||
@@ -9,7 +9,10 @@ import {
|
|||||||
parseLecture,
|
parseLecture,
|
||||||
} from "./utils/lectureUtils";
|
} from "./utils/lectureUtils";
|
||||||
import { Lecture } from "@/models/local/lecture";
|
import { Lecture } from "@/models/local/lecture";
|
||||||
import { getDayOfWeek, LocalCourseSettings } from "@/models/local/localCourse";
|
import {
|
||||||
|
getDayOfWeek,
|
||||||
|
LocalCourseSettings,
|
||||||
|
} from "@/models/local/localCourseSettings";
|
||||||
import { getWeekNumber } from "@/app/course/[courseName]/calendar/calendarMonthUtils";
|
import { getWeekNumber } from "@/app/course/[courseName]/calendar/calendarMonthUtils";
|
||||||
import { getDateFromStringOrThrow } from "@/models/local/timeUtils";
|
import { getDateFromStringOrThrow } from "@/models/local/timeUtils";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
LocalCourseSettings,
|
LocalCourseSettings,
|
||||||
localCourseYamlUtils,
|
localCourseYamlUtils,
|
||||||
} from "@/models/local/localCourse";
|
} from "@/models/local/localCourseSettings";
|
||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { describe, it, expect, beforeEach } from "vitest";
|
import { describe, it, expect, beforeEach } from "vitest";
|
||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "fs";
|
||||||
import { DayOfWeek, LocalCourseSettings } from "@/models/local/localCourse";
|
import {
|
||||||
|
DayOfWeek,
|
||||||
|
LocalCourseSettings,
|
||||||
|
} from "@/models/local/localCourseSettings";
|
||||||
import { fileStorageService } from "../fileStorage/fileStorageService";
|
import { fileStorageService } from "../fileStorage/fileStorageService";
|
||||||
|
|
||||||
describe("FileStorageTests", () => {
|
describe("FileStorageTests", () => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import publicProcedure from "../procedures/public";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { router } from "../trpc";
|
import { router } from "../trpc";
|
||||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||||
|
import { zodLocalCourseSettings } from "@/models/local/localCourseSettings";
|
||||||
|
|
||||||
export const settingsRouter = router({
|
export const settingsRouter = router({
|
||||||
allCoursesSettings: publicProcedure.query(async () => {
|
allCoursesSettings: publicProcedure.query(async () => {
|
||||||
@@ -23,4 +24,29 @@ export const settingsRouter = router({
|
|||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}),
|
}),
|
||||||
|
createCourse: publicProcedure
|
||||||
|
.input(
|
||||||
|
z.object({
|
||||||
|
settings: zodLocalCourseSettings,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.mutation(async ({ input: { settings } }) => {
|
||||||
|
await fileStorageService.settings.updateCourseSettings(
|
||||||
|
settings.name,
|
||||||
|
settings
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
updateSettings: publicProcedure
|
||||||
|
.input(
|
||||||
|
z.object({
|
||||||
|
settings: zodLocalCourseSettings,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.mutation(async ({ input: { settings } }) => {
|
||||||
|
await fileStorageService.settings.updateCourseSettings(
|
||||||
|
settings.name,
|
||||||
|
settings
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,50 +1,4 @@
|
|||||||
import { createTRPCReact, httpBatchLink } from "@trpc/react-query";
|
import { createTRPCReact, httpBatchLink } from "@trpc/react-query";
|
||||||
import { createTRPCNext } from "@trpc/next";
|
|
||||||
import { ssrPrepass } from '@trpc/next/ssrPrepass';
|
|
||||||
import { AppRouter } from "./router/app";
|
import { AppRouter } from "./router/app";
|
||||||
import superjson from "superjson";
|
|
||||||
|
|
||||||
export const trpc = createTRPCReact<AppRouter>();
|
export const trpc = createTRPCReact<AppRouter>();
|
||||||
// export const trpc = createTRPCNext<AppRouter>({
|
|
||||||
// ssr: true,
|
|
||||||
// ssrPrepass,
|
|
||||||
// transformer: superjson,
|
|
||||||
// config(opts) {
|
|
||||||
// const { ctx } = opts;
|
|
||||||
// if (typeof window !== "undefined") {
|
|
||||||
// // during client requests
|
|
||||||
// return {
|
|
||||||
// links: [
|
|
||||||
// httpBatchLink({
|
|
||||||
// url: "/api/trpc",
|
|
||||||
// transformer: superjson,
|
|
||||||
// }),
|
|
||||||
// ],
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// return {
|
|
||||||
// links: [
|
|
||||||
// httpBatchLink({
|
|
||||||
// transformer: superjson,
|
|
||||||
// // The server needs to know your app's full url
|
|
||||||
// url: `http://localhost:3000/api/trpc`,
|
|
||||||
// /**
|
|
||||||
// * Set custom request headers on every request from tRPC
|
|
||||||
// * @see https://trpc.io/docs/v10/header
|
|
||||||
// */
|
|
||||||
// headers() {
|
|
||||||
// if (!ctx?.req?.headers) {
|
|
||||||
// return {};
|
|
||||||
// }
|
|
||||||
// // To use SSR properly, you need to forward client headers to the server
|
|
||||||
// // This is so you can pass through things like cookies when we're server-side rendering
|
|
||||||
// return {
|
|
||||||
// cookie: ctx.req.headers.cookie,
|
|
||||||
// };
|
|
||||||
// },
|
|
||||||
// }),
|
|
||||||
// ],
|
|
||||||
// };
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// export const trpcClient = trpc.createClient({ links: [] }); //server only?
|
|
||||||
|
|||||||
Reference in New Issue
Block a user