Apply the public site UI checklist.

Align header, footer, brand, homepage course preview, faculty links, and the course catalog with the documented changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
smhk1376andCursor committed 2026-10-16 14:05:33 +03:30
1 parent 8886aa8640
commit de800d27b1
139 files changed
+3311 -1547

No files matched your search

@@ -1,9 +1,10 @@
"use client";
import { useDeferredValue, useMemo, useState } from "react";
import { useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { Search, X } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -19,11 +20,23 @@ import type { Course, TaxonomyRef } from "@/lib/types";
import {
courseCatalogHref,
courseCategoryHref,
courseFilterHref,
courseTagHref,
} from "@/lib/course-nav";
import { formatCoursePrice, formatLabel } from "@/lib/labels";
import { cn } from "@/lib/utils";
const categoryChipClass =
"h-9 shrink-0 rounded-full px-4 text-sm font-semibold whitespace-nowrap";
const categoryChipIdle =
"text-background/70 hover:bg-background/10 hover:text-background";
const tagChipClass =
"h-7 shrink-0 rounded-full border px-3 text-xs whitespace-nowrap";
const tagChipIdle =
"border-background/15 bg-transparent text-background/65 hover:border-background/35 hover:bg-transparent hover:text-background";
const tagChipActive =
"border-primary bg-primary/20 text-background hover:bg-primary/30";
export function CategoryCourseExplorer({
courses,
findLabel,
@@ -47,35 +60,50 @@ export function CategoryCourseExplorer({
}) {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const onCatalogPage = pathname.startsWith("/professional");
// URL is source of truth on the catalog page; home keeps local filter state.
const urlTag = searchParams.get("tag")?.trim() ?? "";
const urlCategory = searchParams.get("category")?.trim() ?? "";
const [query, setQuery] = useState("");
const [categorySlug, setCategorySlug] = useState(initialCategory);
const [tagSlug, setTagSlug] = useState(initialTag);
const [searchOpen, setSearchOpen] = useState(false);
const [localCategory, setLocalCategory] = useState(initialCategory);
const [localTag, setLocalTag] = useState(initialTag);
const deferredQuery = useDeferredValue(query);
const isStale = query !== deferredQuery;
const searchInputRef = useRef<HTMLInputElement>(null);
const syncUrl = (nextTag: string, nextCategory: string) => {
if (pathname !== "/professional" && !pathname.startsWith("/professional")) {
const categorySlug = onCatalogPage ? urlCategory : localCategory;
const tagSlug = onCatalogPage ? urlTag : localTag;
useEffect(() => {
if (searchOpen) {
searchInputRef.current?.focus();
}
}, [searchOpen]);
/** Navigate (catalog) or update local state (home). */
const applyFilters = (nextTag: string, nextCategory: string) => {
if (onCatalogPage) {
router.push(courseFilterHref({ tag: nextTag, category: nextCategory }), {
scroll: false,
});
return;
}
const params = new URLSearchParams();
if (nextTag) params.set("tag", nextTag);
if (nextCategory) params.set("category", nextCategory);
const qs = params.toString();
router.replace(qs ? `/professional?${qs}` : courseCatalogHref(), {
scroll: false,
});
setLocalTag(nextTag);
setLocalCategory(nextCategory);
};
const selectTag = (slug: string) => {
const next = tagSlug === slug ? "" : slug;
setTagSlug(next);
syncUrl(next, categorySlug);
applyFilters(next, categorySlug);
};
const selectCategory = (slug: string) => {
const next = categorySlug === slug ? "" : slug;
setCategorySlug(next);
syncUrl(tagSlug, next);
applyFilters(tagSlug, next);
};
const filtered = useMemo(() => {
@@ -93,188 +121,158 @@ export function CategoryCourseExplorer({
});
}, [courses, categorySlug, tagSlug, deferredQuery]);
const hasFilters = tagSlug !== "" || categorySlug !== "" || query !== "";
const resetFilters = () => {
setCategorySlug("");
setTagSlug("");
setQuery("");
syncUrl("", "");
setSearchOpen(false);
applyFilters("", "");
};
const activeCategory = filterCategories.find((c) => c.slug === categorySlug);
const activeTag = filterTags.find((t) => t.slug === tagSlug);
const closeSearch = () => {
setSearchOpen(false);
setQuery("");
};
return (
<div className="space-y-8">
<form
className="flex flex-col gap-3 sm:flex-row"
onSubmit={(e) => e.preventDefault()}
role="search"
>
<Label className="sr-only" htmlFor="course-search">
{findLabel}
</Label>
<Input
id="course-search"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder={findLabel}
className="h-11 flex-1 border-border bg-background text-foreground placeholder:text-muted-foreground"
/>
<Button type="submit" className="h-11">
جستجو
</Button>
</form>
{filterCategories.length > 0 ? (
<div className="space-y-3">
<span className="text-sm font-semibold text-background/80">
{categoriesLabel}
</span>
<div
className="flex flex-wrap gap-2"
role="tablist"
aria-label={categoriesLabel}
>
<Button
type="button"
role="tab"
size="sm"
variant={categorySlug === "" ? "default" : "ghost"}
aria-selected={categorySlug === ""}
onClick={() => {
setCategorySlug("");
syncUrl(tagSlug, "");
}}
className={cn(
categorySlug !== "" &&
"bg-background/10 text-background/85 hover:bg-background/20 hover:text-background",
)}
<div className="rounded-2xl bg-background/5 p-2 ring-1 ring-background/10">
<div className="flex h-11 items-center gap-2">
{searchOpen ? (
<form
className="animate-in fade-in slide-in-from-left-4 flex h-full min-w-0 flex-1 items-center gap-2 duration-200"
onSubmit={(e) => e.preventDefault()}
role="search"
>
همه
</Button>
{filterCategories.map((item) => (
<Label className="sr-only" htmlFor="course-search">
{findLabel}
</Label>
<div className="relative h-full min-w-0 flex-1">
<Search
className="pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2 text-background/50"
aria-hidden
/>
<Input
ref={searchInputRef}
id="course-search"
value={query}
onChange={(e) => setQuery(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Escape") closeSearch();
}}
placeholder={findLabel}
className="h-full rounded-full border-0 bg-background/10 ps-10 pe-3 text-background placeholder:text-background/45 focus-visible:ring-1 focus-visible:ring-background/30"
/>
</div>
<Button
key={item.id}
type="button"
role="tab"
size="sm"
variant={categorySlug === item.slug ? "default" : "ghost"}
aria-selected={categorySlug === item.slug}
onClick={() => selectCategory(item.slug)}
className={cn(
categorySlug !== item.slug &&
"bg-background/10 text-background/85 hover:bg-background/20 hover:text-background",
)}
variant="ghost"
size="icon"
className="size-10 shrink-0 rounded-full text-background/70 hover:bg-background/10 hover:text-background"
aria-label="بستن جستجو"
onClick={closeSearch}
>
{item.label}
<X className="size-5" />
</Button>
))}
</div>
</div>
) : null}
{filterTags.length > 0 ? (
<div className="space-y-3">
<div className="flex flex-wrap items-center gap-2">
<span className="text-sm font-semibold text-background/80">
{tagsLabel}
</span>
<Button
type="button"
size="sm"
variant={tagSlug === "" ? "default" : "ghost"}
aria-selected={tagSlug === ""}
onClick={() => {
setTagSlug("");
syncUrl("", categorySlug);
}}
className={cn(
tagSlug !== "" &&
"bg-background/10 text-background/85 hover:bg-background/20 hover:text-background",
)}
>
همه
</Button>
{filterTags.map((item) => (
</form>
) : (
<div className="animate-in fade-in flex h-full min-w-0 flex-1 items-center gap-2 duration-200">
<Button
key={item.id}
type="button"
size="sm"
variant={tagSlug === item.slug ? "default" : "ghost"}
aria-selected={tagSlug === item.slug}
onClick={() => selectTag(item.slug)}
className={cn(
tagSlug !== item.slug &&
"bg-background/10 text-background/85 hover:bg-background/20 hover:text-background",
)}
variant="ghost"
size="icon"
className="size-10 shrink-0 rounded-full bg-background/10 text-background hover:bg-background/20 hover:text-background"
aria-label={findLabel}
onClick={() => setSearchOpen(true)}
>
{item.label}
<Search className="size-[1.125rem]" />
</Button>
))}
</div>
{filterCategories.length > 0 ? (
<>
<span
className="h-6 w-px shrink-0 bg-background/15"
aria-hidden
/>
<div
className="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
role="tablist"
aria-label={categoriesLabel}
>
<Button
type="button"
role="tab"
variant={categorySlug === "" ? "default" : "ghost"}
aria-selected={categorySlug === ""}
onClick={() => applyFilters(tagSlug, "")}
className={cn(
categoryChipClass,
categorySlug !== "" && categoryChipIdle,
)}
>
همه دوره‌ها
</Button>
{filterCategories.map((item) => (
<Button
key={item.id}
type="button"
role="tab"
variant={categorySlug === item.slug ? "default" : "ghost"}
aria-selected={categorySlug === item.slug}
onClick={() => selectCategory(item.slug)}
className={cn(
categoryChipClass,
categorySlug !== item.slug && categoryChipIdle,
)}
>
{item.label}
</Button>
))}
</div>
</>
) : null}
</div>
)}
</div>
) : null}
{(tagSlug !== "" || categorySlug !== "") && (
<div className="flex flex-wrap items-center gap-2 text-xs text-background/60">
<span>فیلترهای فعال:</span>
{activeCategory ? (
<Badge variant="secondary" className="gap-1 py-0.5 pe-1">
{activeCategory.label}
{filterTags.length > 0 || hasFilters ? (
<div className="mt-2 flex flex-wrap items-center gap-1.5 border-t border-background/10 px-2 pt-2.5 pb-0.5">
{filterTags.length > 0 ? (
<>
<span className="me-1 text-xs text-background/45">
{tagsLabel}
</span>
{filterTags.map((item) => {
const active = tagSlug === item.slug;
return (
<Button
key={item.id}
type="button"
variant="outline"
aria-pressed={active}
onClick={() => selectTag(item.slug)}
className={cn(
tagChipClass,
active ? tagChipActive : tagChipIdle,
)}
>
{item.label}
</Button>
);
})}
</>
) : null}
{hasFilters ? (
<button
type="button"
onClick={() => {
setCategorySlug("");
syncUrl(tagSlug, "");
}}
className="rounded-full p-0.5 hover:bg-foreground/10"
aria-label="حذف فیلتر دسته"
onClick={resetFilters}
className="ms-auto text-xs text-background/55 underline-offset-4 transition-colors hover:text-background hover:underline"
>
×
پاک‌کردن فیلترها
</button>
</Badge>
) : null}
{activeTag ? (
<Badge variant="secondary" className="gap-1 py-0.5 pe-1">
{activeTag.label}
<button
type="button"
onClick={() => {
setTagSlug("");
syncUrl("", categorySlug);
}}
className="rounded-full p-0.5 hover:bg-foreground/10"
aria-label="حذف فیلتر تگ"
>
×
</button>
</Badge>
) : null}
<button
type="button"
onClick={resetFilters}
className="underline underline-offset-4 hover:text-background"
>
پاک‌کردن همه
</button>
{activeTag ? (
<Link
href={courseTagHref(activeTag.slug)}
className="sr-only"
>
{activeTag.label}
</Link>
) : null}
{activeCategory ? (
<Link
href={courseCategoryHref(activeCategory.slug)}
className="sr-only"
>
{activeCategory.label}
</Link>
) : null}
</div>
)}
) : null}
</div>
) : null}
</div>
{filtered.length === 0 ? (
<p className="py-10 text-center text-sm text-background/60">
@@ -292,51 +290,90 @@ export function CategoryCourseExplorer({
return (
<Card
key={course.id}
className="gap-0 overflow-hidden bg-background/5 py-0 text-background ring-background/10"
className="group relative gap-0 overflow-hidden bg-background/5 py-0 text-background ring-background/10 transition-colors hover:ring-background/30"
>
<div className="relative aspect-[16/10] overflow-hidden">
{/* Full-card hit target sits under content; badges use pointer-events-auto */}
<Link
href={course.registrationUrl}
className="absolute inset-0 z-0"
aria-label={course.title}
/>
<div className="pointer-events-none relative aspect-[16/10] overflow-hidden">
<Image
src={course.posterImageUrl}
alt={course.title}
alt=""
fill
className="object-cover"
className="object-cover transition-transform duration-300 group-hover:scale-[1.03]"
sizes="(max-width:768px) 100vw, 33vw"
/>
</div>
<CardHeader className="gap-1 px-4 pt-4">
<CardHeader className="pointer-events-none relative z-[1] gap-1 px-4 pt-4">
<CardTitle className="text-base text-background">
<Link
href={course.registrationUrl}
className="transition-opacity hover:opacity-90"
>
{course.title}
</Link>
{course.title}
</CardTitle>
</CardHeader>
<CardContent className="space-y-3 px-4 pb-4">
<CardContent className="pointer-events-none relative z-[1] space-y-3 px-4 pb-4">
<CardDescription className="line-clamp-3 text-background/70">
{course.summary}
</CardDescription>
{(course.categories.length > 0 || course.tags.length > 0) && (
<div className="flex flex-wrap gap-1.5">
{course.categories.map((c) => (
<Badge
key={`cat:${c.id}`}
variant="outline"
className="border-background/25 text-[10px] text-background/80"
>
{c.label}
</Badge>
))}
{course.tags.map((t) => (
<Badge
key={`tag:${t.id}`}
variant="outline"
className="border-background/25 text-[10px] text-background/80"
>
{t.label}
</Badge>
))}
<div className="pointer-events-auto flex flex-wrap gap-1.5">
{course.categories.map((c) => {
const href = onCatalogPage
? courseCategoryHref(
categorySlug === c.slug ? "" : c.slug,
tagSlug,
)
: courseCategoryHref(c.slug);
const active = categorySlug === c.slug;
return (
<Link
key={`cat:${c.id}`}
href={href || courseCatalogHref()}
className="relative z-[2]"
onClick={(e) => e.stopPropagation()}
aria-current={active ? "true" : undefined}
>
<Badge
variant="outline"
className={cn(
"cursor-pointer border-background/25 text-[11px] font-semibold text-background/90 hover:bg-background/15",
active && "border-accent bg-accent/20 text-background",
)}
>
{c.label}
</Badge>
</Link>
);
})}
{course.tags.map((t) => {
const href = onCatalogPage
? courseTagHref(
tagSlug === t.slug ? "" : t.slug,
categorySlug,
)
: courseTagHref(t.slug);
const active = tagSlug === t.slug;
return (
<Link
key={`tag:${t.id}`}
href={href || courseCatalogHref()}
className="relative z-[2]"
onClick={(e) => e.stopPropagation()}
aria-current={active ? "true" : undefined}
>
<Badge
variant="outline"
className={cn(
"cursor-pointer border-background/25 text-[10px] text-background/75 hover:bg-background/15",
active && "border-accent bg-accent/20 text-background",
)}
>
{t.label}
</Badge>
</Link>
);
})}
</div>
)}
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-background/55">
@@ -351,12 +388,9 @@ export function CategoryCourseExplorer({
</span>
) : null}
</div>
<Link
href={course.registrationUrl}
className="inline-flex text-sm font-semibold text-background underline-offset-4 hover:underline"
>
<span className="inline-flex text-sm font-semibold text-background underline-offset-4 group-hover:underline">
جزئیات و ثبت‌نام
</Link>
</span>
</CardContent>
</Card>
);
@@ -54,7 +54,7 @@ export function ContactInterestForm({
if (sent) {
return (
<p className="rounded-lg border border-primary/25 bg-primary/5 p-4 text-sm text-chart-2">
<p className="rounded-xl border border-primary/25 bg-primary/5 p-4 text-sm leading-7 text-foreground">
{successLabel}
</p>
);
@@ -63,7 +63,7 @@ export function ContactInterestForm({
return (
<form className="space-y-4" onSubmit={handleSubmit}>
{error && (
<p className="rounded-lg bg-destructive/10 p-3 text-sm text-red-600" role="alert">
<p className="rounded-xl bg-destructive/10 p-3 text-sm text-destructive" role="alert">
{error}
</p>
)}
@@ -129,7 +129,7 @@ export function ContactInterestForm({
rows={4}
/>
</div>
<Button type="submit" disabled={loading}>
<Button type="submit" size="lg" className="w-full font-bold" disabled={loading}>
{loading ? "در حال ارسال..." : submitLabel}
</Button>
</form>
+33 -37
View File
@@ -34,45 +34,41 @@ export function CourseRegisterGate({
}: CourseRegisterGateProps) {
const [open, setOpen] = useState(false);
if (!open) {
return (
<div className="space-y-4 rounded-2xl bg-card p-6 shadow-sm ring-1 ring-border">
<div className="space-y-2">
<h2 className="text-lg font-bold tracking-tight">{formTitle}</h2>
<p className="text-sm leading-7 text-muted-foreground">{hint}</p>
</div>
<Button
type="button"
size="lg"
className="w-full font-bold"
onClick={() => setOpen(true)}
>
{ctaLabel}
</Button>
</div>
);
}
return (
<Card className="rounded-2xl border-border/70 shadow-lg" id="register-form">
<CardHeader className="space-y-1">
<CardTitle>{formTitle}</CardTitle>
<CardDescription>{formDescription}</CardDescription>
<Card id="register-form" className="gap-0 py-0">
<CardHeader className="gap-2 p-6 pb-0">
<CardTitle className="text-lg font-bold">{formTitle}</CardTitle>
<CardDescription className="leading-7">
{open ? formDescription : hint}
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<ContactInterestForm
courseSlug={courseSlug}
submitLabel={submitLabel}
successLabel={successLabel}
/>
<Button
type="button"
variant="ghost"
className="w-full"
onClick={() => setOpen(false)}
>
{cancelLabel}
</Button>
<CardContent className="space-y-3 p-6">
{open ? (
<>
<ContactInterestForm
courseSlug={courseSlug}
submitLabel={submitLabel}
successLabel={successLabel}
/>
<Button
type="button"
variant="ghost"
className="w-full"
onClick={() => setOpen(false)}
>
{cancelLabel}
</Button>
</>
) : (
<Button
type="button"
size="lg"
className="w-full font-bold"
onClick={() => setOpen(true)}
>
{ctaLabel}
</Button>
)}
</CardContent>
</Card>
);
+46
View File
@@ -0,0 +1,46 @@
"use client";
import { useEffect } from "react";
import Link from "next/link";
import { Container } from "@/components/atoms/Container";
import { Heading } from "@/components/atoms/Heading";
import { Button, buttonVariants } from "@/components/ui/button";
export function ErrorState({
error,
reset,
homeHref = "/",
}: {
error: Error & { digest?: string };
reset: () => void;
homeHref?: string;
}) {
useEffect(() => {
console.error(error);
}, [error]);
return (
<main id="main-content" className="bg-background">
<Container className="flex min-h-[60vh] flex-col items-start justify-center py-20">
<p className="text-sm font-bold text-primary sm:text-base">خطا</p>
<Heading as="h1" level={2} className="mt-3">
بارگذاری صفحه ناموفق بود
</Heading>
<p className="mt-4 max-w-md text-base leading-8 text-muted-foreground">
لطفاً دوباره تلاش کنید. اگر مشکل ادامه داشت، چند لحظه بعد بازگردید.
</p>
<div className="mt-8 flex flex-wrap gap-3">
<Button type="button" size="lg" className="font-bold" onClick={reset}>
تلاش مجدد
</Button>
<Link
href={homeHref}
className={buttonVariants({ variant: "outline", size: "lg" })}
>
بازگشت
</Link>
</div>
</Container>
</main>
);
}
+4 -2
View File
@@ -56,17 +56,19 @@ export function SiteFooter({
تماس
</p>
<div className="space-y-1.5 text-sm text-background/75">
<p dir="ltr">
<p>
<a
href={`tel:${siteAddress.phone}`}
dir="ltr"
className="transition-colors hover:text-background"
>
{siteAddress.phone}
</a>
</p>
<p dir="ltr">
<p>
<a
href={`mailto:${siteAddress.email}`}
dir="ltr"
className="transition-colors hover:text-background"
>
{siteAddress.email}
+35 -84
View File
@@ -1,6 +1,5 @@
"use client";
import dynamic from "next/dynamic";
import Link from "next/link";
import { ChevronDown, Menu, X } from "lucide-react";
import { useEffect, useState } from "react";
@@ -18,14 +17,6 @@ import { SearchOverlay } from "@/components/organisms/SearchOverlay";
import type { Course, NavItem, Program } from "@/lib/types";
import { cn } from "@/lib/utils";
const AcademicsOverlay = dynamic(
() =>
import("@/components/organisms/AcademicsOverlay").then(
(m) => m.AcademicsOverlay,
),
{ ssr: false },
);
function NavLink({
item,
isDark,
@@ -62,7 +53,7 @@ function NavDropdown({
<DropdownMenu>
<DropdownMenuTrigger
className={cn(
"inline-flex cursor-pointer items-center gap-1 rounded-lg px-2.5 py-2 text-sm font-semibold transition-colors outline-none",
"inline-flex cursor-pointer items-center gap-1 rounded-lg px-3 py-2 text-sm font-semibold transition-colors outline-none",
isDark
? "text-background/80 hover:text-background"
: "text-foreground/75 hover:bg-muted hover:text-primary",
@@ -73,13 +64,12 @@ function NavDropdown({
</DropdownMenuTrigger>
<DropdownMenuContent className="z-[60] w-56 p-1" align="start">
{children.map((child) => (
<DropdownMenuItem key={`nav:${child.href}:${child.label}`} className="p-0">
<Link
href={child.href}
className="w-full cursor-pointer px-1.5 py-1.5"
>
{child.label}
</Link>
<DropdownMenuItem
key={`nav:${child.href}:${child.label}`}
className="cursor-pointer"
render={<Link href={child.href} />}
>
{child.label}
</DropdownMenuItem>
))}
</DropdownMenuContent>
@@ -90,35 +80,26 @@ function NavDropdown({
export function SiteHeader({
items,
searchLabel,
contactLabel,
brandHref = "/",
brandTitle,
brandSubtitle,
academicsLabel,
programSelectorTitle,
executiveLabel,
exploreLabel,
variant = "home",
courses = [],
programs = [],
}: {
items: NavItem[];
searchLabel: string;
contactLabel: string;
brandHref?: string;
brandTitle: string;
brandSubtitle?: string;
academicsLabel: string;
programSelectorTitle: string;
executiveLabel: string;
exploreLabel: string;
variant?: "home" | "professional";
courses?: Course[];
programs?: Program[];
}) {
const [mobileOpen, setMobileOpen] = useState(false);
const [academicsOpen, setAcademicsOpen] = useState(false);
const isDark = variant === "professional";
const standardPrograms = programs.filter((p) => p.group === "standard");
const executivePrograms = programs.filter((p) => p.group === "executive");
useEffect(() => {
if (!mobileOpen) return;
@@ -139,7 +120,7 @@ export function SiteHeader({
: "border-b border-border bg-card/95 text-foreground",
)}
>
<Container className="flex h-[4.5rem] min-w-0 items-center justify-start gap-2 sm:h-20 sm:gap-5" dir="rtl">
<Container className="flex h-[4.5rem] min-w-0 items-center justify-start gap-3 sm:h-20 sm:gap-6" dir="rtl">
<BrandLogo
href={brandHref}
title={brandTitle}
@@ -149,7 +130,7 @@ export function SiteHeader({
/>
<nav
className="hidden min-w-0 flex-1 items-center justify-start gap-0.5 xl:flex"
className="hidden min-w-0 flex-1 items-center justify-start gap-2 xl:flex"
aria-label="منوی اصلی"
>
{items.map((item) => {
@@ -163,25 +144,13 @@ export function SiteHeader({
/>
);
}
return item.prominent ? (
return (
<NavLink
key={itemKey}
item={item}
isDark={isDark}
className={cn(
"ms-1 inline-flex items-center rounded-md border px-2.5 py-1 text-xs font-bold shadow-sm transition-all",
isDark
? "border-primary-foreground/30 bg-primary-foreground/10 text-primary-foreground hover:bg-primary-foreground hover:text-primary"
: "border-primary/30 bg-primary/10 text-primary hover:bg-primary hover:text-primary-foreground",
)}
/>
) : (
<NavLink
key={itemKey}
item={item}
isDark={isDark}
className={cn(
"rounded-lg px-2.5 py-2 text-sm font-semibold transition-colors",
"rounded-lg px-3 py-2 text-sm font-semibold transition-colors",
isDark
? "text-background/80 hover:text-background"
: "text-foreground/75 hover:bg-muted hover:text-primary",
@@ -189,26 +158,25 @@ export function SiteHeader({
/>
);
})}
<Button
variant="outline"
size="sm"
className={cn(
"ms-2 h-9 border-primary/20 font-bold text-primary hover:bg-primary hover:text-primary-foreground",
isDark &&
"border-background/50 bg-transparent text-background hover:bg-background hover:text-foreground",
)}
onClick={() => setAcademicsOpen(true)}
>
{academicsLabel}
</Button>
</nav>
<div
className={cn(
"ms-auto flex shrink-0 items-center gap-0.5 xl:ms-0",
"ms-auto flex shrink-0 items-center gap-2 xl:ms-0",
isDark && "text-background",
)}
>
<Link
href="/contact"
className={cn(
"hidden rounded-lg px-3 py-2 text-sm font-semibold transition-colors sm:inline-flex",
isDark
? "text-background/80 hover:text-background"
: "text-foreground/75 hover:bg-muted hover:text-primary",
)}
>
{contactLabel}
</Link>
<SearchOverlay
courses={courses}
programs={programs}
@@ -284,42 +252,25 @@ export function SiteHeader({
<NavLink
item={item}
isDark
className={cn(
"block py-3.5 text-lg font-bold transition-colors hover:text-background/70",
item.prominent &&
"inline-block text-primary underline underline-offset-4",
)}
className="block py-3.5 text-lg font-bold transition-colors hover:text-background/70"
onClick={() => setMobileOpen(false)}
/>
)}
</li>
))}
<li>
<Link
href="/contact"
className="block py-3.5 text-lg font-bold transition-colors hover:text-background/70"
onClick={() => setMobileOpen(false)}
>
{contactLabel}
</Link>
</li>
</ul>
<Button
variant="outline"
className="mt-8 w-full border-background/80 bg-transparent py-3.5 text-background hover:bg-background hover:text-foreground"
onClick={() => {
setMobileOpen(false);
setAcademicsOpen(true);
}}
>
{academicsLabel}
</Button>
</Container>
</div>
) : null}
{academicsOpen ? (
<AcademicsOverlay
open={academicsOpen}
onClose={() => setAcademicsOpen(false)}
title={programSelectorTitle}
executiveLabel={executiveLabel}
exploreLabel={exploreLabel}
standardPrograms={standardPrograms}
executivePrograms={executivePrograms}
/>
) : null}
</>
);
}
@@ -37,7 +37,7 @@ export function AdminShell({
<div className="flex min-w-0 items-center gap-2">
<span className="relative size-6 shrink-0 md:hidden">
<Image
src="/brand/amirkabir.png"
src="/brand/mst-faculty.png"
alt=""
fill
sizes="24px"
@@ -110,7 +110,7 @@ export function AdminSidebar({ userName }: { userName: string }) {
>
<span className="relative size-8 shrink-0">
<Image
src="/brand/amirkabir.png"
src="/brand/mst-faculty.png"
alt=""
fill
sizes="32px"
@@ -121,7 +121,7 @@ export function AdminSidebar({ userName }: { userName: string }) {
<div className="grid flex-1 text-start text-sm leading-tight">
<span className="truncate font-semibold">پنل مدیریت</span>
<span className="truncate text-xs text-muted-foreground">
آموزش آزاد امیرکبیر
آموزش آزاد دانشگاه صنعتی امیرکبیر
</span>
</div>
</SidebarMenuButton>
@@ -0,0 +1,78 @@
"use client";
import { useRouter } from "next/navigation";
import { useState, useTransition } from "react";
import { RefreshCw } from "lucide-react";
import { Button } from "@/components/ui/button";
type SyncPayload = {
ok?: boolean;
error?: string;
data?: {
total: number;
inserted: number;
updated: number;
imagesSaved: number;
};
};
export function FacultySyncButton() {
const router = useRouter();
const [pending, startTransition] = useTransition();
const [busy, setBusy] = useState(false);
const [message, setMessage] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
async function onSync() {
setBusy(true);
setMessage(null);
setError(null);
try {
const res = await fetch("/api/admin/faculty/sync", { method: "POST" });
const body = (await res.json()) as SyncPayload;
if (!res.ok || !body.ok || !body.data) {
setError(body.error ?? "همگام‌سازی ناموفق بود");
return;
}
const { total, inserted, updated, imagesSaved } = body.data;
setMessage(
`${total} استاد خوانده شد — ${inserted} جدید، ${updated} به‌روز` +
(imagesSaved > 0 ? `، ${imagesSaved} تصویر` : ""),
);
startTransition(() => {
router.refresh();
});
} catch {
setError("ارتباط با سرور برقرار نشد");
} finally {
setBusy(false);
}
}
const loading = busy || pending;
return (
<div className="flex flex-col items-stretch gap-1.5 sm:items-end">
<Button
type="button"
variant="outline"
onClick={onSync}
disabled={loading}
className="gap-2"
>
<RefreshCw className={loading ? "size-4 animate-spin" : "size-4"} />
{loading ? "در حال بروزرسانی…" : "بروزرسانی از شبکه اساتید"}
</Button>
{message ? (
<p className="max-w-xs text-xs text-muted-foreground" role="status">
{message}
</p>
) : null}
{error ? (
<p className="max-w-xs text-xs text-destructive" role="alert">
{error}
</p>
) : null}
</div>
);
}
+1 -1
View File
@@ -54,7 +54,7 @@ export function LeadsList({ leads }: { leads: LeadForDashboard[] }) {
return (
<div className="space-y-3">
{error && (
<p className="text-sm text-red-600" role="alert">
<p className="text-sm text-destructive" role="alert">
{error}
</p>
)}
@@ -22,12 +22,15 @@ import type { AdminCourseCategory, AdminCourseTag } from "@/lib/data/admin/taxon
import { AdminFormCard } from "@/components/organisms/admin/AdminPage";
import { ImageUploadField } from "@/components/organisms/admin/ImageUploadField";
type FacultyOption = { id: string; name: string; title: string };
type Payload = {
slug: string;
title: string;
summary: string;
categoryIds: string[];
tagIds: string[];
facultyIds: string[];
durationHours: number | null;
format: string;
price: number | null;
@@ -42,13 +45,19 @@ interface CourseFormProps {
initial?: AdminCourse;
categories: AdminCourseCategory[];
tags: AdminCourseTag[];
faculty: FacultyOption[];
}
function toggleId(ids: string[], id: string): string[] {
return ids.includes(id) ? ids.filter((x) => x !== id) : [...ids, id];
}
export function CourseForm({ initial, categories, tags }: CourseFormProps) {
export function CourseForm({
initial,
categories,
tags,
faculty,
}: CourseFormProps) {
const router = useRouter();
const isEdit = Boolean(initial);
const [form, setForm] = useState<Payload>({
@@ -57,6 +66,7 @@ export function CourseForm({ initial, categories, tags }: CourseFormProps) {
summary: initial?.summary ?? "",
categoryIds: initial?.categoryIds ?? [],
tagIds: initial?.tagIds ?? [],
facultyIds: initial?.facultyIds ?? [],
durationHours: initial?.durationHours ?? null,
format: initial?.format ?? "in-person",
price: initial?.price ?? null,
@@ -345,6 +355,62 @@ export function CourseForm({ initial, categories, tags }: CourseFormProps) {
</div>
) : null}
</div>
<div className="space-y-2">
<Label>اساتید (رفرنس دانشکده)</Label>
{faculty.length === 0 ? (
<p className="text-xs text-muted-foreground">
هنوز استادی تعریف نشده. از «اساتید» در ادمین اضافه کنید و لینک
صفحه دانشکده را وارد کنید.
</p>
) : (
<div className="flex flex-wrap gap-2">
{faculty.map((item) => {
const active = form.facultyIds.includes(item.id);
return (
<Button
key={item.id}
type="button"
size="sm"
variant={active ? "default" : "outline"}
aria-pressed={active}
onClick={() =>
set("facultyIds", toggleId(form.facultyIds, item.id))
}
className="h-8 px-3 text-xs"
>
{item.name}
</Button>
);
})}
</div>
)}
{form.facultyIds.length > 0 ? (
<div className="flex flex-wrap gap-1.5 pt-1">
{form.facultyIds.map((id) => {
const item = faculty.find((f) => f.id === id);
return (
<Badge key={id} variant="secondary" className="gap-1 py-1 pe-1">
{item?.name ?? id}
<button
type="button"
onClick={() =>
set(
"facultyIds",
form.facultyIds.filter((x) => x !== id),
)
}
className="rounded-full p-0.5 hover:bg-foreground/10"
aria-label="حذف استاد"
>
×
</button>
</Badge>
);
})}
</div>
) : null}
</div>
</section>
<Separator />
@@ -48,7 +48,7 @@ export function DeleteCourseDialog({ id, title }: { id: string; title: string })
دوره «{title}» برای همیشه حذف می‌شود. این عمل قابل بازگشت نیست.
</DialogDescription>
</DialogHeader>
{error && <p className="text-sm text-red-600">{error}</p>}
{error && <p className="text-sm text-destructive">{error}</p>}
<DialogFooter>
<Button type="button" variant="outline" onClick={() => setOpen(false)}>
انصراف
@@ -40,7 +40,7 @@ export function PublishToggle({ id, published }: { id: string; published: boolea
>
{loading ? "..." : published ? "منتشرشده" : "پیش‌نویس"}
</Button>
{error && <p className="mt-1 max-w-40 text-xs text-red-600">{error}</p>}
{error && <p className="mt-1 max-w-40 text-xs text-destructive">{error}</p>}
</div>
);
}
@@ -58,7 +58,7 @@ export function GenericDeleteDialog({
«{subject}» برای همیشه حذف می‌شود. این عمل قابل بازگشت نیست.
</DialogDescription>
</DialogHeader>
{error && <p className="text-sm text-red-600">{error}</p>}
{error && <p className="text-sm text-destructive">{error}</p>}
<DialogFooter>
<Button type="button" variant="outline" onClick={() => setOpen(false)}>
انصراف
@@ -48,7 +48,7 @@ export function PublishToggle({
>
{loading ? "..." : published ? "منتشرشده" : "پیش‌نویس"}
</Button>
{error && <p className="mt-1 max-w-40 text-xs text-red-600">{error}</p>}
{error && <p className="mt-1 max-w-40 text-xs text-destructive">{error}</p>}
</div>
);
}