diff --git a/apps/nextjs/src/components/AppComponents/Chat/Chat/hooks/useProgressForDownloads.ts b/apps/nextjs/src/components/AppComponents/Chat/Chat/hooks/useProgressForDownloads.ts index 145ff171e..4f3786afd 100644 --- a/apps/nextjs/src/components/AppComponents/Chat/Chat/hooks/useProgressForDownloads.ts +++ b/apps/nextjs/src/components/AppComponents/Chat/Chat/hooks/useProgressForDownloads.ts @@ -1,9 +1,26 @@ import { useMemo } from "react"; -import type { LooseLessonPlan } from "@oakai/aila/src/protocol/schema"; +import type { + LessonPlanKeys, + LooseLessonPlan, +} from "@oakai/aila/src/protocol/schema"; import { lessonPlanSectionsSchema } from "@oakai/exports/src/schema/input.schema"; import type { ZodIssue } from "zod"; +export type ProgressForDownloads = { + sections: ProgressSection[]; + totalSections: number; + totalSectionsComplete: number; +}; + +export type ProgressSection = { + label: string; + key: LessonPlanKeys; + complete: boolean; +}; + +export type ProgressSections = ProgressSection[]; + /** * For a given list of Zod issues and lessonPlan fields, checks that none of * the errors pertain to the fields. @@ -16,16 +33,6 @@ function getCompleteness(errors: ZodIssue[], fields: string[]) { return !hasErrorInSomeField; } -export type ProgressSections = { - label: string; - key: string; - complete: boolean; -}[]; -type ProgressForDownloads = { - sections: ProgressSections; - totalSections: number; - totalSectionsComplete: number; -}; export function useProgressForDownloads({ lessonPlan, @@ -60,7 +67,8 @@ export function useProgressForDownloads({ return true; } }) ?? []; - const sections = [ + + const sections: ProgressSection[] = [ { label: "Lesson details", key: "title", diff --git a/apps/nextjs/src/components/AppComponents/Chat/chat-right-hand-side-lesson.tsx b/apps/nextjs/src/components/AppComponents/Chat/chat-right-hand-side-lesson.tsx index 5be3e7430..8a7fa2b7b 100644 --- a/apps/nextjs/src/components/AppComponents/Chat/chat-right-hand-side-lesson.tsx +++ b/apps/nextjs/src/components/AppComponents/Chat/chat-right-hand-side-lesson.tsx @@ -1,5 +1,7 @@ import React, { useRef, useState } from "react"; +import type { LessonPlanKeys } from "@oakai/aila/src/protocol/schema"; + import { useLessonChat } from "@/components/ContextProviders/ChatProvider"; import AiIcon from "../../AiIcon"; @@ -30,7 +32,9 @@ const ChatRightHandSideLesson = ({ const [showScrollButton, setShowScrollButton] = useState(false); // This retains this existing bug, but is fixed on subsequent PRs - const sectionRefs = {}; + const sectionRefs: Partial< + Record> + > = {}; const scrollToBottom = () => { if (chatEndRef.current) { @@ -57,7 +61,7 @@ const ChatRightHandSideLesson = ({ return (
1 && showLessonMobile ? "flex" : "hidden"} fixed bottom-20 left-0 right-0 items-center justify-center duration-150 sm:hidden`} + className={`${messages.length > 1 && showLessonMobile ? "flex" : "hidden"} fixed bottom-20 left-0 right-0 items-center justify-center duration-150 sm:hidden`} > >; + sectionRefs: Partial< + Record> + >; documentContainerRef: React.MutableRefObject; }>; @@ -61,10 +66,10 @@ export const LessonPlanProgressDropdown: React.FC< disabled={!complete} className="mb-7 flex gap-6" onClick={() => { - if (key === "cycles" && complete) { - if (sectionRefs["cycle-1"]) { + if (key === "cycle1" && complete) { + if (sectionRefs["cycle1"]) { scrollToRef({ - ref: sectionRefs["cycle-1"], + ref: sectionRefs["cycle1"], containerRef: documentContainerRef, }); } diff --git a/apps/nextjs/src/components/AppComponents/Chat/export-buttons/index.tsx b/apps/nextjs/src/components/AppComponents/Chat/export-buttons/index.tsx index 671e9ee56..e639b2dc1 100644 --- a/apps/nextjs/src/components/AppComponents/Chat/export-buttons/index.tsx +++ b/apps/nextjs/src/components/AppComponents/Chat/export-buttons/index.tsx @@ -1,5 +1,6 @@ "use client"; +import type { LessonPlanKeys } from "@oakai/aila/src/protocol/schema"; import { OakSmallSecondaryButton } from "@oaknational/oak-components"; import Link from "next/link"; @@ -11,7 +12,9 @@ import { useDialog } from "../../DialogContext"; import { LessonPlanProgressDropdown } from "./LessonPlanProgressDropdown"; export type ExportButtonsProps = Readonly<{ - sectionRefs: Record>; + sectionRefs: Partial< + Record> + >; documentContainerRef: React.MutableRefObject; }>; @@ -26,7 +29,7 @@ const ExportButtons = ({ const demo = useDemoUser(); return ( -
+