diff --git a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx index 043ff1a..299eca8 100644 --- a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx @@ -1,15 +1,31 @@ "use client"; -import { CalendarMonthModel } from "./calendarMonthUtils"; +import { CalendarMonthModel, getWeekNumber } from "./calendarMonthUtils"; import { DayOfWeek } from "@/models/local/localCourseSettings"; import { Expandable } from "@/components/Expandable"; import { CalendarWeek } from "./CalendarWeek"; +import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks"; +import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils"; export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => { // const weekInMilliseconds = 604_800_000; const four_days_in_milliseconds = 345_600_000; - const isInPast = - new Date(month.year, month.month, 1) < - new Date(Date.now() - four_days_in_milliseconds); + const [settings] = useLocalCourseSettingsQuery(); + const startDate = getDateFromStringOrThrow( + settings.startDate, + "week calculation start date" + ); + + const pastWeekNumber = getWeekNumber( + startDate, + new Date(Date.now() - four_days_in_milliseconds) + ); + + const startOfMonthWeekNumber = getWeekNumber( + startDate, + new Date(month.year, month.month, 1) + ); + + const isInPast = pastWeekNumber >= startOfMonthWeekNumber; const monthName = new Date(month.year, month.month - 1, 1).toLocaleString( "default", diff --git a/nextjs/src/services/serverFunctions/TrpcProvider.tsx b/nextjs/src/services/serverFunctions/TrpcProvider.tsx index 315e180..2443c13 100644 --- a/nextjs/src/services/serverFunctions/TrpcProvider.tsx +++ b/nextjs/src/services/serverFunctions/TrpcProvider.tsx @@ -19,6 +19,7 @@ export default function TrpcProvider({ httpBatchLink({ url, transformer: superjson, + maxURLLength: 10_000, // limit number of batched requests }), ], }) diff --git a/nextjs/src/services/serverFunctions/router/assignmentRouter.ts b/nextjs/src/services/serverFunctions/router/assignmentRouter.ts index 6e58891..5cda91b 100644 --- a/nextjs/src/services/serverFunctions/router/assignmentRouter.ts +++ b/nextjs/src/services/serverFunctions/router/assignmentRouter.ts @@ -14,11 +14,13 @@ export const assignmentRouter = router({ }) ) .query(async ({ input: { courseName, moduleName, assignmentName } }) => { - return await fileStorageService.assignments.getAssignment( + const assignment = await fileStorageService.assignments.getAssignment( courseName, moduleName, assignmentName ); + // console.log(assignment); + return assignment; }), getAllAssignments: publicProcedure .input( @@ -28,10 +30,11 @@ export const assignmentRouter = router({ }) ) .query(async ({ input: { courseName, moduleName } }) => { - return await fileStorageService.assignments.getAssignments( + const assignments = await fileStorageService.assignments.getAssignments( courseName, moduleName ); + return assignments; }), createAssignment: publicProcedure .input(