Align header, footer, brand, homepage course preview, faculty links, and the course catalog with the documented changes. Co-authored-by: Cursor <cursoragent@cursor.com>
197 lines
6.9 KiB
TypeScript
197 lines
6.9 KiB
TypeScript
import Image from "next/image";
|
|
import Link from "next/link";
|
|
import { ArrowUpLeft, Clock, Layers, Wallet } from "lucide-react";
|
|
import { Container } from "@/components/atoms/Container";
|
|
import { Heading } from "@/components/atoms/Heading";
|
|
import { Section } from "@/components/atoms/Section";
|
|
import { TextLink } from "@/components/atoms/TextLink";
|
|
import { DetailList, type DetailItem } from "@/components/molecules/DetailList";
|
|
import { PageHero } from "@/components/molecules/PageHero";
|
|
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
|
import { CourseRegisterGate } from "@/components/organisms/CourseRegisterGate";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import type { Course } from "@/lib/types";
|
|
import { courseCategoryHref, courseTagHref } from "@/lib/course-nav";
|
|
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
|
import { JsonLd, courseJsonLd } from "@/lib/seo/json-ld";
|
|
|
|
export type CourseDetailLabels = {
|
|
submit: string;
|
|
success: string;
|
|
cta: string;
|
|
formTitle: string;
|
|
formDescription: string;
|
|
hint: string;
|
|
cancel: string;
|
|
backToCatalog: string;
|
|
detailsTitle: string;
|
|
aboutTitle: string;
|
|
duration: string;
|
|
format: string;
|
|
category: string;
|
|
price: string;
|
|
priceUnset: string;
|
|
};
|
|
|
|
export function CourseDetailTemplate({
|
|
course,
|
|
labels,
|
|
}: {
|
|
course: Course;
|
|
labels: CourseDetailLabels;
|
|
}) {
|
|
const priceLabel = formatCoursePrice(course.price);
|
|
const instructors = course.instructors ?? [];
|
|
const details: DetailItem[] = [
|
|
{ icon: Layers, label: labels.format, value: formatLabel(course.format) },
|
|
...(course.durationHours
|
|
? [
|
|
{
|
|
icon: Clock,
|
|
label: labels.duration,
|
|
value: `${course.durationHours} ساعت`,
|
|
},
|
|
]
|
|
: []),
|
|
{
|
|
icon: Wallet,
|
|
label: labels.price,
|
|
value: priceLabel ?? labels.priceUnset,
|
|
emphasis: Boolean(priceLabel),
|
|
},
|
|
];
|
|
const hasTaxonomy = course.categories.length > 0 || course.tags.length > 0;
|
|
|
|
return (
|
|
<main id="main-content">
|
|
<JsonLd data={courseJsonLd(course)} />
|
|
<PageHero
|
|
title={course.title}
|
|
intro={course.summary}
|
|
eyebrow={course.categories[0]?.label ?? course.tags[0]?.label}
|
|
imageUrl={course.posterImageUrl}
|
|
/>
|
|
|
|
<Section tone="subtle">
|
|
<Container className="grid min-w-0 gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,22rem)] lg:items-start lg:gap-12">
|
|
<div className="min-w-0 space-y-10">
|
|
<div className="relative aspect-[16/9] overflow-hidden rounded-2xl bg-muted ring-1 ring-foreground/10">
|
|
<Image
|
|
src={course.brochureImageUrl}
|
|
alt={course.title}
|
|
fill
|
|
className="object-cover"
|
|
sizes="(max-width:1024px) 100vw, 60vw"
|
|
priority
|
|
/>
|
|
</div>
|
|
|
|
<section className="space-y-4">
|
|
<Heading level={3} as="h2">
|
|
{labels.aboutTitle}
|
|
</Heading>
|
|
<p className="text-base leading-8 text-foreground/90">
|
|
{course.seoDescription || course.summary}
|
|
</p>
|
|
</section>
|
|
|
|
{instructors.length > 0 ? (
|
|
<section className="space-y-4">
|
|
<Heading level={3} as="h2">
|
|
اساتید
|
|
</Heading>
|
|
<ul className="grid gap-3 sm:grid-cols-2">
|
|
{instructors.map((person) => {
|
|
const body = (
|
|
<>
|
|
<span className="block font-semibold text-foreground">
|
|
{person.name}
|
|
</span>
|
|
{person.title ? (
|
|
<span className="mt-1 block text-xs text-muted-foreground">
|
|
{person.title}
|
|
</span>
|
|
) : null}
|
|
</>
|
|
);
|
|
return (
|
|
<li key={person.id}>
|
|
{person.profileUrl ? (
|
|
<a
|
|
href={person.profileUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="group flex items-center justify-between gap-3 rounded-xl bg-card p-4 text-sm ring-1 ring-foreground/10 transition-shadow hover:shadow-md hover:ring-primary/25"
|
|
>
|
|
<span className="min-w-0">{body}</span>
|
|
<ArrowUpLeft className="size-4 shrink-0 text-muted-foreground transition-colors group-hover:text-primary" />
|
|
</a>
|
|
) : (
|
|
<div className="rounded-xl bg-card p-4 text-sm ring-1 ring-foreground/10">
|
|
{body}
|
|
</div>
|
|
)}
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
</section>
|
|
) : null}
|
|
|
|
{hasTaxonomy ? (
|
|
<section className="space-y-4">
|
|
<Heading level={3} as="h2">
|
|
{labels.category}
|
|
</Heading>
|
|
<div className="flex flex-wrap gap-2">
|
|
{course.categories.map((c) => (
|
|
<Link key={c.id} href={courseCategoryHref(c.slug)}>
|
|
<Badge className="h-7 cursor-pointer px-3 text-sm font-semibold">
|
|
{c.label}
|
|
</Badge>
|
|
</Link>
|
|
))}
|
|
{course.tags.map((t) => (
|
|
<Link key={t.id} href={courseTagHref(t.slug)}>
|
|
<Badge
|
|
variant="outline"
|
|
className="h-7 cursor-pointer px-3 text-xs hover:bg-muted"
|
|
>
|
|
{t.label}
|
|
</Badge>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</section>
|
|
) : null}
|
|
</div>
|
|
|
|
<aside className="min-w-0 space-y-4 lg:sticky lg:top-28">
|
|
<SurfaceCard padded as="div">
|
|
<p className="mb-4 text-sm font-bold text-foreground">
|
|
{labels.detailsTitle}
|
|
</p>
|
|
<DetailList items={details} />
|
|
</SurfaceCard>
|
|
|
|
<CourseRegisterGate
|
|
courseSlug={course.slug}
|
|
submitLabel={labels.submit}
|
|
successLabel={labels.success}
|
|
ctaLabel={labels.cta}
|
|
formTitle={labels.formTitle}
|
|
formDescription={labels.formDescription}
|
|
hint={labels.hint}
|
|
cancelLabel={labels.cancel}
|
|
/>
|
|
|
|
<TextLink href="/professional" className="block px-1 text-sm">
|
|
{labels.backToCatalog}
|
|
</TextLink>
|
|
</aside>
|
|
</Container>
|
|
</Section>
|
|
</main>
|
|
);
|
|
}
|