From c47d7405c275de2dc46c3bb233753292e2819ff5 Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Fri, 8 Nov 2024 16:28:14 -0700 Subject: [PATCH] doing more trpc, still working on preloading --- nextjs/package.json | 1 - nextjs/pnpm-lock.yaml | 30 ------- nextjs/src/app/CourseList.tsx | 2 +- .../[courseName]/calendar/CalendarMonth.tsx | 2 +- .../course/[courseName]/calendar/day/Day.tsx | 2 +- .../lecture/[lectureDay]/EditLectureTitle.tsx | 2 +- .../lecture/[lectureDay]/layout.tsx | 5 +- .../lecture/[lectureDay]/page.tsx | 7 +- .../lecture/[lectureDay]/preview/page.tsx | 7 +- .../[assignmentName]/EditAssignment.tsx | 2 +- .../assignment/[assignmentName]/page.tsx | 8 +- .../[moduleName]/page/[pageName]/page.tsx | 5 +- .../[moduleName]/quiz/[quizName]/page.tsx | 5 +- nextjs/src/app/newCourse/NewCourseForm.tsx | 7 +- .../src/app/todaysLectures/TodaysLectures.tsx | 2 +- nextjs/src/components/TimePicker.tsx | 2 +- nextjs/src/components/form/DayOfWeekInput.tsx | 8 +- nextjs/src/hooks/hookHydration.ts | 3 +- .../localCourse/localCourseModuleHooks.ts | 10 ++- .../hooks/localCourse/localCoursesHooks.ts | 89 +++---------------- .../localCourse/localCoursesServerActions.ts | 42 ++++----- .../local/assignment/localAssignmentGroup.ts | 10 ++- ...{localCourse.ts => localCourseSettings.ts} | 70 +++++++++++---- .../fileStorage/lectureFileStorageService.ts | 5 +- .../fileStorage/settingsFileStorageService.ts | 2 +- nextjs/src/services/tests/fileStorage.test.ts | 5 +- .../services/trpc/router/settingsRouter.ts | 26 ++++++ nextjs/src/services/trpc/utils.ts | 46 ---------- 28 files changed, 175 insertions(+), 230 deletions(-) rename nextjs/src/models/local/{localCourse.ts => localCourseSettings.ts} (58%) diff --git a/nextjs/package.json b/nextjs/package.json index a57f2b5..a1af495 100644 --- a/nextjs/package.json +++ b/nextjs/package.json @@ -13,7 +13,6 @@ "@next/env": "^15.0.3", "@tanstack/react-query": "^5.59.20", "@trpc/client": "11.0.0-rc.608", - "@trpc/next": "11.0.0-rc.608", "@trpc/react-query": "11.0.0-rc.608", "@trpc/server": "11.0.0-rc.608", "jsdom": "^25.0.0", diff --git a/nextjs/pnpm-lock.yaml b/nextjs/pnpm-lock.yaml index db32792..95950bb 100644 --- a/nextjs/pnpm-lock.yaml +++ b/nextjs/pnpm-lock.yaml @@ -17,9 +17,6 @@ importers: '@trpc/client': specifier: 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': 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) @@ -721,22 +718,6 @@ packages: peerDependencies: '@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': resolution: {integrity: sha512-V0UJltzCfdn3PqePqbB8TK64aNXVBpdoLEC4OdMtTYiZTsAnH1jTwrNOBji3Xwm8Q0n4jaUDrIz5M/5IPjYrGg==} peerDependencies: @@ -3075,17 +3056,6 @@ snapshots: dependencies: '@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)': dependencies: '@tanstack/react-query': 5.59.20(react@18.3.1) diff --git a/nextjs/src/app/CourseList.tsx b/nextjs/src/app/CourseList.tsx index bb7ecd5..99137e0 100644 --- a/nextjs/src/app/CourseList.tsx +++ b/nextjs/src/app/CourseList.tsx @@ -4,7 +4,7 @@ import { getCourseUrl } from "@/services/urlUtils"; import Link from "next/link"; export default function CourseList() { - const { data: allSettings } = useLocalCoursesSettingsQuery(); + const [allSettings] = useLocalCoursesSettingsQuery(); return (
diff --git a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx index 2374194..043ff1a 100644 --- a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx @@ -1,6 +1,6 @@ "use client"; import { CalendarMonthModel } from "./calendarMonthUtils"; -import { DayOfWeek } from "@/models/local/localCourse"; +import { DayOfWeek } from "@/models/local/localCourseSettings"; import { Expandable } from "@/components/Expandable"; import { CalendarWeek } from "./CalendarWeek"; diff --git a/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx b/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx index a2f1328..d6c3309 100644 --- a/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx @@ -5,7 +5,7 @@ import { } from "@/models/local/timeUtils"; import { useDraggingContext } from "../../context/drag/draggingContext"; import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks"; -import { getDayOfWeek } from "@/models/local/localCourse"; +import { getDayOfWeek } from "@/models/local/localCourseSettings"; import { ItemInDay } from "./ItemInDay"; import { useTodaysItems } from "./useTodaysItems"; import { DayTitle } from "./DayTitle"; diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLectureTitle.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLectureTitle.tsx index 6621a95..1637340 100644 --- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLectureTitle.tsx +++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/EditLectureTitle.tsx @@ -1,5 +1,5 @@ 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 { getLectureWeekName } from "@/services/fileStorage/utils/lectureUtils"; import { getCourseUrl, getLecturePreviewUrl } from "@/services/urlUtils"; diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/layout.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/layout.tsx index 29538b3..8261553 100644 --- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/layout.tsx +++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/layout.tsx @@ -3,11 +3,12 @@ import CourseContextProvider from "../../context/CourseContextProvider"; export default async function LectureLayout({ children, - params: { courseName, lectureDay }, + params, }: { children: React.ReactNode; - params: { courseName: string; lectureDay: string }; + params: Promise<{ courseName: string; lectureDay: string }>; }) { + const { courseName, lectureDay } = await params; const decodedCourseName = decodeURIComponent(courseName); if (courseName.includes(".js.map")) { console.log("cannot load course that is .js.map " + decodedCourseName); diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/page.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/page.tsx index b164960..77c3801 100644 --- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/page.tsx +++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/page.tsx @@ -4,11 +4,12 @@ import { getDateOnlyMarkdownString, } from "@/models/local/timeUtils"; -export default function page({ - params: { lectureDay }, +export default async function page({ + params, }: { - params: { lectureDay: string }; + params: Promise<{ lectureDay: string }>; }) { + const { lectureDay } = await params; const decodedLectureDay = decodeURIComponent(lectureDay); console.log(decodedLectureDay); const lectureDate = getDateFromStringOrThrow( diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/page.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/page.tsx index 5c291a0..53ad0f6 100644 --- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/page.tsx +++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/page.tsx @@ -4,11 +4,12 @@ import { } from "@/models/local/timeUtils"; import LecturePreviewPage from "./LecturePreviewPage"; -export default function Page({ - params: { lectureDay }, +export default async function Page({ + params, }: { - params: { lectureDay: string }; + params: Promise<{ lectureDay: string }>; }) { + const { lectureDay } = await params; const decodedLectureDay = decodeURIComponent(lectureDay); console.log(decodedLectureDay); const lectureDate = getDateFromStringOrThrow( diff --git a/nextjs/src/app/course/[courseName]/modules/[moduleName]/assignment/[assignmentName]/EditAssignment.tsx b/nextjs/src/app/course/[courseName]/modules/[moduleName]/assignment/[assignmentName]/EditAssignment.tsx index cd4fd68..f2515d4 100644 --- a/nextjs/src/app/course/[courseName]/modules/[moduleName]/assignment/[assignmentName]/EditAssignment.tsx +++ b/nextjs/src/app/course/[courseName]/modules/[moduleName]/assignment/[assignmentName]/EditAssignment.tsx @@ -13,7 +13,7 @@ import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHoo import ClientOnly from "@/components/ClientOnly"; import { SuspenseAndErrorHandling } from "@/components/SuspenseAndErrorHandling"; 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 { AssignmentButtons } from "./AssignmentButtons"; diff --git a/nextjs/src/app/course/[courseName]/modules/[moduleName]/assignment/[assignmentName]/page.tsx b/nextjs/src/app/course/[courseName]/modules/[moduleName]/assignment/[assignmentName]/page.tsx index 3fbf7d4..1e58658 100644 --- a/nextjs/src/app/course/[courseName]/modules/[moduleName]/assignment/[assignmentName]/page.tsx +++ b/nextjs/src/app/course/[courseName]/modules/[moduleName]/assignment/[assignmentName]/page.tsx @@ -1,12 +1,12 @@ import React from "react"; import EditAssignment from "./EditAssignment"; -import ClientOnly from "@/components/ClientOnly"; -export default function Page({ - params: { moduleName, assignmentName }, +export default async function Page({ + params, }: { - params: { assignmentName: string; moduleName: string }; + params: Promise<{ assignmentName: string; moduleName: string }>; }) { + const { moduleName, assignmentName } = await params; const decodedAssignmentName = decodeURIComponent(assignmentName); const decodedModuleName = decodeURIComponent(moduleName); return ( diff --git a/nextjs/src/app/course/[courseName]/modules/[moduleName]/page/[pageName]/page.tsx b/nextjs/src/app/course/[courseName]/modules/[moduleName]/page/[pageName]/page.tsx index aaa1205..5a8a9fe 100644 --- a/nextjs/src/app/course/[courseName]/modules/[moduleName]/page/[pageName]/page.tsx +++ b/nextjs/src/app/course/[courseName]/modules/[moduleName]/page/[pageName]/page.tsx @@ -2,10 +2,11 @@ import React from "react"; import EditPage from "./EditPage"; 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 decodedModuleName = decodeURIComponent(moduleName); return ; diff --git a/nextjs/src/app/course/[courseName]/modules/[moduleName]/quiz/[quizName]/page.tsx b/nextjs/src/app/course/[courseName]/modules/[moduleName]/quiz/[quizName]/page.tsx index 7781cb2..18cef08 100644 --- a/nextjs/src/app/course/[courseName]/modules/[moduleName]/quiz/[quizName]/page.tsx +++ b/nextjs/src/app/course/[courseName]/modules/[moduleName]/quiz/[quizName]/page.tsx @@ -2,10 +2,11 @@ import React from "react"; import EditQuiz from "./EditQuiz"; 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 decodedModuleName = decodeURIComponent(moduleName) return ; diff --git a/nextjs/src/app/newCourse/NewCourseForm.tsx b/nextjs/src/app/newCourse/NewCourseForm.tsx index e23ae23..7c6511b 100644 --- a/nextjs/src/app/newCourse/NewCourseForm.tsx +++ b/nextjs/src/app/newCourse/NewCourseForm.tsx @@ -13,7 +13,7 @@ import { useEmptyDirectoriesQuery } from "@/hooks/localCourse/storageDirectoryHo import { CanvasCourseModel } from "@/models/canvas/courses/canvasCourseModel"; import { CanvasEnrollmentTermModel } from "@/models/canvas/enrollmentTerms/canvasEnrollmentTermModel"; 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 { useRouter } from "next/navigation"; import React, { useMemo, useState } from "react"; @@ -81,7 +81,6 @@ export default function NewCourseForm() { if (formIsComplete) { createCourse .mutateAsync({ - modules: [], settings: { name: selectedDirectory, assignmentGroups: [], @@ -96,7 +95,7 @@ export default function NewCourseForm() { ], defaultFileUploadTypes: ["pdf", "png", "jpg", "jpeg"], defaultLockHoursOffset: 0, - holidays: [] + holidays: [], }, }) .then(() => { @@ -140,7 +139,7 @@ function OtherSettings({ setSelectedDaysOfWeek: React.Dispatch>; }) { const { data: canvasCourses } = useCourseListInTermQuery(selectedTerm.id); - const { data: allSettings } = useLocalCoursesSettingsQuery(); + const [allSettings] = useLocalCoursesSettingsQuery(); const { data: emptyDirectories } = useEmptyDirectoriesQuery(); const populatedCanvasCourseIds = allSettings.map((s) => s.canvasId); diff --git a/nextjs/src/app/todaysLectures/TodaysLectures.tsx b/nextjs/src/app/todaysLectures/TodaysLectures.tsx index f843acd..3cc9aca 100644 --- a/nextjs/src/app/todaysLectures/TodaysLectures.tsx +++ b/nextjs/src/app/todaysLectures/TodaysLectures.tsx @@ -7,7 +7,7 @@ import CourseContextProvider from "../course/[courseName]/context/CourseContextP import { Fragment } from "react"; export default function TodaysLectures() { - const { data: allSettings } = useLocalCoursesSettingsQuery(); + const [allSettings] = useLocalCoursesSettingsQuery(); return (
{/*

todays lectures

*/} diff --git a/nextjs/src/components/TimePicker.tsx b/nextjs/src/components/TimePicker.tsx index be164f4..05ad51d 100644 --- a/nextjs/src/components/TimePicker.tsx +++ b/nextjs/src/components/TimePicker.tsx @@ -1,5 +1,5 @@ "use client"; -import { SimpleTimeOnly } from "@/models/local/localCourse"; +import { SimpleTimeOnly } from "@/models/local/localCourseSettings"; import { FC, useState, useEffect } from "react"; export const TimePicker: FC<{ diff --git a/nextjs/src/components/form/DayOfWeekInput.tsx b/nextjs/src/components/form/DayOfWeekInput.tsx index 01c62f4..72026c3 100644 --- a/nextjs/src/components/form/DayOfWeekInput.tsx +++ b/nextjs/src/components/form/DayOfWeekInput.tsx @@ -1,4 +1,4 @@ -import { DayOfWeek } from "@/models/local/localCourse"; +import { DayOfWeek } from "@/models/local/localCourseSettings"; export function DayOfWeekInput({ selectedDays, @@ -15,11 +15,7 @@ export function DayOfWeekInput({