-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,392 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import ReactMarkdown from "react-markdown"; | ||
import Link from "next/link"; | ||
import type * as z from "zod"; | ||
|
||
import type { RouterOutputs } from "~/utils/api"; | ||
import type { ResourceConfiguation, ResourceType } from "@prisma/client"; | ||
import { use, useMemo } from "react"; | ||
import { lessonPlanCreateSchema, type resourceCreateSchema } from "~/utils/zod"; | ||
import { ScrollArea } from "~/components/ui/scroll-area"; | ||
import { Separator } from "./ui/separator"; | ||
|
||
type ApiLessonPlan = Readonly<RouterOutputs["lessonPlan"]["getById"]>; | ||
type CreationLessonPlan = z.infer<typeof lessonPlanCreateSchema>; | ||
type LessonPlanUnion = ApiLessonPlan | CreationLessonPlan; | ||
|
||
type Props = { | ||
lessonPlan: LessonPlanUnion; | ||
}; | ||
export function SingleLessonPlanComponent({ lessonPlan }: Props) { | ||
const isPreviewItem = ( | ||
item: LessonPlanUnion["sections"][0]["items"][0], | ||
): item is CreationLessonPlan["sections"][0]["items"][0] => { | ||
return !!item.resource && "label" in item.resource; | ||
}; | ||
|
||
return ( | ||
<div className="prose dark:prose-invert"> | ||
<p>{lessonPlan.description}</p> | ||
{lessonPlan.sections.map((section, index) => ( | ||
<div key={index}> | ||
<h2>{section.title}</h2> | ||
{section.items.map((item, itemIndex) => ( | ||
<div key={itemIndex}> | ||
{isPreviewItem(item) | ||
? item.resource?.label | ||
: item.resource?.title} | ||
- {item.text} | ||
</div> | ||
))} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.