Implement faculty page redirect and enhance course management features. Added a redirect for the faculty page to an external URL. Updated course data structure to include new fields for poster and brochure images, and introduced tagging functionality for courses. Enhanced admin course filters to support tag-based filtering and improved course form for tag management. Updated navigation links to reflect changes in course and faculty structure.
This commit is contained in:
1 parent
0e2fcaacdd
commit
ab7fcd41d8
22 files changed
+544
-167
No files matched your search
@@ -6,6 +6,7 @@ import Link from "next/link";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
@@ -21,28 +22,49 @@ import { cn } from "@/lib/utils";
|
||||
export function CategoryCourseExplorer({
|
||||
courses,
|
||||
findLabel,
|
||||
tagsLabel = "دستهبندیها",
|
||||
}: {
|
||||
courses: Course[];
|
||||
findLabel: string;
|
||||
tagsLabel?: string;
|
||||
}) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [category, setCategory] = useState("all");
|
||||
const [tag, setTag] = useState("");
|
||||
const deferredQuery = useDeferredValue(query);
|
||||
const isStale = query !== deferredQuery;
|
||||
|
||||
// Distinct tags across all courses (stable order: most used first).
|
||||
const tags = useMemo(() => {
|
||||
const counts = new Map<string, number>();
|
||||
for (const course of courses) {
|
||||
for (const t of course.tags ?? []) {
|
||||
counts.set(t, (counts.get(t) ?? 0) + 1);
|
||||
}
|
||||
}
|
||||
return [...counts.entries()].sort((a, b) => b[1] - a[1]).map(([t]) => t);
|
||||
}, [courses]);
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
return courses.filter((course) => {
|
||||
const matchesCategory =
|
||||
category === "all" ||
|
||||
category === "best" ||
|
||||
course.category === category;
|
||||
const matchesTag = !tag || (course.tags ?? []).includes(tag);
|
||||
const matchesQuery =
|
||||
!deferredQuery ||
|
||||
course.title.includes(deferredQuery) ||
|
||||
course.summary.includes(deferredQuery);
|
||||
return matchesCategory && matchesQuery;
|
||||
return matchesCategory && matchesTag && matchesQuery;
|
||||
});
|
||||
}, [courses, category, deferredQuery]);
|
||||
}, [courses, category, tag, deferredQuery]);
|
||||
|
||||
const resetFilters = () => {
|
||||
setCategory("all");
|
||||
setTag("");
|
||||
setQuery("");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
@@ -90,65 +112,162 @@ export function CategoryCourseExplorer({
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"grid gap-5 transition-opacity sm:grid-cols-2 lg:grid-cols-3",
|
||||
isStale && "opacity-70",
|
||||
)}
|
||||
>
|
||||
{filtered.map((course) => {
|
||||
const priceLabel = formatCoursePrice(course.price);
|
||||
return (
|
||||
<Card
|
||||
key={course.id}
|
||||
className="gap-0 overflow-hidden bg-background/5 py-0 text-background ring-background/10"
|
||||
>
|
||||
<div className="relative aspect-[16/10] overflow-hidden">
|
||||
<Image
|
||||
src={course.imageUrl}
|
||||
alt={course.title}
|
||||
fill
|
||||
className="object-cover"
|
||||
sizes="(max-width:768px) 100vw, 33vw"
|
||||
/>
|
||||
</div>
|
||||
<CardHeader className="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>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 px-4 pb-4">
|
||||
<CardDescription className="line-clamp-3 text-background/70">
|
||||
{course.summary}
|
||||
</CardDescription>
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-background/55">
|
||||
<span>
|
||||
{course.durationHours
|
||||
? `${course.durationHours} ساعت · ${formatLabel(course.format)}`
|
||||
: formatLabel(course.format)}
|
||||
</span>
|
||||
{priceLabel ? (
|
||||
<span className="font-semibold text-background/90">
|
||||
{priceLabel}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<Link
|
||||
href={course.registrationUrl}
|
||||
className="inline-flex text-sm font-semibold text-background underline-offset-4 hover:underline"
|
||||
{tags.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={tag === "" ? "default" : "ghost"}
|
||||
aria-selected={tag === ""}
|
||||
onClick={() => setTag("")}
|
||||
className={cn(
|
||||
tag !== "" &&
|
||||
"bg-background/10 text-background/85 hover:bg-background/20 hover:text-background",
|
||||
)}
|
||||
>
|
||||
همه
|
||||
</Button>
|
||||
{tags.map((item) => (
|
||||
<Button
|
||||
key={item}
|
||||
type="button"
|
||||
size="sm"
|
||||
variant={tag === item ? "default" : "ghost"}
|
||||
aria-selected={tag === item}
|
||||
onClick={() => setTag(tag === item ? "" : item)}
|
||||
className={cn(
|
||||
tag !== item &&
|
||||
"bg-background/10 text-background/85 hover:bg-background/20 hover:text-background",
|
||||
)}
|
||||
>
|
||||
جزئیات و ثبتنام
|
||||
</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{item}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{(tag !== "" || category !== "all") && (
|
||||
<div className="flex flex-wrap items-center gap-2 text-xs text-background/60">
|
||||
<span>فیلترهای فعال:</span>
|
||||
{category !== "all" && (
|
||||
<Badge variant="secondary" className="gap-1 py-0.5 pe-1">
|
||||
{courseCategories.find((c) => c.id === category)?.label ?? category}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setCategory("all")}
|
||||
className="rounded-full p-0.5 hover:bg-foreground/10"
|
||||
aria-label="حذف فیلتر دستهبندی"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</Badge>
|
||||
)}
|
||||
{tag !== "" && (
|
||||
<Badge variant="secondary" className="gap-1 py-0.5 pe-1">
|
||||
{tag}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setTag("")}
|
||||
className="rounded-full p-0.5 hover:bg-foreground/10"
|
||||
aria-label="حذف فیلتر تگ"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</Badge>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={resetFilters}
|
||||
className="underline underline-offset-4 hover:text-background"
|
||||
>
|
||||
پاککردن همه
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{filtered.length === 0 ? (
|
||||
<p className="py-10 text-center text-sm text-background/60">
|
||||
دورهای با این فیلترها یافت نشد.
|
||||
</p>
|
||||
) : (
|
||||
<div
|
||||
className={cn(
|
||||
"grid gap-5 transition-opacity sm:grid-cols-2 lg:grid-cols-3",
|
||||
isStale && "opacity-70",
|
||||
)}
|
||||
>
|
||||
{filtered.map((course) => {
|
||||
const priceLabel = formatCoursePrice(course.price);
|
||||
return (
|
||||
<Card
|
||||
key={course.id}
|
||||
className="gap-0 overflow-hidden bg-background/5 py-0 text-background ring-background/10"
|
||||
>
|
||||
<div className="relative aspect-[16/10] overflow-hidden">
|
||||
<Image
|
||||
src={course.posterImageUrl}
|
||||
alt={course.title}
|
||||
fill
|
||||
className="object-cover"
|
||||
sizes="(max-width:768px) 100vw, 33vw"
|
||||
/>
|
||||
</div>
|
||||
<CardHeader className="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>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3 px-4 pb-4">
|
||||
<CardDescription className="line-clamp-3 text-background/70">
|
||||
{course.summary}
|
||||
</CardDescription>
|
||||
{course.tags && course.tags.length > 0 ? (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{course.tags.map((t) => (
|
||||
<Badge
|
||||
key={t}
|
||||
variant="outline"
|
||||
className="border-background/25 text-[10px] text-background/80"
|
||||
>
|
||||
{t}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-background/55">
|
||||
<span>
|
||||
{course.durationHours
|
||||
? `${course.durationHours} ساعت · ${formatLabel(course.format)}`
|
||||
: formatLabel(course.format)}
|
||||
</span>
|
||||
{priceLabel ? (
|
||||
<span className="font-semibold text-background/90">
|
||||
{priceLabel}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<Link
|
||||
href={course.registrationUrl}
|
||||
className="inline-flex text-sm font-semibold text-background underline-offset-4 hover:underline"
|
||||
>
|
||||
جزئیات و ثبتنام
|
||||
</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,12 @@ import { BrandLogo } from "@/components/atoms/BrandLogo";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { SearchOverlay } from "@/components/organisms/SearchOverlay";
|
||||
import type { Course, NavItem, Program } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -85,20 +91,79 @@ export function SiteHeader({
|
||||
className="hidden min-w-0 flex-1 items-center justify-start gap-0.5 xl:flex"
|
||||
aria-label="منوی اصلی"
|
||||
>
|
||||
{items.map((item) => (
|
||||
<Link
|
||||
key={item.href + item.label}
|
||||
href={item.href}
|
||||
className={cn(
|
||||
"rounded-lg px-2.5 py-2 text-sm font-semibold transition-colors",
|
||||
isDark
|
||||
? "text-background/80 hover:text-background"
|
||||
: "text-foreground/75 hover:bg-muted hover:text-primary",
|
||||
)}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
))}
|
||||
{items.map((item) => {
|
||||
if (item.label.includes("دورهها") || item.label.includes("فهرست")) {
|
||||
return (
|
||||
<DropdownMenu key={item.href + item.label}>
|
||||
<DropdownMenuTrigger
|
||||
className={cn(
|
||||
"rounded-lg px-2.5 py-2 text-sm font-semibold transition-colors outline-none cursor-pointer inline-flex items-center gap-1",
|
||||
isDark
|
||||
? "text-background/80 hover:text-background"
|
||||
: "text-foreground/75 hover:bg-muted hover:text-primary",
|
||||
)}
|
||||
>
|
||||
{item.label}
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="z-[60] w-56 p-1">
|
||||
<DropdownMenuItem>
|
||||
<Link href="/professional" className="w-full cursor-pointer">
|
||||
همه دورهها
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<Link href="/professional#programs" className="w-full cursor-pointer">
|
||||
کارگاهها
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<Link href="/professional#programs" className="w-full cursor-pointer">
|
||||
دورههای سازمانی
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<Link href="/professional#programs" className="w-full cursor-pointer">
|
||||
گزیده دورههای برگزار شده
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
return item.prominent ? (
|
||||
<Link
|
||||
key={item.href + item.label}
|
||||
href={item.href}
|
||||
target={item.href.startsWith("http") ? "_blank" : undefined}
|
||||
rel={
|
||||
item.href.startsWith("http")
|
||||
? "noopener noreferrer"
|
||||
: undefined
|
||||
}
|
||||
className={cn(
|
||||
"ms-1 inline-flex items-center rounded-md border px-2.5 py-1 text-xs font-bold transition-all shadow-sm",
|
||||
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",
|
||||
)}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
) : (
|
||||
<Link
|
||||
key={item.href + item.label}
|
||||
href={item.href}
|
||||
className={cn(
|
||||
"rounded-lg px-2.5 py-2 text-sm font-semibold transition-colors",
|
||||
isDark
|
||||
? "text-background/80 hover:text-background"
|
||||
: "text-foreground/75 hover:bg-muted hover:text-primary",
|
||||
)}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
@@ -174,7 +239,19 @@ export function SiteHeader({
|
||||
<li key={item.href + item.label}>
|
||||
<Link
|
||||
href={item.href}
|
||||
className="block py-3.5 text-lg font-bold transition-colors hover:text-background/70"
|
||||
target={
|
||||
item.href.startsWith("http") ? "_blank" : undefined
|
||||
}
|
||||
rel={
|
||||
item.href.startsWith("http")
|
||||
? "noopener noreferrer"
|
||||
: undefined
|
||||
}
|
||||
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"
|
||||
)}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
>
|
||||
{item.label}
|
||||
|
||||
@@ -12,10 +12,11 @@ import {
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
function buildUrl(search: string, published: string) {
|
||||
function buildUrl(search: string, published: string, tag: string) {
|
||||
const params = new URLSearchParams();
|
||||
if (search.trim()) params.set("search", search.trim());
|
||||
if (published && published !== "all") params.set("published", published);
|
||||
if (tag && tag.trim()) params.set("tag", tag.trim());
|
||||
const qs = params.toString();
|
||||
return qs ? `/admin/courses?${qs}` : "/admin/courses";
|
||||
}
|
||||
@@ -23,46 +24,48 @@ function buildUrl(search: string, published: string) {
|
||||
export function CourseFilters({
|
||||
initialSearch,
|
||||
initialPublished,
|
||||
initialTag,
|
||||
availableTags,
|
||||
}: {
|
||||
initialSearch: string;
|
||||
initialPublished: string;
|
||||
initialTag: string;
|
||||
availableTags: string[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [search, setSearch] = useState(initialSearch);
|
||||
const [published, setPublished] = useState(initialPublished);
|
||||
const hasFilters = Boolean(initialSearch.trim()) || initialPublished !== "all";
|
||||
const [tag, setTag] = useState(initialTag);
|
||||
const hasFilters = Boolean(search.trim()) || published !== "all" || Boolean(tag.trim());
|
||||
|
||||
function apply(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
router.push(buildUrl(search, published));
|
||||
router.push(buildUrl(search, published, tag));
|
||||
}
|
||||
|
||||
function clear() {
|
||||
setSearch("");
|
||||
setPublished("all");
|
||||
setTag("");
|
||||
router.push("/admin/courses");
|
||||
}
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={apply}
|
||||
className="flex flex-wrap items-end gap-3"
|
||||
>
|
||||
<form onSubmit={apply} className="flex flex-wrap items-end gap-3">
|
||||
{/* ... search input ... */}
|
||||
<div className="w-full max-w-xs space-y-1.5">
|
||||
<label htmlFor="course-search" className="text-sm font-medium">
|
||||
جستجو
|
||||
</label>
|
||||
<label htmlFor="course-search" className="text-sm font-medium">جستجو</label>
|
||||
<Input
|
||||
id="course-search"
|
||||
placeholder="عنوان یا اسلاگ دوره..."
|
||||
placeholder="عنوان یا اسلاگ..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* ... published select ... */}
|
||||
<div className="w-full max-w-[12rem] space-y-1.5">
|
||||
<label htmlFor="course-published" className="text-sm font-medium">
|
||||
وضعیت انتشار
|
||||
</label>
|
||||
<label htmlFor="course-published" className="text-sm font-medium">وضعیت انتشار</label>
|
||||
<Select value={published} onValueChange={(v) => setPublished(v ?? "all")}>
|
||||
<SelectTrigger id="course-published" className="w-full">
|
||||
<SelectValue />
|
||||
@@ -74,11 +77,26 @@ export function CourseFilters({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* ... tag select ... */}
|
||||
<div className="w-full max-w-[12rem] space-y-1.5">
|
||||
<label htmlFor="course-tag" className="text-sm font-medium">تگ</label>
|
||||
<Select value={tag} onValueChange={(v) => setTag(v ?? "")}>
|
||||
<SelectTrigger id="course-tag" className="w-full">
|
||||
<SelectValue placeholder="همه" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="">همه</SelectItem>
|
||||
{availableTags.map((t) => (
|
||||
<SelectItem key={t} value={t}>{t}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<Button type="submit">اعمال فیلتر</Button>
|
||||
{hasFilters && (
|
||||
<Button type="button" variant="ghost" onClick={clear}>
|
||||
پاککردن فیلترها
|
||||
</Button>
|
||||
<Button type="button" variant="ghost" onClick={clear}>پاککردن فیلترها</Button>
|
||||
)}
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -16,9 +16,17 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Plus, X } from "lucide-react";
|
||||
import type { AdminCourse } from "@/lib/data/admin/courses";
|
||||
import { AdminFormCard } from "@/components/organisms/admin/AdminPage";
|
||||
|
||||
const SUGGESTED_TAGS = [
|
||||
"کارگاهها",
|
||||
"دورههای سازمانی",
|
||||
"گزیده دورههای برگزار شده",
|
||||
];
|
||||
|
||||
type Payload = {
|
||||
slug: string;
|
||||
title: string;
|
||||
@@ -28,8 +36,10 @@ type Payload = {
|
||||
format: string;
|
||||
price: number | null;
|
||||
registrationUrl: string;
|
||||
imageUrl: string;
|
||||
posterImageUrl: string;
|
||||
brochureImageUrl: string;
|
||||
seoDescription: string;
|
||||
tags: string[];
|
||||
published: boolean;
|
||||
};
|
||||
|
||||
@@ -49,13 +59,16 @@ export function CourseForm({ initial }: CourseFormProps) {
|
||||
format: initial?.format ?? "in-person",
|
||||
price: initial?.price ?? null,
|
||||
registrationUrl: initial?.registrationUrl ?? "/register/",
|
||||
imageUrl: initial?.imageUrl ?? "",
|
||||
posterImageUrl: initial?.posterImageUrl ?? "",
|
||||
brochureImageUrl: initial?.brochureImageUrl ?? "",
|
||||
seoDescription: initial?.seoDescription ?? "",
|
||||
tags: initial?.tags ?? [],
|
||||
published: initial?.published ?? true,
|
||||
});
|
||||
const [priceInput, setPriceInput] = useState(
|
||||
initial?.price != null ? String(initial.price) : "",
|
||||
);
|
||||
const [customTagInput, setCustomTagInput] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
@@ -63,6 +76,29 @@ export function CourseForm({ initial }: CourseFormProps) {
|
||||
setForm((f) => ({ ...f, [key]: value }));
|
||||
}
|
||||
|
||||
function toggleTag(tag: string) {
|
||||
setForm((f) => {
|
||||
const exists = f.tags.includes(tag);
|
||||
return {
|
||||
...f,
|
||||
tags: exists ? f.tags.filter((t) => t !== tag) : [...f.tags, tag],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function addCustomTag() {
|
||||
const trimmed = customTagInput.trim();
|
||||
if (!trimmed) return;
|
||||
if (!form.tags.includes(trimmed)) {
|
||||
set("tags", [...form.tags, trimmed]);
|
||||
}
|
||||
setCustomTagInput("");
|
||||
}
|
||||
|
||||
function removeTag(tagToRemove: string) {
|
||||
set("tags", form.tags.filter((t) => t !== tagToRemove));
|
||||
}
|
||||
|
||||
function onPriceChange(raw: string) {
|
||||
setPriceInput(raw);
|
||||
const trimmed = raw.trim();
|
||||
@@ -243,6 +279,94 @@ export function CourseForm({ initial }: CourseFormProps) {
|
||||
|
||||
<Separator />
|
||||
|
||||
<section className="space-y-4">
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold text-foreground">تگها و دستهبندی</h2>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
||||
برچسبهایی که دوره در فیلترها و دستهبندی سایت نمایش داده میشود (مثلاً کارگاهها، دورههای سازمانی، گزیده دورههای برگزارشده)
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<Label className="text-xs text-muted-foreground">تگهای پیشنهادی</Label>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
{SUGGESTED_TAGS.map((tag) => {
|
||||
const active = form.tags.includes(tag);
|
||||
return (
|
||||
<Button
|
||||
key={tag}
|
||||
type="button"
|
||||
size="sm"
|
||||
variant={active ? "default" : "outline"}
|
||||
aria-pressed={active}
|
||||
onClick={() => toggleTag(tag)}
|
||||
className="h-8 px-3 text-xs"
|
||||
>
|
||||
{tag}
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-end gap-2">
|
||||
<div className="flex-1 space-y-1.5">
|
||||
<Label htmlFor="newTag">افزودن تگ دلخواه</Label>
|
||||
<Input
|
||||
id="newTag"
|
||||
value={customTagInput}
|
||||
onChange={(e) => setCustomTagInput(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
addCustomTag();
|
||||
}
|
||||
}}
|
||||
placeholder="مثلاً دورههای ویژه مدیران"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={addCustomTag}
|
||||
className="shrink-0"
|
||||
>
|
||||
<Plus className="size-4" />
|
||||
افزودن
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label className="text-xs text-muted-foreground">
|
||||
تگهای این دوره ({form.tags.length})
|
||||
</Label>
|
||||
{form.tags.length > 0 ? (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{form.tags.map((tag) => (
|
||||
<Badge key={tag} variant="secondary" className="gap-1 py-1 pe-1">
|
||||
{tag}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => removeTag(tag)}
|
||||
className="rounded-full p-0.5 transition-colors hover:bg-foreground/10"
|
||||
aria-label={`حذف تگ ${tag}`}
|
||||
>
|
||||
<X className="size-3" />
|
||||
</button>
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
هنوز تگی برای این دوره انتخاب نشده است.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Separator />
|
||||
|
||||
<section className="space-y-4">
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold text-foreground">رسانه و انتشار</h2>
|
||||
@@ -261,11 +385,20 @@ export function CourseForm({ initial }: CourseFormProps) {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5 sm:col-span-2">
|
||||
<Label htmlFor="imageUrl">آدرس تصویر</Label>
|
||||
<Label htmlFor="posterImageUrl">آدرس پوستر (نمایش در لیست دورهها)</Label>
|
||||
<Input
|
||||
id="imageUrl"
|
||||
value={form.imageUrl}
|
||||
onChange={(e) => set("imageUrl", e.target.value)}
|
||||
id="posterImageUrl"
|
||||
value={form.posterImageUrl}
|
||||
onChange={(e) => set("posterImageUrl", e.target.value)}
|
||||
placeholder="/images/courses/..."
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5 sm:col-span-2">
|
||||
<Label htmlFor="brochureImageUrl">آدرس بروشور (نمایش در صفحه جزئیات)</Label>
|
||||
<Input
|
||||
id="brochureImageUrl"
|
||||
value={form.brochureImageUrl}
|
||||
onChange={(e) => set("brochureImageUrl", e.target.value)}
|
||||
placeholder="/images/courses/..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,18 @@ export function CourseTable({ courses }: { courses: AdminCourse[] }) {
|
||||
<TableBody>
|
||||
{courses.map((course) => (
|
||||
<TableRow key={course.id}>
|
||||
<TableCell className="font-medium">{course.title}</TableCell>
|
||||
<TableCell className="font-medium">
|
||||
<div>{course.title}</div>
|
||||
{course.tags && course.tags.length > 0 ? (
|
||||
<div className="mt-1 flex flex-wrap gap-1">
|
||||
{course.tags.map((tag) => (
|
||||
<Badge key={tag} variant="outline" className="text-[10px] px-1.5 py-0">
|
||||
{tag}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant="secondary">{categoryLabel(course.category)}</Badge>
|
||||
</TableCell>
|
||||
|
||||
Reference in new issue
Block a user