more refactor

This commit is contained in:
2025-07-23 09:54:11 -06:00
parent 3e371247d6
commit 1885431574
69 changed files with 158 additions and 142 deletions

View File

@@ -3,7 +3,7 @@ import { CalendarMonthModel, getWeekNumber } from "./calendarMonthUtils";
import { Expandable } from "@/components/Expandable";
import { CalendarWeek } from "./CalendarWeek";
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
import UpChevron from "@/components/icons/UpChevron";
import DownChevron from "@/components/icons/DownChevron";
import { DayOfWeek } from "@/features/local/course/localCourseSettings";

View File

@@ -1,6 +1,6 @@
"use client";
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
import { getWeekNumber } from "./calendarMonthUtils";
import Day from "./day/Day";

View File

@@ -1,5 +1,5 @@
"use client";
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
import { getMonthsBetweenDates } from "./calendarMonthUtils";
import { CalendarMonth } from "./CalendarMonth";
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";

View File

@@ -1,7 +1,7 @@
import {
dateToMarkdownString,
getDateFromStringOrThrow,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
export interface CalendarMonthModel {
year: number;

View File

@@ -2,7 +2,7 @@
import {
getDateFromStringOrThrow,
getDateOnlyMarkdownString,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
import { useDraggingContext } from "../../context/drag/draggingContext";
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
import { ItemInDay } from "./ItemInDay";

View File

@@ -5,7 +5,7 @@ import { useCourseContext } from "../../context/courseContext";
import NewItemForm from "../../modules/NewItemForm";
import { DraggableItem } from "../../context/drag/draggingContext";
import { useDragStyleContext } from "../../context/drag/dragStyleContext";
import { getLectureForDay } from "@/models/local/utils/lectureUtils";
import { getLectureForDay } from "@/features/local/utils/lectureUtils";
import { useLecturesSuspenseQuery } from "@/features/local/lectures/lectureHooks";
import ClientOnly from "@/components/ClientOnly";
import { Tooltip } from "@/components/Tooltip";

View File

@@ -6,7 +6,7 @@ import { LocalAssignment } from "@/features/local/assignments/models/localAssign
import {
dateToMarkdownString,
getDateFromStringOrThrow,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
import { markdownToHTMLSafe } from "@/services/htmlMarkdownUtils";
import { htmlIsCloseEnough } from "@/services/utils/htmlIsCloseEnough";
import { ReactNode } from "react";

View File

@@ -6,7 +6,7 @@ import { LocalAssignment } from "@/features/local/assignments/models/localAssign
import {
getDateFromStringOrThrow,
getDateOnlyMarkdownString,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
import { ReactNode } from "react";
import { useCalendarItemsContext } from "../../context/calendarItemsContext";
import { getStatus } from "./getStatus";

View File

@@ -1,6 +1,8 @@
"use client";
import { getDateFromStringOrThrow, dateToMarkdownString } from "@/models/local/utils/timeUtils";
import {
getDateFromStringOrThrow,
dateToMarkdownString,
} from "@/features/local/utils/timeUtils";
export function getNewLockDate(
originalDueDate: string,
@@ -9,15 +11,18 @@ export function getNewLockDate(
): string | undefined {
// todo: preserve previous due date / lock date offset
const dueDate = getDateFromStringOrThrow(originalDueDate, "dueAt date");
const lockDate = originalLockDate === undefined
? undefined
: getDateFromStringOrThrow(originalLockDate, "lockAt date");
const lockDate =
originalLockDate === undefined
? undefined
: getDateFromStringOrThrow(originalLockDate, "lockAt date");
const originalOffset = lockDate === undefined ? undefined : lockDate.getTime() - dueDate.getTime();
const originalOffset =
lockDate === undefined ? undefined : lockDate.getTime() - dueDate.getTime();
const newLockDate = originalOffset === undefined
? undefined
: new Date(dayAsDate.getTime() + originalOffset);
const newLockDate =
originalOffset === undefined
? undefined
: new Date(dayAsDate.getTime() + originalOffset);
return newLockDate === undefined
? undefined

View File

@@ -7,12 +7,12 @@ import { useLocalCourseSettingsQuery } from "@/features/local/course/localCourse
import { useUpdatePageMutation } from "@/features/local/pages/pageHooks";
import { LocalAssignment } from "@/features/local/assignments/models/localAssignment";
import { Lecture } from "@/features/local/lectures/lectureModel";
import { getLectureForDay } from "@/models/local/utils/lectureUtils";
import { getLectureForDay } from "@/features/local/utils/lectureUtils";
import {
getDateFromStringOrThrow,
getDateOnlyMarkdownString,
dateToMarkdownString,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
import { Dispatch, SetStateAction, useCallback, DragEvent } from "react";
import { DraggableItem } from "./draggingContext";
import { getNewLockDate } from "./getNewLockDate";

View File

@@ -1,5 +1,5 @@
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
import { getDateFromString } from "@/models/local/utils/timeUtils";
import { getDateFromString } from "@/features/local/utils/timeUtils";
import { getLectureWeekName } from "@/services/fileStorage/utils/lectureUtils";
import { getCourseUrl, getLecturePreviewUrl } from "@/services/urlUtils";
import { useCourseContext } from "../../context/courseContext";

View File

@@ -2,7 +2,7 @@ import EditLecture from "./EditLecture";
import {
getDateFromStringOrThrow,
getDateOnlyMarkdownString,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
export const dynamic = "force-dynamic";
export default async function page({

View File

@@ -1,7 +1,7 @@
import {
getDateFromStringOrThrow,
getDateOnlyMarkdownString,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
import LecturePreviewPage from "./LecturePreviewPage";
export const dynamic = "force-dynamic";

View File

@@ -5,7 +5,7 @@ import {
getDateFromString,
getDateFromStringOrThrow,
getDateOnlyMarkdownString,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
import { Fragment } from "react";
import Modal, { useModal } from "../../../../components/Modal";
import NewItemForm from "./NewItemForm";

View File

@@ -15,7 +15,7 @@ import {
getDateFromString,
dateToMarkdownString,
getDateFromStringOrThrow,
} from "@/models/local/utils/timeUtils";
} from "@/features/local/utils/timeUtils";
import { useCreateAssignmentMutation } from "@/features/local/assignments/assignmentHooks";
export default function NewItemForm({

View File

@@ -6,12 +6,12 @@ import {
useLocalCourseSettingsQuery,
useUpdateLocalCourseSettingsMutation,
} from "@/features/local/course/localCoursesHooks";
import { getDateFromString } from "@/models/local/utils/timeUtils";
import { getDateFromString } from "@/features/local/utils/timeUtils";
import { useEffect, useState } from "react";
import {
holidaysToString,
parseHolidays,
} from "../../../../models/local/utils/settingsUtils";
} from "../../../../features/local/utils/settingsUtils";
import { settingsBox } from "./sharedSettings";
const exampleString = `springBreak:

View File

@@ -1,6 +1,6 @@
"use client";
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
import { getDateOnlyMarkdownString } from "@/models/local/utils/timeUtils";
import { getDateOnlyMarkdownString } from "@/features/local/utils/timeUtils";
import React from "react";
import { settingsBox } from "./sharedSettings";