mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
moving v2 to top level
This commit is contained in:
51
src/services/serverFunctions/router/lectureRouter.ts
Normal file
51
src/services/serverFunctions/router/lectureRouter.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { z } from "zod";
|
||||
import publicProcedure from "../procedures/public";
|
||||
import { router } from "../trpcSetup";
|
||||
import {
|
||||
deleteLecture,
|
||||
getLectures,
|
||||
updateLecture,
|
||||
} from "@/services/fileStorage/lectureFileStorageService";
|
||||
import { zodLecture } from "@/models/local/lecture";
|
||||
import { zodLocalCourseSettings } from "@/models/local/localCourseSettings";
|
||||
|
||||
export const lectureRouter = router({
|
||||
getLectures: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
courseName: z.string(),
|
||||
})
|
||||
)
|
||||
.query(async ({ input: { courseName } }) => {
|
||||
return await getLectures(courseName);
|
||||
}),
|
||||
updateLecture: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
courseName: z.string(),
|
||||
lecture: zodLecture,
|
||||
previousDay: z.string().optional(),
|
||||
settings: zodLocalCourseSettings,
|
||||
})
|
||||
)
|
||||
.mutation(
|
||||
async ({ input: { courseName, settings, lecture, previousDay } }) => {
|
||||
await updateLecture(courseName, settings, lecture);
|
||||
|
||||
if (previousDay && previousDay !== lecture.date) {
|
||||
await deleteLecture(courseName, settings, previousDay);
|
||||
}
|
||||
}
|
||||
),
|
||||
deleteLecture: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
courseName: z.string(),
|
||||
lectureDay: z.string(),
|
||||
settings: zodLocalCourseSettings,
|
||||
})
|
||||
)
|
||||
.mutation(async ({ input: { courseName, settings, lectureDay } }) => {
|
||||
await deleteLecture(courseName, settings, lectureDay);
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user