mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-27 07:58:31 -06:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
"use client";
|
|
import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks";
|
|
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
|
|
import { getWeekNumber } from "./calendarMonthUtils";
|
|
import Day from "./day/Day";
|
|
|
|
export function CalendarWeek({
|
|
week,
|
|
monthNumber,
|
|
}: {
|
|
week: string[]; //date strings
|
|
monthNumber: number;
|
|
}) {
|
|
const [settings]= useLocalCourseSettingsQuery();
|
|
const startDate = getDateFromStringOrThrow(
|
|
settings.startDate,
|
|
"week calculation start date"
|
|
);
|
|
const firstDateString = getDateFromStringOrThrow(
|
|
week[0],
|
|
"week calculation first day of week"
|
|
);
|
|
const weekNumber = getWeekNumber(startDate, firstDateString);
|
|
return (
|
|
<div className="flex flex-row">
|
|
<div className="my-auto text-gray-400 w-6 text-center flex-none sm:block hidden">
|
|
{weekNumber.toString().padStart(2, "0")}
|
|
</div>
|
|
<div className="grid grid-cols-7 grow">
|
|
{week.map((day, dayIndex) => (
|
|
<Day key={dayIndex} day={day} month={monthNumber} />
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|