diff --git a/.gitignore b/.gitignore
index 81fbba6..204cdb5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
# dependencies
/node_modules
+/.npm-cache
/.pnp
.pnp.*
.yarn/*
diff --git a/db/migrations/011_course_priority.sql b/db/migrations/011_course_priority.sql
new file mode 100644
index 0000000..3c5effe
--- /dev/null
+++ b/db/migrations/011_course_priority.sql
@@ -0,0 +1,5 @@
+-- Catalog pin + manual order for current courses.
+-- Archive grouping still uses tag-archive; featured never lifts an archive course.
+ALTER TABLE courses
+ ADD COLUMN IF NOT EXISTS featured BOOLEAN NOT NULL DEFAULT false,
+ ADD COLUMN IF NOT EXISTS sort_order INT NOT NULL DEFAULT 0;
diff --git a/db/seed.mjs b/db/seed.mjs
index fc44d9c..02a1173 100644
--- a/db/seed.mjs
+++ b/db/seed.mjs
@@ -122,7 +122,8 @@ async function main() {
await upsert("courses", courses.map(courseToRow), [
"id", "slug", "title", "summary", "duration_hours", "format", "price",
"registration_url", "poster_image_url", "brochure_image_url", "image_url",
- "lead_html", "body_html", "seo_description", "published",
+ "lead_html", "body_html", "seo_description", "published", "featured",
+ "sort_order",
]);
const courseIds = courses.map((c) => c.id);
await client.query(
diff --git a/docs/02-domain-rules.md b/docs/02-domain-rules.md
index e4a4ae6..a79c879 100644
--- a/docs/02-domain-rules.md
+++ b/docs/02-domain-rules.md
@@ -47,6 +47,8 @@
|---|---|
| `course.categories` | many-to-many با `course_categories` (موضوع؛ ادمین) |
| `course.tags` | many-to-many با `course_tags` (نوع/منو؛ ادمین) |
+| `course.featured` | تیک ویژه؛ چند دورهٔ جاری میتوانند ویژه باشند (محدودیت تکویژهٔ مقاله اینجا نیست) |
+| `course.sortOrder` | عدد ترتیب؛ کوچکتر جلوتر (مثل دسته/تگ) |
| `program.group` | `standard` یا `executive` برای selector هوم |
| `event.endDate` | اگر null باشد رویداد تکروزه است |
| `article.featured` | حداکثر یک مقاله featured در هوم |
@@ -58,6 +60,8 @@
- هیچ مبلغ/ظرفیت واقعی محاسبه نمیشود تا DB وصل شود.
- منوی صفحهٔ اصلی فقط **یک** دراپداون دوره دارد؛ لیبل ریشه = `courseNavParentTag`؛ فرزندان = تگهای `show_in_nav`. فیلتر پایدار با **slug**: `/professional?tag=` و `/professional?category=` (مستند: `docs/LINKS.md`).
- دسته و تگ فقط از ادمین تعریف میشوند (`/admin/course-categories`، `/admin/course-tags`)؛ هر دوره میتواند چند دسته و چند تگ داشته باشد.
+- ترتیب لیست عمومی دوره: غیرآرشیو، سپس `featured`، سپس `sort_order` صعودی، سپس عنوان. هوم و جستجو همین ترتیب را میگیرند؛ هوم آرشیو را نشان نمیدهد.
+- تگ `archive` (گزیدهٔ برگزارشده) در کتالوگ بلوک جدا و ظاهر ملایمتر است؛ `featured` دورهٔ آرشیو را به بلوک جاری بالا نمیآورد.
## Locale / Format Rules
- زبان UI: فارسی؛ `dir="rtl"`؛ اعداد نمایشی میتوانند فارسیسازی شوند در لایهٔ UI.
diff --git a/docs/03-database.md b/docs/03-database.md
index 906ed68..2566c70 100644
--- a/docs/03-database.md
+++ b/docs/03-database.md
@@ -76,7 +76,7 @@ node scripts/test-db-connection.mjs
| جدول | نکته |
|---|---|
-| `courses` | `category`/`format` با CHECK؛ `slug` UNIQUE؛ `price` اختیاری (تومان، NULL = مخفی در UI) |
+| `courses` | `format` با CHECK؛ `slug` UNIQUE؛ `price` اختیاری؛ `featured` + `sort_order` (migration 011) |
| `programs` | `group_key` (بهجای reserve واژهٔ `group`)؛ `highlights` JSONB |
| `events` | `start_date`/`end_date` DATE؛ `end_date` NULL = تکروزه |
| `articles` | `featured` + ایندکس جزئی `articles_one_featured` (حداکثر یک مقالهٔ published با `featured=true`) |
@@ -98,6 +98,12 @@ node scripts/test-db-connection.mjs
- `idx_programs_title` / `idx_courses_title` روی `(published, title)`.
- `courses.slug`, `programs.slug`, `intersection_topics.slug` از 001 UNIQUE هستند و ایندکس جزئی `articles_one_featured` از 001 موجود است — تکرار نشدهاند.
+## اولویت کاتالوگ (011)
+
+- Migration: `db/migrations/011_course_priority.sql`.
+- `courses.featured BOOLEAN NOT NULL DEFAULT false` و `courses.sort_order INT NOT NULL DEFAULT 0`.
+- لیست عمومی: غیرآرشیو (`tag-archive`) سپس ویژه سپس `sort_order` سپس عنوان. آرشیو با تگ جدا میشود، نه با ستون جدید.
+
## Admin (فاز E — 2026-09-22)
- مکانیزم: `admin_users` (رمز با scrypt در `password_hash`، هرگز plaintext) + `admin_sessions` (توکن تصادفی؛ `token_hash` در DB ذخیره میشود؛ cookie فقط `admin_session` HttpOnly/SameSite=Lax).
diff --git a/docs/LINKS.md b/docs/LINKS.md
index 0ddc454..f52e236 100644
--- a/docs/LINKS.md
+++ b/docs/LINKS.md
@@ -10,6 +10,7 @@
| فیلتر با تگ | `/professional?tag=` |
| فیلتر با دسته | `/professional?category=` |
| هر دو فیلتر | `/professional?tag=&category=` |
+| گزیدهٔ برگزارشده | `/professional?tag=archive` (در لیست کامل، بلوک جدا زیر دورههای جاری) |
### تگ پدر (لیبل منو)
diff --git a/docs/log/decisions.md b/docs/log/decisions.md
index 7f75101..96d35c9 100644
--- a/docs/log/decisions.md
+++ b/docs/log/decisions.md
@@ -30,3 +30,4 @@
| 2026-09-24 | D23 — پایان H: حذف کامل وابستگی runtime به mock برای محتوای با تیبل: `intersections`، `stats`، `testimonials` از DB میآیند (`getTopics`، `getSiteStats`، `getTestimonials` در `lib/data/site.ts`؛ `HomeRest` با prop `stats`)؛ هویت/ناو استاتیکِ بدونتیبل به ماژول مستقل `src/lib/site-config.ts` منتقل شد؛ `src/lib/mock/site.ts` فقط برای seed باقی ماند (کامنت هدر دارد)؛ ایندکسها با `db/migrations/002_indexes.sql` (leads/articles/events/programs/courses)؛ اسکریپت `scripts/smoke.mjs` (۴ API عمومی + login + create/delete stat) | معیار پذیرش C/H: runtime هیچ import مستقیمی از mock ندارد؛ config بدون تیبل نباید «دادهٔ mock» تلقی شود؛ smoke خواندنی + یک write ادمین میسنجد |
| 2026-10-12 | D25 — تاکسونومی دوره دو لایهٔ ادمینمحور: `course_categories` (موضوع) + `course_tags` (نوع/منو) با junction many-to-many؛ حذف `courses.category` enum و `courses.tags` text[]؛ لینک پایدار با slug (`?tag=` / `?category=`)؛ CRUD در `/admin/course-categories` و `/admin/course-tags` | دسته و تگ باید پویا و قابل تعریف در ادمین باشند؛ لیبل فارسی جدا از slug است |
| 2026-10-11 | D24 — آپلود تصویر ادمین: `POST /api/admin/upload` (multipart، فقط ادمین) فایل را در `public/uploads/{folder}/` مینویسد و مسیر عمومی `/uploads/...` برمیگرداند؛ UI با `ImageUploadField` در `CourseForm` و فیلد نوع `image` در `GenericForm`/`entities` (articles/topics/faculty/alumni)؛ persistence در Docker با volume `uploads_data` و env `UPLOAD_DIR` | ورود دستی URL اشتباه بود؛ ادمین باید فایل بارگذاری کند؛ ستونهای DB همچنان path/URL میمانند |
+| 2026-10-22 | D26 — اولویت کاتالوگ: `courses.featured` + `courses.sort_order` (migration 011)؛ ترتیب عمومی غیرآرشیو → ویژه → ترتیب → عنوان؛ تگ `archive` در کتالوگ بلوک جدا با کارت ملایمتر است و از هوم حذف میماند | چند دورهٔ جاری باید جلو بیایند و گزیدهٔ برگزارشده از لیست جاری جدا دیده شود |
diff --git a/docs/state/active-context.md b/docs/state/active-context.md
index 579d39f..e396cf8 100644
--- a/docs/state/active-context.md
+++ b/docs/state/active-context.md
@@ -1,11 +1,10 @@
# Active Context
## Current Goal
-چکلیست UI در `docs/Todo.Md` پیاده شد؛ سه آیتم blocked منتظر کاربر.
+اولویت نمایش دورهها (ویژه + ترتیب) و جداسازی گزیدهٔ برگزارشده در کتالوگ.
## Current Work
-- انجامشده: هدر/ناو/فوتر، فونت Vazirmatn، هوم، سرچ/کارت دورهها، اسکیما اساتید (`profile_url` + `course_faculty_links`)
-- لوگو دانشکده اعمال شد (`/brand/mst-faculty.png` + favicon)
+- انجامشده: `featured`/`sort_order` روی `courses`، ادمین، Badge ویژه، بلوک آرشیو جدا در `/professional`
- Blocked: پالت رنگی mst (۱۱)، seed اساتید پس از دسترسی (۱۷c)
## Current Blockers
@@ -13,5 +12,6 @@
- دسترسی به شبکه اساتید mst برای کپی داده
## Next Steps
-1. دریافت پالت و بهروزرسانی توکنهای `globals.css`
-2. پس از دسترسی mst: seed اساتید با `profileUrl`
+1. در ادمین، دورههای مهم جاری را ویژه/مرتب کنید
+2. دریافت پالت و بهروزرسانی توکنهای `globals.css`
+3. پس از دسترسی mst: seed اساتید با `profileUrl`
diff --git a/docs/state/progress.md b/docs/state/progress.md
index 905a20c..c07189a 100644
--- a/docs/state/progress.md
+++ b/docs/state/progress.md
@@ -39,10 +39,12 @@
- [x] منوی هوم: یک دراپداون از تگها؛ `courseNavParentTag`؛ لینک پایدار
- [x] D25 تاکسونومی ادمینمحور: دسته + تگ many-to-many؛ migration 007؛ CRUD ادمین؛ فیلتر `?tag=`/`?category=` با slug
+- [x] D26 اولویت کاتالوگ: `featured` + `sort_order` (migration 011)؛ بلوک جدا برای تگ `archive`
## Next
- [x] فاز H باقیمانده — ایندکسها، docs/README نهایی، حذف وابستگی runtime به mock، smoke script
- [x] Todo UI سایت (هدر/هوم/دورهها/فونت/اسکیما اساتید) — جزئیات در `docs/Todo.Md`
+- [x] D26 اولویت دوره + جداسازی گزیدهٔ برگزارشده
- [ ] محتوای واقعی از پنل ادمین (طبق دستور کاربر بعداً)
- [x] لوگوی دانشکده (نشان بدون متن کناری + favicon)
- [ ] Todo blocked: پالت mst، seed اساتید از شبکه دانشکده
diff --git a/next.config.ts b/next.config.ts
index 889d356..d62a0ad 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -7,6 +7,10 @@ const nextConfig: NextConfig = {
output: "standalone",
// Babel React Compiler is heavy in Docker/CI; keep it for local `next dev`.
reactCompiler: process.env.DISABLE_REACT_COMPILER !== "1",
+ // VPS deploy sets SKIP_TYPECHECK=1. `npm run build` locally still typechecks.
+ typescript: {
+ ignoreBuildErrors: process.env.SKIP_TYPECHECK === "1",
+ },
experimental: {
optimizePackageImports: ["lucide-react"],
},
diff --git a/scripts/vps-autodeploy.sh b/scripts/vps-autodeploy.sh
index f93e470..dbca747 100644
--- a/scripts/vps-autodeploy.sh
+++ b/scripts/vps-autodeploy.sh
@@ -13,14 +13,23 @@ export NODE_OPTIONS="${NODE_OPTIONS:---max-old-space-size=3072}"
echo "Building Next.js at $ROOT (Node 22 container)…"
# No BuildKit cache mounts — stock docker on the VPS does not support type=cache.
+# A normal host directory works. .next/cache stays on the checkout between deploys
+# so webpack can reuse it. Do not delete it here.
+NPM_CACHE=/var/cache/edu-npm
+if ! mkdir -p "$NPM_CACHE" 2>/dev/null; then
+ NPM_CACHE="$ROOT/.npm-cache"
+ mkdir -p "$NPM_CACHE"
+fi
docker run --rm \
-e DISABLE_REACT_COMPILER=1 \
-e NEXT_TELEMETRY_DISABLED=1 \
-e NEXT_PUBLIC_SITE_URL \
-e NODE_OPTIONS \
+ -e SKIP_TYPECHECK=1 \
-v "$ROOT:/app" -w /app \
+ -v "$NPM_CACHE:/root/.npm" \
node:22-alpine \
- sh -ec 'npm ci --no-audit --no-fund && npm run build'
+ sh /app/scripts/vps-next-build.sh
bash scripts/assemble-prebuilt.sh "$ROOT/prebuilt"
rm -rf "$ROOT/prebuilt/static"
diff --git a/scripts/vps-next-build.sh b/scripts/vps-next-build.sh
new file mode 100644
index 0000000..34b366f
--- /dev/null
+++ b/scripts/vps-next-build.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Runs inside node:22-alpine with the repo mounted at /app.
+# npm cache is a host directory mounted at /root/.npm (BuildKit cache mounts
+# are unavailable on the VPS Docker).
+set -eu
+cd /app
+
+lock=$(sha256sum package-lock.json | awk 'NR==1 { print $1 }')
+node_ver=$(node -v)
+stamp="node_modules/.install-stamp"
+want="$lock $node_ver"
+
+if [ -d node_modules/next ] && [ -f "$stamp" ] && [ "$(cat "$stamp")" = "$want" ]; then
+ echo "Dependencies unchanged ($node_ver); skipping npm ci"
+else
+ echo "Installing dependencies ($node_ver)…"
+ npm ci --no-audit --no-fund --prefer-offline --cache /root/.npm
+ printf '%s\n' "$want" > "$stamp"
+fi
+
+npm run build
diff --git a/src/app/api/admin/courses/[id]/route.ts b/src/app/api/admin/courses/[id]/route.ts
index 6c4e46d..efef712 100644
--- a/src/app/api/admin/courses/[id]/route.ts
+++ b/src/app/api/admin/courses/[id]/route.ts
@@ -47,6 +47,8 @@ const COURSE_COLUMNS: Record = {
bodyHtml: "body_html",
seoDescription: "seo_description",
published: "published",
+ featured: "featured",
+ sortOrder: "sort_order",
};
// PATCH /api/admin/courses/[id] — update course (admin only)
diff --git a/src/app/api/admin/courses/route.ts b/src/app/api/admin/courses/route.ts
index 35d7568..d08af88 100644
--- a/src/app/api/admin/courses/route.ts
+++ b/src/app/api/admin/courses/route.ts
@@ -65,8 +65,8 @@ export async function POST(request: NextRequest) {
`INSERT INTO courses
(id, slug, title, summary, duration_hours, format, price,
registration_url, poster_image_url, brochure_image_url, image_url,
- lead_html, body_html, seo_description, published)
- VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)`,
+ lead_html, body_html, seo_description, published, featured, sort_order)
+ VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17)`,
[
id,
d.slug,
@@ -83,6 +83,8 @@ export async function POST(request: NextRequest) {
d.bodyHtml,
d.seoDescription,
d.published,
+ d.featured,
+ d.sortOrder,
],
);
await setCourseCategories(id, d.categoryIds ?? []);
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 54e14e9..6429e7d 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -2,6 +2,8 @@ import type { Metadata, Viewport } from "next";
import { Vazirmatn } from "next/font/google";
import { NextIntlClientProvider } from "next-intl";
import { getLocale, getMessages, getTranslations } from "next-intl/server";
+import { Suspense } from "react";
+import { GlobalActionLoadingOverlay } from "@/components/molecules/GlobalActionLoadingOverlay";
import { getSiteOrigin } from "@/lib/seo/metadata";
import { JsonLd, organizationJsonLd } from "@/lib/seo/json-ld";
import "./globals.css";
@@ -78,6 +80,9 @@ export default async function RootLayout({
className={`${vazirmatn.className} flex min-h-full min-w-0 flex-col font-sans`}
>
+
+
+
string;
+ tagHref: (slug: string) => string;
+}) {
+ const priceLabel = formatCoursePrice(course.price);
+ const isArchive = variant === "archive";
+ const showFeatured = !isArchive && Boolean(course.featured);
+
+ return (
+
+
+
+
+ {showFeatured ? (
+
+ ویژه
+
+ ) : null}
+
+ {course.title}
+
+
+
+
+ {course.summary}
+
+ {course.categories.length > 0 || course.tags.length > 0 ? (
+
+ {course.categories.map((c) => {
+ const href = categoryHref(c.slug);
+ const active = categorySlug === c.slug;
+ return (
+
+
+ {c.label}
+
+
+ );
+ })}
+ {course.tags.map((t) => {
+ const href = tagHref(t.slug);
+ const active = tagSlug === t.slug;
+ return (
+
+
+ {t.label}
+
+
+ );
+ })}
+
+ ) : null}
+
+
+ {course.durationHours
+ ? `${course.durationHours} ساعت · ${formatLabel(course.format)}`
+ : formatLabel(course.format)}
+
+ {priceLabel ? (
+
+ {priceLabel}
+
+ ) : null}
+
+
+ {isArchive ? "مشاهده جزئیات" : "جزئیات و ثبت نام"}
+
+
+
+ );
+}
diff --git a/src/components/molecules/GlobalActionLoadingOverlay.tsx b/src/components/molecules/GlobalActionLoadingOverlay.tsx
new file mode 100644
index 0000000..accc9ed
--- /dev/null
+++ b/src/components/molecules/GlobalActionLoadingOverlay.tsx
@@ -0,0 +1,239 @@
+"use client";
+
+import { usePathname, useSearchParams } from "next/navigation";
+import { useCallback, useEffect, useRef, useState } from "react";
+import {
+ GLOBAL_ACTION_LOADING_START,
+ GLOBAL_ACTION_LOADING_STOP,
+} from "@/lib/global-action-loading";
+import { cn } from "@/lib/utils";
+
+const MIN_VISIBLE_MS = 320;
+const STALL_MS = 25_000;
+
+function routeKey(pathname: string, search: string) {
+ return `${pathname}?${search}`;
+}
+
+function isModifiedPointer(event: MouseEvent) {
+ return (
+ event.button !== 0 ||
+ event.metaKey ||
+ event.ctrlKey ||
+ event.shiftKey ||
+ event.altKey
+ );
+}
+
+function isOptedOut(element: Element) {
+ return Boolean(element.closest("[data-no-action-loading]"));
+}
+
+function isInternalAnchor(anchor: HTMLAnchorElement) {
+ if (anchor.target === "_blank" || anchor.hasAttribute("download")) {
+ return false;
+ }
+ const href = anchor.getAttribute("href");
+ if (!href || href.startsWith("#") || href.startsWith("mailto:") || href.startsWith("tel:")) {
+ return false;
+ }
+ try {
+ const url = new URL(href, window.location.href);
+ return url.origin === window.location.origin;
+ } catch {
+ return false;
+ }
+}
+
+export function GlobalActionLoadingOverlay() {
+ const pathname = usePathname();
+ const searchParams = useSearchParams();
+ const search = searchParams.toString();
+ const currentRouteKey = routeKey(pathname, search);
+
+ const [visible, setVisible] = useState(false);
+
+ const activeRef = useRef(false);
+ const startedAtRef = useRef(0);
+ const inflightRef = useRef(0);
+ const prevRouteKeyRef = useRef(null);
+ const finishTimerRef = useRef(null);
+ const hideTimerRef = useRef(null);
+ const stallTimerRef = useRef(null);
+
+ const clearTimers = useCallback(() => {
+ if (finishTimerRef.current != null) {
+ window.clearTimeout(finishTimerRef.current);
+ finishTimerRef.current = null;
+ }
+ if (hideTimerRef.current != null) {
+ window.clearTimeout(hideTimerRef.current);
+ hideTimerRef.current = null;
+ }
+ if (stallTimerRef.current != null) {
+ window.clearTimeout(stallTimerRef.current);
+ stallTimerRef.current = null;
+ }
+ }, []);
+
+ const hide = useCallback(() => {
+ activeRef.current = false;
+ inflightRef.current = 0;
+ clearTimers();
+ setVisible(false);
+ }, [clearTimers]);
+
+ const scheduleFinish = useCallback(() => {
+ if (!activeRef.current) {
+ return;
+ }
+ if (inflightRef.current > 0) {
+ return;
+ }
+
+ const elapsed = Date.now() - startedAtRef.current;
+ const delay = Math.max(MIN_VISIBLE_MS - elapsed, 0);
+
+ if (finishTimerRef.current != null) {
+ window.clearTimeout(finishTimerRef.current);
+ }
+
+ finishTimerRef.current = window.setTimeout(() => {
+ if (!activeRef.current || inflightRef.current > 0) {
+ return;
+ }
+ activeRef.current = false;
+ hideTimerRef.current = window.setTimeout(() => setVisible(false), 180);
+ }, delay);
+ }, []);
+
+ const start = useCallback(() => {
+ clearTimers();
+ activeRef.current = true;
+ startedAtRef.current = Date.now();
+ inflightRef.current = 0;
+ setVisible(true);
+
+ stallTimerRef.current = window.setTimeout(() => {
+ if (activeRef.current) {
+ hide();
+ }
+ }, STALL_MS);
+ }, [clearTimers, hide]);
+
+ useEffect(() => {
+ if (prevRouteKeyRef.current === null) {
+ prevRouteKeyRef.current = currentRouteKey;
+ return;
+ }
+ if (prevRouteKeyRef.current !== currentRouteKey) {
+ prevRouteKeyRef.current = currentRouteKey;
+ if (activeRef.current) {
+ scheduleFinish();
+ }
+ }
+ }, [currentRouteKey, scheduleFinish]);
+
+ useEffect(() => {
+ const originalFetch = window.fetch.bind(window);
+
+ window.fetch = async (...args) => {
+ if (activeRef.current) {
+ inflightRef.current += 1;
+ }
+ try {
+ return await originalFetch(...args);
+ } finally {
+ if (activeRef.current && inflightRef.current > 0) {
+ inflightRef.current -= 1;
+ if (inflightRef.current === 0) {
+ scheduleFinish();
+ }
+ }
+ }
+ };
+
+ return () => {
+ window.fetch = originalFetch;
+ };
+ }, [scheduleFinish]);
+
+ useEffect(() => {
+ const onActionClick = (event: MouseEvent) => {
+ if (event.defaultPrevented || isModifiedPointer(event)) {
+ return;
+ }
+ const target = event.target;
+ if (!(target instanceof Element) || isOptedOut(target)) {
+ return;
+ }
+
+ const anchor = target.closest("a");
+ if (anchor && isInternalAnchor(anchor)) {
+ const href = anchor.getAttribute("href");
+ if (!href) {
+ return;
+ }
+ try {
+ const url = new URL(href, window.location.href);
+ const targetKey = routeKey(url.pathname, url.searchParams.toString());
+ if (targetKey !== currentRouteKey) {
+ start();
+ }
+ } catch {
+ /* ignore */
+ }
+ return;
+ }
+
+ const button = target.closest('[data-slot="button"], button, input[type="submit"]');
+ if (button instanceof HTMLElement && !button.hasAttribute("disabled")) {
+ if (button.closest("a")) {
+ return;
+ }
+ start();
+ window.setTimeout(() => {
+ if (activeRef.current && inflightRef.current === 0) {
+ scheduleFinish();
+ }
+ }, 64);
+ }
+ };
+
+ const onSubmit = (event: Event) => {
+ const form = event.target;
+ if (!(form instanceof HTMLFormElement) || isOptedOut(form)) {
+ return;
+ }
+ start();
+ };
+
+ const onManualStart = () => start();
+ const onManualStop = () => hide();
+
+ document.addEventListener("click", onActionClick, true);
+ document.addEventListener("submit", onSubmit, true);
+ window.addEventListener(GLOBAL_ACTION_LOADING_START, onManualStart);
+ window.addEventListener(GLOBAL_ACTION_LOADING_STOP, onManualStop);
+
+ return () => {
+ document.removeEventListener("click", onActionClick, true);
+ document.removeEventListener("submit", onSubmit, true);
+ window.removeEventListener(GLOBAL_ACTION_LOADING_START, onManualStart);
+ window.removeEventListener(GLOBAL_ACTION_LOADING_STOP, onManualStop);
+ };
+ }, [currentRouteKey, hide, scheduleFinish, start]);
+
+ useEffect(() => () => clearTimers(), [clearTimers]);
+
+ return (
+
+ );
+}
diff --git a/src/components/organisms/CategoryCourseExplorer.tsx b/src/components/organisms/CategoryCourseExplorer.tsx
index a3b1fb6..8cb0ee6 100644
--- a/src/components/organisms/CategoryCourseExplorer.tsx
+++ b/src/components/organisms/CategoryCourseExplorer.tsx
@@ -7,22 +7,20 @@ import { Search, X } from "lucide-react";
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,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
-import { CourseCardBanner } from "@/components/molecules/CourseCardBanner";
+import { Separator } from "@/components/ui/separator";
+import { Heading } from "@/components/atoms/Heading";
+import { CourseCatalogCard } from "@/components/molecules/CourseCatalogCard";
import type { Course, TaxonomyRef } from "@/lib/types";
+import {
+ ARCHIVE_SECTION_LABEL,
+ ARCHIVE_TAG_SLUG,
+ isArchiveCourse,
+} from "@/lib/course-catalog";
import {
courseCatalogHref,
courseCategoryHref,
courseTagHref,
} from "@/lib/course-nav";
-import { formatCoursePrice, formatLabel } from "@/lib/labels";
import { cn } from "@/lib/utils";
const categoryChipClass =
@@ -119,6 +117,20 @@ export function CategoryCourseExplorer({
});
}, [courses, categorySlug, tagSlug, deferredQuery]);
+ const { currentCourses, archiveCourses } = useMemo(() => {
+ const current: Course[] = [];
+ const archive: Course[] = [];
+ for (const course of filtered) {
+ if (isArchiveCourse(course)) archive.push(course);
+ else current.push(course);
+ }
+ return { currentCourses: current, archiveCourses: archive };
+ }, [filtered]);
+
+ const archiveLabel =
+ filterTags.find((tag) => tag.slug === ARCHIVE_TAG_SLUG)?.label ??
+ ARCHIVE_SECTION_LABEL;
+
const hasFilters = tagSlug !== "" || categorySlug !== "" || query !== "";
const resetFilters = () => {
@@ -337,108 +349,78 @@ export function CategoryCourseExplorer({
دوره ای با این فیلتر ها یافت نشد.
) : (
-
- {filtered.map((course) => {
- const priceLabel = formatCoursePrice(course.price);
- return (
-
- {/* Full-card hit target sits under content; badges use pointer-events-auto */}
-
-
-
-
- {course.title}
-
-
-
-
- {course.summary}
-
- {(course.categories.length > 0 || course.tags.length > 0) && (
-
- {course.categories.map((c) => {
- const href = categoryHref(c.slug);
- const active = categorySlug === c.slug;
- return (
-
-
- {c.label}
-
-
- );
- })}
- {course.tags.map((t) => {
- const href = tagHref(t.slug);
- const active = tagSlug === t.slug;
- return (
-
-
- {t.label}
-
-
- );
- })}
-
- )}
-
-
- {course.durationHours
- ? `${course.durationHours} ساعت · ${formatLabel(course.format)}`
- : formatLabel(course.format)}
-
- {priceLabel ? (
-
- {priceLabel}
-
- ) : null}
-
-
- جزئیات و ثبت نام
-
-
-
- );
- })}
+
+ {currentCourses.length > 0 ? (
+
+ ) : null}
+ {currentCourses.length > 0 && archiveCourses.length > 0 ? (
+
+ ) : null}
+ {archiveCourses.length > 0 ? (
+
+
+ {archiveLabel}
+
+
+
+ ) : null}
)}
);
}
+
+function CourseCatalogGrid({
+ courses,
+ variant,
+ isStale,
+ categorySlug,
+ tagSlug,
+ categoryHref,
+ tagHref,
+}: {
+ courses: Course[];
+ variant: "current" | "archive";
+ isStale: boolean;
+ categorySlug: string;
+ tagSlug: string;
+ categoryHref: (slug: string) => string;
+ tagHref: (slug: string) => string;
+}) {
+ return (
+
+ {courses.map((course) => (
+
+ ))}
+
+ );
+}
diff --git a/src/components/organisms/SearchOverlay.tsx b/src/components/organisms/SearchOverlay.tsx
index a3e7023..d75ca2c 100644
--- a/src/components/organisms/SearchOverlay.tsx
+++ b/src/components/organisms/SearchOverlay.tsx
@@ -64,6 +64,7 @@ export function SearchOverlay({