Compare commits
7
Commits
fe3d153ef1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a60718aaf9 | ||
|
|
2858b9c746 | ||
|
|
8cf4490f21 | ||
|
|
4b84409ed7 | ||
|
|
1641edfd01 | ||
|
|
0a57ef2b80 | ||
|
|
7d7b55f060 |
No files matched your search
+4
-3
@@ -2,6 +2,7 @@
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.npm-cache
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
@@ -24,9 +25,9 @@
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# admin-uploaded images (keep folder via .gitkeep)
|
||||
/public/uploads/*
|
||||
!/public/uploads/.gitkeep
|
||||
# admin-uploaded images (served by GET /uploads/[...path], not public/)
|
||||
/uploads/
|
||||
/public/uploads/
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
|
||||
+5
-2
@@ -36,8 +36,11 @@ COPY --from=builder /app/public ./public
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
# Writable dir for admin image uploads (mount a volume in compose for persistence)
|
||||
RUN mkdir -p ./public/uploads && chown -R nextjs:nodejs ./public/uploads
|
||||
# Writable dir for admin image uploads (mount a volume in compose for persistence).
|
||||
# Keep this outside public/: Next standalone does not serve runtime public files.
|
||||
RUN rm -rf ./public/uploads \
|
||||
&& mkdir -p ./uploads \
|
||||
&& chown -R nextjs:nodejs ./uploads
|
||||
|
||||
USER nextjs
|
||||
|
||||
|
||||
+5
-2
@@ -18,8 +18,11 @@ COPY --chown=nextjs:nodejs . ./
|
||||
# Next warns/breaks if a legacy root-level ./static exists alongside ./public
|
||||
RUN rm -rf ./static
|
||||
|
||||
# Writable dir for admin image uploads (mount a volume in compose for persistence)
|
||||
RUN mkdir -p ./public/uploads && chown -R nextjs:nodejs ./public/uploads
|
||||
# Writable dir for admin image uploads (mount a volume in compose for persistence).
|
||||
# Keep this outside public/: Next standalone does not serve runtime public files.
|
||||
RUN rm -rf ./public/uploads \
|
||||
&& mkdir -p ./uploads \
|
||||
&& chown -R nextjs:nodejs ./uploads
|
||||
|
||||
USER nextjs
|
||||
EXPOSE 3000
|
||||
|
||||
@@ -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;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Public sections other than courses are retired.
|
||||
-- Drop their rows so they cannot be served or listed again.
|
||||
DELETE FROM articles;
|
||||
DELETE FROM events;
|
||||
DELETE FROM programs;
|
||||
DELETE FROM intersection_topics;
|
||||
DELETE FROM alumni_stories;
|
||||
DELETE FROM testimonials;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Optional schedule for a course: when it starts, and when it is held.
|
||||
ALTER TABLE courses
|
||||
ADD COLUMN IF NOT EXISTS start_date DATE,
|
||||
ADD COLUMN IF NOT EXISTS held_date DATE;
|
||||
@@ -0,0 +1,21 @@
|
||||
-- News items shown on /news. Separate from articles (long-form insights).
|
||||
|
||||
CREATE TABLE IF NOT EXISTS news_items (
|
||||
id TEXT PRIMARY KEY,
|
||||
title TEXT NOT NULL,
|
||||
banner_image_url TEXT NOT NULL,
|
||||
body TEXT NOT NULL,
|
||||
gallery_images JSONB NOT NULL DEFAULT '[]',
|
||||
published_at DATE NOT NULL,
|
||||
published BOOLEAN DEFAULT true,
|
||||
created_at TIMESTAMPTZ DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_news_items_published_at
|
||||
ON news_items (published, published_at DESC);
|
||||
|
||||
DROP TRIGGER IF EXISTS trg_news_items_set_updated_at ON news_items;
|
||||
CREATE TRIGGER trg_news_items_set_updated_at
|
||||
BEFORE UPDATE ON news_items
|
||||
FOR EACH ROW EXECUTE FUNCTION set_updated_at();
|
||||
@@ -0,0 +1,6 @@
|
||||
-- One date per course: when it starts being held.
|
||||
UPDATE courses
|
||||
SET start_date = held_date
|
||||
WHERE start_date IS NULL AND held_date IS NOT NULL;
|
||||
|
||||
ALTER TABLE courses DROP COLUMN IF EXISTS held_date;
|
||||
+13
-34
@@ -8,17 +8,11 @@ import { fileURLToPath } from "node:url";
|
||||
import pg from "pg";
|
||||
|
||||
import { courses } from "../src/lib/mock/courses.ts";
|
||||
import { programs } from "../src/lib/mock/programs.ts";
|
||||
import { events } from "../src/lib/mock/events.ts";
|
||||
import { articles } from "../src/lib/mock/articles.ts";
|
||||
import {
|
||||
alumniStories,
|
||||
campaignBanners,
|
||||
faculty,
|
||||
intersections,
|
||||
legalPages,
|
||||
stats,
|
||||
testimonials,
|
||||
} from "../src/lib/mock/site.ts";
|
||||
import {
|
||||
SEED_COURSE_CATEGORIES,
|
||||
@@ -26,17 +20,11 @@ import {
|
||||
} from "../src/lib/taxonomy.ts";
|
||||
|
||||
import {
|
||||
alumniStoryToRow,
|
||||
articleToRow,
|
||||
campaignBannerToRow,
|
||||
courseToRow,
|
||||
eventToRow,
|
||||
facultyMemberToRow,
|
||||
intersectionTopicToRow,
|
||||
legalPageToRow,
|
||||
programToRow,
|
||||
siteStatToRow,
|
||||
testimonialToRow,
|
||||
} from "../src/lib/db/mappers.ts";
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
@@ -122,7 +110,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(
|
||||
@@ -155,29 +144,22 @@ async function main() {
|
||||
}
|
||||
results.push(["course_category_links", catLinks]);
|
||||
results.push(["course_tag_links", tagLinks]);
|
||||
await upsert("programs", programs.map(programToRow), [
|
||||
"id", "slug", "title", "blurb", "group_key", "href", "tagline", "audience",
|
||||
"duration_label", "format_label", "highlights", "body", "published",
|
||||
]);
|
||||
await upsert("events", events.map(eventToRow), [
|
||||
"id", "title", "start_date", "end_date", "location", "href", "summary", "published",
|
||||
]);
|
||||
await upsert("articles", articles.map(articleToRow), [
|
||||
"id", "title", "category", "excerpt", "image_url", "href", "featured",
|
||||
"body", "published_at", "author", "published",
|
||||
]);
|
||||
await client.query(`DELETE FROM intersection_topics`);
|
||||
await upsert("intersection_topics", intersections.map(intersectionTopicToRow), [
|
||||
"id", "slug", "title", "description", "href", "image_url", "body", "highlights", "published",
|
||||
]);
|
||||
for (const table of [
|
||||
"programs",
|
||||
"events",
|
||||
"articles",
|
||||
"intersection_topics",
|
||||
"alumni_stories",
|
||||
"testimonials",
|
||||
]) {
|
||||
const deleted = await client.query(`DELETE FROM ${table}`);
|
||||
results.push([`${table}_cleared`, deleted.rowCount]);
|
||||
}
|
||||
await upsert("faculty_members", faculty.map(facultyMemberToRow), [
|
||||
"id", "name", "title", "focus", "bio", "image_url",
|
||||
"email", "office", "phone", "department", "linkedin_url", "scholar_url",
|
||||
"published",
|
||||
]);
|
||||
await upsert("alumni_stories", alumniStories.map(alumniStoryToRow), [
|
||||
"id", "title", "excerpt", "name", "program", "image_url", "href", "published",
|
||||
]);
|
||||
await upsert("campaign_banners", campaignBanners.map(campaignBannerToRow), [
|
||||
"id", "version", "text", "href", "cta", "published",
|
||||
]);
|
||||
@@ -187,9 +169,6 @@ async function main() {
|
||||
await upsert("site_stats", stats.map(siteStatToRow), [
|
||||
"id", "value", "label", "published",
|
||||
]);
|
||||
await upsert("testimonials", testimonials.map(testimonialToRow), [
|
||||
"id", "quote", "name", "role", "course_title", "published",
|
||||
]);
|
||||
|
||||
const counts = await client.query(`
|
||||
SELECT (SELECT count(*) FROM courses) AS courses,
|
||||
|
||||
+4
-2
@@ -13,11 +13,11 @@ services:
|
||||
- HOSTNAME=0.0.0.0
|
||||
- NEXT_PUBLIC_SITE_URL=${NEXT_PUBLIC_SITE_URL:-https://edu.mstaut.ir}
|
||||
- DATABASE_URL=${DATABASE_URL:?Set DATABASE_URL in a protected environment file}
|
||||
- UPLOAD_DIR=/app/public/uploads
|
||||
- UPLOAD_DIR=/app/uploads
|
||||
# Nginx Proxy Manager: edu.mstaut.ir → http://aut-management-faculty:3000
|
||||
# DB: same Docker network as container `insaight-postgres` (not the public IP).
|
||||
volumes:
|
||||
- uploads_data:/app/public/uploads
|
||||
- uploads_data:/app/uploads
|
||||
expose:
|
||||
- "3000"
|
||||
networks:
|
||||
@@ -32,3 +32,5 @@ networks:
|
||||
shared_web_network:
|
||||
external: true
|
||||
name: shared_web_network
|
||||
|
||||
# TEST
|
||||
@@ -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.
|
||||
|
||||
+7
-1
@@ -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).
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
| فیلتر با تگ | `/professional?tag=<slug>` |
|
||||
| فیلتر با دسته | `/professional?category=<slug>` |
|
||||
| هر دو فیلتر | `/professional?tag=<slug>&category=<slug>` |
|
||||
| گزیدهٔ برگزارشده | `/professional?tag=archive` (در لیست کامل، بلوک جدا زیر دورههای جاری) |
|
||||
|
||||
### تگ پدر (لیبل منو)
|
||||
|
||||
|
||||
@@ -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` در کتالوگ بلوک جدا با کارت ملایمتر است و از هوم حذف میماند | چند دورهٔ جاری باید جلو بیایند و گزیدهٔ برگزارشده از لیست جاری جدا دیده شود |
|
||||
@@ -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`
|
||||
@@ -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 اساتید از شبکه دانشکده
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
"insightsIntro": "نکات کاربردی مدیریت و فناوری برای کار و سازمان.",
|
||||
"eventsTitle": "رویداد ها",
|
||||
"eventsIntro": "وبینار ها، بازدیدها و نشست های معرفی برنامه.",
|
||||
"newsTitle": "اخبار",
|
||||
"newsIntro": "اطلاعیه ها و خبرهای مرکز آموزش های آزاد.",
|
||||
"newsEmpty": "هنوز خبری منتشر نشده است.",
|
||||
"aboutTitle": "درباره مرکز آموزش های آزاد",
|
||||
"valuesTitle": "ارزش های ما",
|
||||
"alumniTitle": "دانش آموختگان",
|
||||
@@ -60,6 +63,7 @@
|
||||
"courseAboutTitle": "درباره این دوره",
|
||||
"courseDetailsTitle": "جزئیات برگزاری",
|
||||
"courseDuration": "مدت",
|
||||
"courseDate": "تاریخ برگزاری",
|
||||
"courseFormat": "قالب",
|
||||
"courseCategory": "دسته بندی",
|
||||
"coursePrice": "شهریه",
|
||||
|
||||
+4
-5
@@ -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"],
|
||||
},
|
||||
@@ -20,11 +24,6 @@ const nextConfig: NextConfig = {
|
||||
},
|
||||
async redirects() {
|
||||
return [
|
||||
{
|
||||
source: "/faculty",
|
||||
destination: "https://mst.aut.ac.ir/content/31094/شبکه-اساتید",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/images/faculty/placeholder.png",
|
||||
destination: "/images/faculty/placeholder.webp",
|
||||
|
||||
Generated
+651
-3
@@ -9,10 +9,18 @@
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@base-ui/react": "^1.8.0",
|
||||
"@tiptap/extension-link": "^3.32.0",
|
||||
"@tiptap/extension-placeholder": "^3.32.0",
|
||||
"@tiptap/extension-text-align": "^3.32.0",
|
||||
"@tiptap/extension-underline": "^3.32.0",
|
||||
"@tiptap/pm": "^3.32.0",
|
||||
"@tiptap/react": "^3.32.0",
|
||||
"@tiptap/starter-kit": "^3.32.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"cn": "^0.3.2",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
"isomorphic-dompurify": "^4.6.0",
|
||||
"jalaali-js": "^2.0.1",
|
||||
"lucide-react": "^1.47.0",
|
||||
"next": "16.3.5",
|
||||
"next-intl": "^4.14.6",
|
||||
@@ -3123,6 +3131,462 @@
|
||||
"tailwindcss": "4.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/core": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.32.0.tgz",
|
||||
"integrity": "sha512-Ghh2h02GKSqzytQGcLV4espYOG4EHxjj0MsrUB2Vnr47xmlZYRf6r7k2J09H+JpBdaGrWwrTkyBEi5i3c3yy2Q==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-blockquote": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-blockquote/-/extension-blockquote-3.32.0.tgz",
|
||||
"integrity": "sha512-wmuthEdlYVArNoUbqFPH35giutBABFu7fqEB0lTD1k0UXJUs4dFvcbRyGWWgnHFZgP3TT4u8e+xiayYw0eQ0NQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bold": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bold/-/extension-bold-3.32.0.tgz",
|
||||
"integrity": "sha512-SQYewnYDoIBN+8oH53IDcD8p+Pz+Jnyq3hrxjy/FAo5ctc+96d3ZLdqc9gzLVSqFFo/SUINv2FVGoq9PvU7yqw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bubble-menu": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bubble-menu/-/extension-bubble-menu-3.32.0.tgz",
|
||||
"integrity": "sha512-X3ll8i9Z8QNvt7+tcqlwopJG+68ugO13Av0Ox4Ico+jXcTnFdDuKQJBSI9sLuMR5vTQOeTHhKYXhjF88aahMSA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@floating-ui/dom": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bullet-list": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bullet-list/-/extension-bullet-list-3.32.0.tgz",
|
||||
"integrity": "sha512-Y5P/l06pVCUG46vXpBl3z0fW2b6JpSMX4Cvr+5sfQh8zB3TxwSiLQaaPwI3R5MFD1KfRk3AjiPRieEyXdWcNHw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-code/-/extension-code-3.32.0.tgz",
|
||||
"integrity": "sha512-I+aEVl0dTmkfnU6HzBGEefb9U7ja2MkucwBBwrmoMwU+uIKpC4xw8NcHC9X6sjAcom3Pxs2HX+8WEo4Vp13R/Q==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code-block": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-code-block/-/extension-code-block-3.32.0.tgz",
|
||||
"integrity": "sha512-9NZW/yXP9j9XKr+hRS5m58xiyZI+tQo1PJ7eLHXjGNFWaF601NG/h6741mbKh5uCY51XsbyqG+7que+RavngPA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-document": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-document/-/extension-document-3.32.0.tgz",
|
||||
"integrity": "sha512-GugeKE6AnZDluRXJUNBuX43TPcaJxy5wck6vT2J4a0/EnKStJ43suSZZf1IPfb1ij9EL9bYvAwg9DOcrvdEzTQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-dropcursor": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-dropcursor/-/extension-dropcursor-3.32.0.tgz",
|
||||
"integrity": "sha512-t4Ug8hFLt30dwwYvrh63BVUt6N1Yg5PVI3tMllhCmN3Q68oD47v4MB/i5nGfzIsQqMyXUOetwHJWcZ4MoLTx4Q==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extensions": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-floating-menu": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-floating-menu/-/extension-floating-menu-3.32.0.tgz",
|
||||
"integrity": "sha512-AzKCWceL+4Q1pTc8Whw1kPqN/aYGPQ70/jXPsblWl501t/pXi6Kz0Pi/NggKkuu73VGjykh68YYf/dcOJ/mPZQ==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@floating-ui/dom": "^1.0.0",
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-gapcursor": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-gapcursor/-/extension-gapcursor-3.32.0.tgz",
|
||||
"integrity": "sha512-HUpKKWJLtthnpQY5LIjHlJJOmh562RusmOMIe/4iP/H7y+WUR9ZFiZjEs1NBkRjig9fwj8F3BfsrVPYBnM4nLA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extensions": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-hard-break": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-hard-break/-/extension-hard-break-3.32.0.tgz",
|
||||
"integrity": "sha512-IKUYvK+bO2hGrDWhhTVg0CSh9C2belWg9GyLzvpyd3SZyQ9EgdccLfoytNjOBKbAE/TQ4Oo3kSP+XF6RsUIKPA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-heading": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-heading/-/extension-heading-3.32.0.tgz",
|
||||
"integrity": "sha512-XRiZxZuhfjvbgwCvoBHj04gOsPANEXxxRwrFCQVuFi5yeTHYIzMEioc81j6iAH9pV7aQeJCwLxuh6VHNz3dXEQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-horizontal-rule": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-3.32.0.tgz",
|
||||
"integrity": "sha512-Iry7ynsG4xgcxnH1cm+uXJnEtUzoop4sGA10NUN9I+08TOjhj/GrDiRKMQHKAiVI/R7t2MVav1MJlxFf2FdzGw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-italic": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-italic/-/extension-italic-3.32.0.tgz",
|
||||
"integrity": "sha512-KB/i1xoHilbBGcQ+UotDWhi60KpdCde3RzRIpl2na0Yol4z4Fe2IRWg8ljIrlsssDRwel/fsHJbG7a13EP8oKA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-link": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-3.32.0.tgz",
|
||||
"integrity": "sha512-DRdQSgWPSEjrDg5EDBB5yxRygHtUVLhceVGzAsTz8RziiFyvcwAvzBHCO9hd9jutjCXQ2DLIuZB8P+aHhFWnpg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"linkifyjs": "^4.3.3"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list/-/extension-list-3.32.0.tgz",
|
||||
"integrity": "sha512-QdzS5nFz9agAQhBgIuQluobWib39W2cMKx1XB6tYSue7bHMJdgPFP0EnGfFajaeVX42CG6RXtQWrNfyQGKhBvg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list-item": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list-item/-/extension-list-item-3.32.0.tgz",
|
||||
"integrity": "sha512-FdJTCAeALixzyyGSSEmroXmkIEclbo/4t2Pl03aRERqpPOSPJcC3evDtIhLazTuP6v+FjCmJ+pXNql6ov7qitA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list-keymap": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list-keymap/-/extension-list-keymap-3.32.0.tgz",
|
||||
"integrity": "sha512-vXFre18Dk2m5N/gjo408C02GSrolZ8ZIf0wz6/U8lNC4FcYOISgZFj3BND6uabVntGh2GCSPrVFuNpVPhFnn/A==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-ordered-list": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-3.32.0.tgz",
|
||||
"integrity": "sha512-htZ5hoMLBkGiDP6M5mGemjOoaBmkrj911wiGoTmMMKzO7qJq9QxUBkLY7ILPaKlUWL8U3ccLdDV2TB/nysp4Jg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-paragraph": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-paragraph/-/extension-paragraph-3.32.0.tgz",
|
||||
"integrity": "sha512-afKLMc7fWMkkar9H5FilizStSbhFzUoCzdwwdZf6DDsn3LUt8tJlFHACK78cAyx/TzMJBo0N8/8T1u9bL+N67Q==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-placeholder": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-placeholder/-/extension-placeholder-3.32.0.tgz",
|
||||
"integrity": "sha512-TSjyQmVFq56gfURPotxbMsXU3seNTy9VzMACdb6b0bQ66yGWBcjBfWmhpiSRVLdBjQrRvl1+jQbWx0YPSCSpsw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extensions": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-strike": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-3.32.0.tgz",
|
||||
"integrity": "sha512-J9Vw6wmh/wV6SxSsN9RhurvAGcXSY5J3p4EQrROD5PARBl0VOnDFi7/UVoz1RkSdqOKPgAiqDZpaLRgtdBO9Rg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-text": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-3.32.0.tgz",
|
||||
"integrity": "sha512-sF0jIK67IHdZMnzv2mz5vPTyK7R0ui6/YZgFg+/bLnFCNmweVAoYcHZLlC7ISRnwu0mqJr+epNtzJepY1ZDCjg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-text-align": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-text-align/-/extension-text-align-3.32.0.tgz",
|
||||
"integrity": "sha512-DdV/V86ds9VtQ1MkbovgI28xwSvOW03I8SexsaKljGqSN/HovBXEjlefSnbK4tlWmQLJPH9eNsxRcpHJMftYCA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-underline": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-3.32.0.tgz",
|
||||
"integrity": "sha512-rMLdd4vg6sed/JnaXnaupLbCtYiWikTnQ8qir9ItKOXwf1Ui9P1Y4G0bYU4+gcnMsFzaSGtrOhMqG4/c66AogQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extensions": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.32.0.tgz",
|
||||
"integrity": "sha512-qO+ndNvlOjzU2MWCtQHoRg1tIortCXLvqPjDx58F1pUYFNCOVZegXi+jqLGDODUA31er+TVz66umzRbbN1bO1Q==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/pm": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.32.0.tgz",
|
||||
"integrity": "sha512-H9eN+xHFboJybE7KPGVsu24S8aBlCIgYz38vCHRSnNv17nwmqm06owq/IQ5scza0n3Y7IfUfpgPOtm9SgeHmNQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-changeset": "^2.4.4",
|
||||
"prosemirror-commands": "^1.7.2",
|
||||
"prosemirror-dropcursor": "^1.8.4",
|
||||
"prosemirror-gapcursor": "^1.4.1",
|
||||
"prosemirror-history": "^1.5.1",
|
||||
"prosemirror-inputrules": "^1.5.1",
|
||||
"prosemirror-keymap": "^1.2.3",
|
||||
"prosemirror-model": "^1.25.12",
|
||||
"prosemirror-schema-list": "^1.5.1",
|
||||
"prosemirror-state": "^1.4.4",
|
||||
"prosemirror-tables": "^1.8.5",
|
||||
"prosemirror-transform": "^1.12.2",
|
||||
"prosemirror-view": "^1.42.6"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/react": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/react/-/react-3.32.0.tgz",
|
||||
"integrity": "sha512-+iS9RKj6Ve8SXqJ49xptDiifF7PQXmUOh4cjMu+BCXXqKphQkiUccvbWYAeOJCTceM01wWgFhrpfy8qG+CHJYw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/use-sync-external-store": "^0.0.6",
|
||||
"fast-equals": "^5.3.3",
|
||||
"use-sync-external-store": "^1.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@tiptap/extension-bubble-menu": "3.32.0",
|
||||
"@tiptap/extension-floating-menu": "3.32.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0",
|
||||
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"@types/react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/starter-kit": {
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/starter-kit/-/starter-kit-3.32.0.tgz",
|
||||
"integrity": "sha512-aPYxaevci4PgMrTLsg+baiqI7M1ICd4V9H+zTTdrqs8OUZIbAvj/pNDuHU8uWZyKMu3Dh72t2D6ZdqRu/6aSWw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tiptap/core": "3.32.0",
|
||||
"@tiptap/extension-blockquote": "3.32.0",
|
||||
"@tiptap/extension-bold": "3.32.0",
|
||||
"@tiptap/extension-bullet-list": "3.32.0",
|
||||
"@tiptap/extension-code": "3.32.0",
|
||||
"@tiptap/extension-code-block": "3.32.0",
|
||||
"@tiptap/extension-document": "3.32.0",
|
||||
"@tiptap/extension-dropcursor": "3.32.0",
|
||||
"@tiptap/extension-gapcursor": "3.32.0",
|
||||
"@tiptap/extension-hard-break": "3.32.0",
|
||||
"@tiptap/extension-heading": "3.32.0",
|
||||
"@tiptap/extension-horizontal-rule": "3.32.0",
|
||||
"@tiptap/extension-italic": "3.32.0",
|
||||
"@tiptap/extension-link": "3.32.0",
|
||||
"@tiptap/extension-list": "3.32.0",
|
||||
"@tiptap/extension-list-item": "3.32.0",
|
||||
"@tiptap/extension-list-keymap": "3.32.0",
|
||||
"@tiptap/extension-ordered-list": "3.32.0",
|
||||
"@tiptap/extension-paragraph": "3.32.0",
|
||||
"@tiptap/extension-strike": "3.32.0",
|
||||
"@tiptap/extension-text": "3.32.0",
|
||||
"@tiptap/extension-underline": "3.32.0",
|
||||
"@tiptap/extensions": "3.32.0",
|
||||
"@tiptap/pm": "3.32.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
}
|
||||
},
|
||||
"node_modules/@ts-morph/common": {
|
||||
"version": "0.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.27.0.tgz",
|
||||
@@ -3266,7 +3730,6 @@
|
||||
"version": "19.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz",
|
||||
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"csstype": "^3.2.2"
|
||||
@@ -3276,7 +3739,6 @@
|
||||
"version": "19.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz",
|
||||
"integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@types/react": "^19.3.0"
|
||||
@@ -3289,6 +3751,12 @@
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/use-sync-external-store": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
|
||||
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/validate-npm-package-name": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/validate-npm-package-name/-/validate-npm-package-name-4.0.2.tgz",
|
||||
@@ -4890,7 +5358,6 @@
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/damerau-levenshtein": {
|
||||
@@ -6082,6 +6549,15 @@
|
||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-equals": {
|
||||
"version": "5.4.5",
|
||||
"resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.4.5.tgz",
|
||||
"integrity": "sha512-yKEpcFuRPu/pTQL2VB8YKE2yFldrLlIsoWtJeBnAdqEhvu21OgkFT0C8njf/xYc2LSZGEr3K9JGjthHJxnVLvQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz",
|
||||
@@ -7443,6 +7919,15 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/jalaali-js": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/jalaali-js/-/jalaali-js-2.0.1.tgz",
|
||||
"integrity": "sha512-qzTmjw6lZ3V4znyNA8ceYoGgFR+CcF+xEfIYZNcK2ZR0mzdMpMZ6iAcdRPvMgxUVdPMh6QLWCANpTcCJow2U+Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/jiti": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",
|
||||
@@ -7964,6 +8449,12 @@
|
||||
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/linkifyjs": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.4.0.tgz",
|
||||
"integrity": "sha512-InTexvtbai+2c+dEVGcc6O6P2DMVIiwD9a/i4zFroazOIYLOS6FSVmAJ7kFeumnCMx6/gQqNAkbUvgMubV4+MA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/locate-path": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
||||
@@ -8732,6 +9223,12 @@
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/orderedmap": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz",
|
||||
"integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/own-keys": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.2.tgz",
|
||||
@@ -9253,6 +9750,145 @@
|
||||
"react-is": "^16.13.1"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-changeset": {
|
||||
"version": "2.4.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.4.tgz",
|
||||
"integrity": "sha512-Gyuz9jYdrAeA9I7AholyOes9KUmv/lEwsC5O9s5xF5VB3EgTPsXMGUxz4+H1B+wKVPdZbvRcg1Cp3x8qX+8ofA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-transform": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-commands": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.7.2.tgz",
|
||||
"integrity": "sha512-q6Q6szxqdu9Xd6EcdKsqXghu5nQdZTpB4Q9yd04WRc7/jt763e/rT60Owh0L1GYY+T46o5rD+9lEN36dZS43tw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.10.2"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-dropcursor": {
|
||||
"version": "1.8.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-dropcursor/-/prosemirror-dropcursor-1.8.4.tgz",
|
||||
"integrity": "sha512-VmKxhcA6a+h5oPSYmfF1ZNeQqPbyYaIxqZsKqeYCyTlPtrjUgNaHL3P8vVaO19oqAV0zuaM/axkowZHrB1P3Tg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.1.0",
|
||||
"prosemirror-view": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-gapcursor": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-gapcursor/-/prosemirror-gapcursor-1.4.1.tgz",
|
||||
"integrity": "sha512-pMdYaEnjNMSwl11yjEGtgTmLkR08m/Vl+Jj443167p9eB3HVQKhYCc4gmHVDsLPODfZfjr/MmirsdyZziXbQKw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-keymap": "^1.0.0",
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-view": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-history": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.5.1.tgz",
|
||||
"integrity": "sha512-onlwnqKvgtFg6srZOmDOAhlAy1FIHQpOExORybX0S+DvJepE5tPALrB9iGet/2sqqqrelSnB10OoiOJqAvu2DA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.2.2",
|
||||
"prosemirror-transform": "^1.0.0",
|
||||
"prosemirror-view": "^1.31.0",
|
||||
"rope-sequence": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-inputrules": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-inputrules/-/prosemirror-inputrules-1.5.1.tgz",
|
||||
"integrity": "sha512-7wj4uMjKaXWAQ1CDgxNzNtR9AlsuwzHfdFH1ygEHA2KHF2DOEaXl1CJfNPAKCg9qNEh4rum975QLaCiQPyY6Fw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-keymap": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.3.tgz",
|
||||
"integrity": "sha512-4HucRlpiLd1IPQQXNqeo81BGtkY8Ai5smHhKW9jjPKRc2wQIxksg7Hl1tTI2IfT2B/LgX6bfYvXxEpJl7aKYKw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"w3c-keyname": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-model": {
|
||||
"version": "1.25.12",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.12.tgz",
|
||||
"integrity": "sha512-Ue2gTmXMa7EhpLNhC7J+h4+ykD8ha12K6rrZFFKKJHBForfIStw5gJ6Zrf1mqqAa9NmpmEB4wp9bKmA4eUVjWg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"orderedmap": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-schema-list": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.5.1.tgz",
|
||||
"integrity": "sha512-927lFx/uwyQaGwJxLWCZRkjXG0p48KpMj6ueoYiu4JX05GGuGcgzAy62dfiV8eFZftgyBUvLx76RsMe20fJl+Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-state": {
|
||||
"version": "1.4.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz",
|
||||
"integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-transform": "^1.0.0",
|
||||
"prosemirror-view": "^1.27.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-tables": {
|
||||
"version": "1.8.5",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.8.5.tgz",
|
||||
"integrity": "sha512-V/0cDCsHKHe/tfWkeCmthNUcEp1IVO3p6vwN8XtwE9PZQLAZJigbw3QoraAdfJPir4NKJtNvOB8oYGKRl+t0Dw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-keymap": "^1.2.3",
|
||||
"prosemirror-model": "^1.25.4",
|
||||
"prosemirror-state": "^1.4.4",
|
||||
"prosemirror-transform": "^1.10.5",
|
||||
"prosemirror-view": "^1.41.4"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-transform": {
|
||||
"version": "1.12.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.12.4.tgz",
|
||||
"integrity": "sha512-2/WuPum3pn+O/Vi2vzpi8210ICUe2kIPXdLYjQ09Pv5DtT5bcKWMJhAKPBwvpPjpp5iOYUVwVEr0gOM1BY1Mgw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-view": {
|
||||
"version": "1.42.8",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.42.8.tgz",
|
||||
"integrity": "sha512-ftDZjCs9AjAekXmCfJRn2U3IdlRCl0Yc4tZT1/jJWCsz4DiSifEBXtWmpJpw/4f1Rg328uAUQ+u2lCJ0+AVZkw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.25.12",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
|
||||
@@ -9530,6 +10166,12 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rope-sequence": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz",
|
||||
"integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/router": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
||||
@@ -11024,6 +11666,12 @@
|
||||
"integrity": "sha512-fbjNc0CMjazZpIegWzz9OHGzI1APFboT+x7ZecXlUCtDe/nkyx7gtCTZnWS/+eeXG7fbfXymCPKJI8EsnM3iqw==",
|
||||
"license": "OFL"
|
||||
},
|
||||
"node_modules/w3c-keyname": {
|
||||
"version": "2.2.8",
|
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/w3c-xmlserializer": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz",
|
||||
|
||||
@@ -14,10 +14,18 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@base-ui/react": "^1.8.0",
|
||||
"@tiptap/extension-link": "^3.32.0",
|
||||
"@tiptap/extension-placeholder": "^3.32.0",
|
||||
"@tiptap/extension-text-align": "^3.32.0",
|
||||
"@tiptap/extension-underline": "^3.32.0",
|
||||
"@tiptap/pm": "^3.32.0",
|
||||
"@tiptap/react": "^3.32.0",
|
||||
"@tiptap/starter-kit": "^3.32.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"cn": "^0.3.2",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
"isomorphic-dompurify": "^4.6.0",
|
||||
"jalaali-js": "^2.0.1",
|
||||
"lucide-react": "^1.47.0",
|
||||
"next": "16.3.5",
|
||||
"next-intl": "^4.14.6",
|
||||
|
||||
Whitespace-only changes.
@@ -44,8 +44,8 @@ docker run --rm --network "$NETWORK" --env-file "$ENV_FILE" \
|
||||
# Check the database and a minimal page set before switching the public upstream.
|
||||
CANDIDATE="edu-candidate-${REVISION:0:12}"
|
||||
docker run -d --name "$CANDIDATE" --network "$NETWORK" --env-file "$ENV_FILE" \
|
||||
-e UPLOAD_DIR=/app/public/uploads \
|
||||
-v "$UPLOAD_VOLUME:/app/public/uploads" \
|
||||
-e UPLOAD_DIR=/app/uploads \
|
||||
-v "$UPLOAD_VOLUME:/app/uploads" \
|
||||
"$IMAGE"
|
||||
cleanup_candidate() { docker rm -f "$CANDIDATE" >/dev/null 2>&1 || true; }
|
||||
trap cleanup_candidate EXIT
|
||||
@@ -101,8 +101,8 @@ rollback() {
|
||||
trap rollback ERR
|
||||
docker run -d --name "$CONTAINER" --restart unless-stopped \
|
||||
--network "$NETWORK" --env-file "$ENV_FILE" \
|
||||
-e UPLOAD_DIR=/app/public/uploads \
|
||||
-v "$UPLOAD_VOLUME:/app/public/uploads" \
|
||||
-e UPLOAD_DIR=/app/uploads \
|
||||
-v "$UPLOAD_VOLUME:/app/uploads" \
|
||||
-p 127.0.0.1:3000:3000 "$IMAGE"
|
||||
READY=false
|
||||
for attempt in $(seq 1 20); do
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
// Usage: node scripts/dump-database.mjs
|
||||
// Reads DATABASE_URL from the environment or .env.local.
|
||||
// Writes a restorable SQL snapshot under backups/ (gitignored).
|
||||
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import pg from "pg";
|
||||
|
||||
const { Client } = pg;
|
||||
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
const envPath = path.join(rootDir, ".env.local");
|
||||
if (existsSync(envPath)) {
|
||||
for (const line of readFileSync(envPath, "utf8").split(/\r?\n/)) {
|
||||
const match = line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*)\s*$/);
|
||||
if (match && !(match[1] in process.env)) {
|
||||
process.env[match[1]] = match[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
console.error("DATABASE_URL is not set. Copy .env.example → .env.local and fill it in.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function quoteIdent(name) {
|
||||
return `"${String(name).replaceAll('"', '""')}"`;
|
||||
}
|
||||
|
||||
function topologicalTables(tables, edges) {
|
||||
const remaining = new Set(tables);
|
||||
const parentsByChild = new Map(tables.map((table) => [table, new Set()]));
|
||||
for (const { child, parent } of edges) {
|
||||
if (remaining.has(child) && remaining.has(parent) && child !== parent) {
|
||||
parentsByChild.get(child).add(parent);
|
||||
}
|
||||
}
|
||||
const ordered = [];
|
||||
while (remaining.size > 0) {
|
||||
const ready = [...remaining].filter((table) => {
|
||||
const parents = parentsByChild.get(table);
|
||||
return [...parents].every((parent) => !remaining.has(parent));
|
||||
});
|
||||
const batch = ready.length > 0 ? ready.toSorted() : [[...remaining].toSorted()[0]];
|
||||
for (const table of batch) {
|
||||
remaining.delete(table);
|
||||
ordered.push(table);
|
||||
}
|
||||
}
|
||||
return ordered;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const client = new Client({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
connectionTimeoutMillis: Number(process.env.DATABASE_CONNECTION_TIMEOUT_MS ?? 20_000),
|
||||
});
|
||||
await client.connect();
|
||||
|
||||
try {
|
||||
const info = await client.query(`
|
||||
SELECT current_database() AS database, current_user AS username, now() AS dumped_at
|
||||
`);
|
||||
const { database, username, dumped_at } = info.rows[0];
|
||||
|
||||
const tableRows = await client.query(`
|
||||
SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public' AND table_type = 'BASE TABLE'
|
||||
ORDER BY table_name
|
||||
`);
|
||||
const tables = tableRows.rows.map((row) => row.table_name);
|
||||
|
||||
const fkRows = await client.query(`
|
||||
SELECT
|
||||
tc.table_name AS child,
|
||||
ccu.table_name AS parent
|
||||
FROM information_schema.table_constraints AS tc
|
||||
JOIN information_schema.constraint_column_usage AS ccu
|
||||
ON tc.constraint_name = ccu.constraint_name
|
||||
AND tc.table_schema = ccu.table_schema
|
||||
WHERE tc.constraint_type = 'FOREIGN KEY'
|
||||
AND tc.table_schema = 'public'
|
||||
`);
|
||||
const ordered = topologicalTables(tables, fkRows.rows);
|
||||
|
||||
const stamp = new Date(dumped_at).toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
|
||||
const outDir = path.join(rootDir, "backups");
|
||||
mkdirSync(outDir, { recursive: true });
|
||||
const outFile = path.join(outDir, `${database}-${stamp}.sql`);
|
||||
|
||||
const lines = [
|
||||
`-- Snapshot of ${database} (user ${username})`,
|
||||
`-- Generated at ${new Date(dumped_at).toISOString()}`,
|
||||
`-- Restore into an empty DB after migrations, or into a matching schema:`,
|
||||
`-- psql -v ON_ERROR_STOP=1 -d TARGET_DB -f ${path.basename(outFile)}`,
|
||||
"BEGIN;",
|
||||
"SET client_encoding = 'UTF8';",
|
||||
"SET statement_timeout = 0;",
|
||||
"SET lock_timeout = 0;",
|
||||
"",
|
||||
];
|
||||
|
||||
if (ordered.length > 0) {
|
||||
lines.push(
|
||||
`TRUNCATE ${ordered.map(quoteIdent).join(", ")} RESTART IDENTITY CASCADE;`,
|
||||
"",
|
||||
);
|
||||
}
|
||||
|
||||
const counts = [];
|
||||
for (const table of ordered) {
|
||||
const columns = await client.query(
|
||||
`
|
||||
SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = $1
|
||||
ORDER BY ordinal_position
|
||||
`,
|
||||
[table],
|
||||
);
|
||||
const colNames = columns.rows.map((row) => row.column_name);
|
||||
if (colNames.length === 0) continue;
|
||||
|
||||
const colIdents = colNames.map(quoteIdent).join(", ");
|
||||
const tupleSql = colNames
|
||||
.map((name) => `quote_nullable(${quoteIdent(name)}::text)`)
|
||||
.join(" || ',' || ");
|
||||
const data = await client.query(
|
||||
`SELECT ${tupleSql} AS tuple FROM ${quoteIdent(table)}`,
|
||||
);
|
||||
|
||||
counts.push({ table, rows: data.rows.length });
|
||||
lines.push(`-- ${table}: ${data.rows.length} row(s)`);
|
||||
if (data.rows.length === 0) {
|
||||
lines.push("");
|
||||
continue;
|
||||
}
|
||||
const values = data.rows.map((row) => `(${row.tuple})`).join(",\n");
|
||||
lines.push(
|
||||
`INSERT INTO ${quoteIdent(table)} (${colIdents}) VALUES`,
|
||||
`${values};`,
|
||||
"",
|
||||
);
|
||||
}
|
||||
|
||||
const sequences = await client.query(`
|
||||
SELECT sequencename, last_value
|
||||
FROM pg_sequences
|
||||
WHERE schemaname = 'public'
|
||||
ORDER BY sequencename
|
||||
`);
|
||||
for (const seq of sequences.rows) {
|
||||
if (seq.last_value == null) continue;
|
||||
const seqName = String(seq.sequencename).replaceAll("'", "''");
|
||||
lines.push(`SELECT setval('${seqName}', ${Number(seq.last_value)}, true);`);
|
||||
}
|
||||
|
||||
lines.push("", "COMMIT;", "");
|
||||
writeFileSync(outFile, lines.join("\n"), "utf8");
|
||||
|
||||
const statsFile = outFile.replace(/\.sql$/, ".tables.json");
|
||||
writeFileSync(
|
||||
statsFile,
|
||||
JSON.stringify(
|
||||
{
|
||||
database,
|
||||
dumpedAt: new Date(dumped_at).toISOString(),
|
||||
tables: counts,
|
||||
file: path.basename(outFile),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const bytes = Buffer.byteLength(lines.join("\n"), "utf8");
|
||||
console.log("DUMP_OK");
|
||||
console.log(outFile);
|
||||
console.log(`bytes=${bytes} tables=${counts.length} rows=${counts.reduce((sum, item) => sum + item.rows, 0)}`);
|
||||
for (const item of counts) {
|
||||
console.log(`${item.table}\t${item.rows}`);
|
||||
}
|
||||
} finally {
|
||||
await client.end().catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("DUMP_FAIL");
|
||||
console.error(error instanceof Error ? error.message : error);
|
||||
process.exit(1);
|
||||
});
|
||||
+8
-3
@@ -28,10 +28,15 @@ async function readJson(res) {
|
||||
async function main() {
|
||||
console.log(`Smoke: ${BASE}`);
|
||||
|
||||
for (const path of ["courses", "programs", "events", "articles"]) {
|
||||
const res = await fetch(`${BASE}/api/${path}`);
|
||||
{
|
||||
const res = await fetch(`${BASE}/api/courses`);
|
||||
const { status, json } = await readJson(res);
|
||||
check(`GET /api/${path}`, status === 200 && Array.isArray(json.data), `status=${status}`);
|
||||
check("GET /api/courses", status === 200 && Array.isArray(json.data), `status=${status}`);
|
||||
}
|
||||
|
||||
for (const path of ["programs", "events", "articles"]) {
|
||||
const res = await fetch(`${BASE}/api/${path}`);
|
||||
check(`GET /api/${path} disabled`, res.status === 404, `status=${res.status}`);
|
||||
}
|
||||
|
||||
if (!ADMIN_EMAIL || !ADMIN_PASSWORD) {
|
||||
|
||||
@@ -12,15 +12,24 @@ export NEXT_PUBLIC_SITE_URL="${NEXT_PUBLIC_SITE_URL:-https://edu.mstaut.ir}"
|
||||
export NODE_OPTIONS="${NODE_OPTIONS:---max-old-space-size=3072}"
|
||||
|
||||
echo "Building Next.js at $ROOT (Node 22 container)…"
|
||||
DOCKER_BUILDKIT=1 docker run --rm \
|
||||
# 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 \
|
||||
--mount type=cache,target=/root/.npm \
|
||||
-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"
|
||||
|
||||
@@ -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
|
||||
@@ -43,7 +43,7 @@ export default async function LegalSlugPage({ params }: Props) {
|
||||
<Container className="grid gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.2fr)] lg:items-start">
|
||||
<div className="min-w-0 space-y-5">
|
||||
{page.body.map((paragraph) => (
|
||||
<p key={paragraph} className="text-base leading-8 text-foreground/90">
|
||||
<p key={paragraph} className="text-justify text-base leading-8 text-foreground/90">
|
||||
{paragraph}
|
||||
</p>
|
||||
))}
|
||||
|
||||
@@ -1,69 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import Image from "next/image";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Heading } from "@/components/atoms/Heading";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { BadgeLabel } from "@/components/atoms/BadgeLabel";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
||||
import { getAlumniStories } from "@/lib/data/site";
|
||||
import { pageMetadata } from "@/lib/seo/metadata";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("pages");
|
||||
return pageMetadata({
|
||||
title: t("alumniTitle"),
|
||||
description: t("alumniIntro"),
|
||||
path: "/alumni",
|
||||
});
|
||||
}
|
||||
|
||||
export default async function AlumniPage() {
|
||||
const t = await getTranslations("pages");
|
||||
const stories = await getAlumniStories();
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<PageHero
|
||||
title={t("alumniTitle")}
|
||||
intro={t("alumniIntro")}
|
||||
imageUrl="/brand/graduation-cap-neural.webp"
|
||||
/>
|
||||
<Section tone="subtle">
|
||||
<Container>
|
||||
<div className="grid gap-5 md:grid-cols-3">
|
||||
{stories.map((story) => (
|
||||
<SurfaceCard
|
||||
key={story.id}
|
||||
id={story.id}
|
||||
padded={false}
|
||||
className="scroll-mt-24"
|
||||
>
|
||||
<div className="relative aspect-[16/10] bg-muted">
|
||||
<Image
|
||||
src={story.imageUrl}
|
||||
alt={story.name}
|
||||
fill
|
||||
className="object-cover"
|
||||
sizes="(max-width:768px) 100vw, 33vw"
|
||||
/>
|
||||
</div>
|
||||
<div className="p-6">
|
||||
<BadgeLabel>{story.program}</BadgeLabel>
|
||||
<Heading as="h2" level={4} className="mt-3">
|
||||
{story.title}
|
||||
</Heading>
|
||||
<p className="mt-2 text-sm leading-7 text-muted-foreground">
|
||||
{story.excerpt}
|
||||
</p>
|
||||
<p className="mt-4 text-sm font-semibold">{story.name}</p>
|
||||
</div>
|
||||
</SurfaceCard>
|
||||
))}
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
export default function AlumniPage() {
|
||||
notFound();
|
||||
}
|
||||
@@ -1,90 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { CalendarDays, MapPin } 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 } from "@/components/molecules/DetailList";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
||||
import { getEventById } from "@/lib/data/events";
|
||||
import { JsonLd } from "@/lib/seo/json-ld";
|
||||
import {
|
||||
absoluteUrl,
|
||||
pageMetadata,
|
||||
truncateMetaDescription,
|
||||
} from "@/lib/seo/metadata";
|
||||
|
||||
type Props = { params: Promise<{ id: string }> };
|
||||
|
||||
const dateFormat: Intl.DateTimeFormatOptions = {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
};
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { id } = await params;
|
||||
const event = await getEventById(id);
|
||||
if (!event) return { title: "رویداد یافت نشد" };
|
||||
return pageMetadata({
|
||||
title: event.title,
|
||||
description: truncateMetaDescription(event.summary),
|
||||
path: `/events/${id}`,
|
||||
});
|
||||
}
|
||||
|
||||
export default async function EventDetailPage({ params }: Props) {
|
||||
const { id } = await params;
|
||||
const event = await getEventById(id);
|
||||
if (!event) notFound();
|
||||
|
||||
const start = new Date(event.startDate).toLocaleDateString("fa-IR", dateFormat);
|
||||
const end = event.endDate
|
||||
? new Date(event.endDate).toLocaleDateString("fa-IR", dateFormat)
|
||||
: null;
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<JsonLd
|
||||
data={{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Event",
|
||||
name: event.title,
|
||||
description: event.summary,
|
||||
startDate: event.startDate,
|
||||
...(event.endDate ? { endDate: event.endDate } : {}),
|
||||
location: { "@type": "Place", name: event.location },
|
||||
url: absoluteUrl(`/events/${id}`),
|
||||
}}
|
||||
/>
|
||||
<PageHero title={event.title} intro={event.summary} />
|
||||
<Section tone="subtle">
|
||||
<Container narrow className="space-y-6">
|
||||
<SurfaceCard padded as="div">
|
||||
<DetailList
|
||||
items={[
|
||||
{
|
||||
icon: CalendarDays,
|
||||
label: "زمان",
|
||||
value: end ? `${start} تا ${end}` : start,
|
||||
},
|
||||
{ icon: MapPin, label: "مکان", value: event.location },
|
||||
]}
|
||||
/>
|
||||
</SurfaceCard>
|
||||
<section className="space-y-4">
|
||||
<Heading level={3} as="h2">
|
||||
درباره رویداد
|
||||
</Heading>
|
||||
<p className="text-base leading-8 text-foreground/90">{event.summary}</p>
|
||||
</section>
|
||||
<TextLink href="/events" className="inline-block text-sm">
|
||||
بازگشت به رویدادها
|
||||
</TextLink>
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
export default function EventDetailPage() {
|
||||
notFound();
|
||||
}
|
||||
@@ -1,37 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { EventCard } from "@/components/molecules/Cards";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { getEvents } from "@/lib/data/events";
|
||||
import { pageMetadata } from "@/lib/seo/metadata";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("pages");
|
||||
return pageMetadata({
|
||||
title: t("eventsTitle"),
|
||||
description: t("eventsIntro"),
|
||||
path: "/events",
|
||||
});
|
||||
}
|
||||
|
||||
export default async function EventsPage() {
|
||||
const t = await getTranslations("pages");
|
||||
const events = await getEvents();
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<PageHero title={t("eventsTitle")} intro={t("eventsIntro")} />
|
||||
<Section tone="subtle">
|
||||
<Container>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{events.map((event) => (
|
||||
<EventCard key={event.id} {...event} variant="list" />
|
||||
))}
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
export default function EventsPage() {
|
||||
notFound();
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
/** Faculty are not introduced on this site; send visitors home. */
|
||||
export default function FacultyPage() {
|
||||
redirect("/");
|
||||
notFound();
|
||||
}
|
||||
@@ -1,78 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import Image from "next/image";
|
||||
import { notFound } from "next/navigation";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { TextLink } from "@/components/atoms/TextLink";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { getArticleById } from "@/lib/data/articles";
|
||||
import { JsonLd } from "@/lib/seo/json-ld";
|
||||
import {
|
||||
absoluteUrl,
|
||||
pageMetadata,
|
||||
truncateMetaDescription,
|
||||
} from "@/lib/seo/metadata";
|
||||
|
||||
type Props = { params: Promise<{ id: string }> };
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { id } = await params;
|
||||
const article = await getArticleById(id);
|
||||
if (!article) return { title: "مقاله یافت نشد" };
|
||||
return pageMetadata({
|
||||
title: article.title,
|
||||
description: truncateMetaDescription(article.excerpt),
|
||||
path: `/insights/${id}`,
|
||||
image: article.imageUrl,
|
||||
});
|
||||
}
|
||||
|
||||
export default async function InsightDetailPage({ params }: Props) {
|
||||
const { id } = await params;
|
||||
const article = await getArticleById(id);
|
||||
if (!article) notFound();
|
||||
|
||||
const date = new Date(article.publishedAt).toLocaleDateString("fa-IR");
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<JsonLd
|
||||
data={{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Article",
|
||||
headline: article.title,
|
||||
description: article.excerpt,
|
||||
datePublished: article.publishedAt,
|
||||
author: { "@type": "Person", name: article.author },
|
||||
image: article.imageUrl,
|
||||
url: absoluteUrl(`/insights/${id}`),
|
||||
}}
|
||||
/>
|
||||
<PageHero
|
||||
eyebrow={article.category}
|
||||
title={article.title}
|
||||
intro={`${article.author} · ${date}`}
|
||||
/>
|
||||
<Section tone="subtle">
|
||||
<Container narrow>
|
||||
<div className="relative mb-10 aspect-[16/9] overflow-hidden rounded-2xl bg-muted ring-1 ring-foreground/10">
|
||||
<Image
|
||||
src={article.imageUrl}
|
||||
alt={article.title}
|
||||
fill
|
||||
className="object-cover"
|
||||
sizes="(max-width:768px) 100vw, 800px"
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
<p className="text-base leading-8 text-foreground/90 sm:text-lg sm:leading-9">
|
||||
{article.body}
|
||||
</p>
|
||||
<TextLink href="/insights" className="mt-10 inline-block text-sm">
|
||||
بازگشت به مقالات
|
||||
</TextLink>
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
export default function InsightArticlePage() {
|
||||
notFound();
|
||||
}
|
||||
@@ -1,49 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { ArticleCard } from "@/components/molecules/Cards";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { getArticles } from "@/lib/data/articles";
|
||||
import { pageMetadata } from "@/lib/seo/metadata";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("pages");
|
||||
return pageMetadata({
|
||||
title: t("insightsTitle"),
|
||||
description: t("insightsIntro"),
|
||||
path: "/insights",
|
||||
});
|
||||
}
|
||||
|
||||
export default async function InsightsPage() {
|
||||
const t = await getTranslations("pages");
|
||||
const articles = await getArticles();
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<PageHero
|
||||
title={t("insightsTitle")}
|
||||
intro={t("insightsIntro")}
|
||||
imageUrl="/brand/neural-open-book.webp"
|
||||
/>
|
||||
<Section tone="subtle">
|
||||
<Container>
|
||||
<div className="mx-auto max-w-5xl">
|
||||
{articles.map((article) => (
|
||||
<ArticleCard
|
||||
key={article.id}
|
||||
title={article.title}
|
||||
category={article.category}
|
||||
excerpt={article.excerpt}
|
||||
imageUrl={article.imageUrl}
|
||||
href={article.href}
|
||||
variant="list"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
export default function InsightsPage() {
|
||||
notFound();
|
||||
}
|
||||
@@ -5,9 +5,12 @@ import { SiteHeader } from "@/components/organisms/SiteHeader";
|
||||
import { buildHomeNavWithCourseTags } from "@/lib/course-nav";
|
||||
import { getCourses } from "@/lib/data/courses";
|
||||
import { listPublishedCourseTags } from "@/lib/data/taxonomy";
|
||||
import { getPrograms } from "@/lib/data/programs";
|
||||
import { getCampaignBanners } from "@/lib/data/site";
|
||||
import { facultySiteUrl, siteShortName } from "@/lib/site-config";
|
||||
import {
|
||||
facultyNetworkUrl,
|
||||
facultySiteUrl,
|
||||
siteShortName,
|
||||
} from "@/lib/site-config";
|
||||
|
||||
// Public CMS pages must read Postgres at request time — static bake at Docker
|
||||
// build often has no DATABASE_URL and ships empty lists.
|
||||
@@ -21,13 +24,11 @@ export default async function MainLayout({
|
||||
const t = await getTranslations();
|
||||
const year = new Date().getFullYear();
|
||||
let courses: Awaited<ReturnType<typeof getCourses>> = [];
|
||||
let programs: Awaited<ReturnType<typeof getPrograms>> = [];
|
||||
let banners: Awaited<ReturnType<typeof getCampaignBanners>> = [];
|
||||
let navTags: Awaited<ReturnType<typeof listPublishedCourseTags>> = [];
|
||||
try {
|
||||
[courses, programs, banners, navTags] = await Promise.all([
|
||||
[courses, banners, navTags] = await Promise.all([
|
||||
getCourses(),
|
||||
getPrograms(),
|
||||
getCampaignBanners(),
|
||||
listPublishedCourseTags({ navOnly: true }),
|
||||
]);
|
||||
@@ -47,7 +48,6 @@ export default async function MainLayout({
|
||||
brandSubtitle={t("nav.brandSubtitle")}
|
||||
variant="home"
|
||||
courses={courses}
|
||||
programs={programs}
|
||||
/>
|
||||
<CampaignBanners banners={banners} />
|
||||
<div className="min-w-0 flex-1 overflow-x-clip">{children}</div>
|
||||
@@ -56,6 +56,7 @@ export default async function MainLayout({
|
||||
linksTitle={t("footer.links")}
|
||||
links={[
|
||||
{ label: t("footer.facultySite"), href: facultySiteUrl },
|
||||
{ label: t("footer.facultyNetwork"), href: facultyNetworkUrl },
|
||||
{ label: t("footer.press"), href: "/press" },
|
||||
{ label: t("footer.careers"), href: "/careers" },
|
||||
]}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { NewsDetailTemplate } from "@/components/templates/NewsDetailTemplate";
|
||||
import { getNewsById, newsExcerpt } from "@/lib/data/news";
|
||||
import { pageMetadata } from "@/lib/seo/metadata";
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}): Promise<Metadata> {
|
||||
const { id } = await params;
|
||||
const item = await getNewsById(id);
|
||||
if (!item) {
|
||||
return pageMetadata({
|
||||
title: "خبر",
|
||||
description: "خبر مرکز آموزش های آزاد",
|
||||
path: `/news/${id}`,
|
||||
});
|
||||
}
|
||||
return pageMetadata({
|
||||
title: item.title,
|
||||
description: newsExcerpt(item.body),
|
||||
path: `/news/${item.id}`,
|
||||
image: item.bannerImageUrl,
|
||||
});
|
||||
}
|
||||
|
||||
export default async function NewsDetailPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const { id } = await params;
|
||||
const item = await getNewsById(id);
|
||||
if (!item) notFound();
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<NewsDetailTemplate item={item} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { Metadata } from "next";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { NewsListTemplate } from "@/components/templates/NewsListTemplate";
|
||||
import { getNews } from "@/lib/data/news";
|
||||
import { pageMetadata } from "@/lib/seo/metadata";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("pages");
|
||||
return pageMetadata({
|
||||
title: t("newsTitle"),
|
||||
description: t("newsIntro"),
|
||||
path: "/news",
|
||||
});
|
||||
}
|
||||
|
||||
export default async function NewsPage() {
|
||||
const [t, items] = await Promise.all([getTranslations("pages"), getNews()]);
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<NewsListTemplate
|
||||
items={items}
|
||||
title={t("newsTitle")}
|
||||
intro={t("newsIntro")}
|
||||
emptyLabel={t("newsEmpty")}
|
||||
/>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -5,13 +5,11 @@ import {
|
||||
HomeApproach,
|
||||
HomeClosing,
|
||||
HomeCourseSearch,
|
||||
HomeEventsTeaser,
|
||||
HomeHero,
|
||||
HomeIdeas,
|
||||
HomeTeams,
|
||||
type HomeLabels,
|
||||
} from "@/components/templates/HomeTemplate";
|
||||
import { getFeaturedArticle } from "@/lib/data/articles";
|
||||
import { getLatestCourses } from "@/lib/data/courses";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
@@ -46,11 +44,8 @@ async function orFallback<T>(
|
||||
}
|
||||
|
||||
async function HeroSection() {
|
||||
const [featured, labels] = await Promise.all([
|
||||
orFallback("featured article", getFeaturedArticle, null),
|
||||
getLabels(),
|
||||
]);
|
||||
return <HomeHero featured={featured} eyebrow={labels.ideasEyebrow} />;
|
||||
const labels = await getLabels();
|
||||
return <HomeHero featured={null} eyebrow={labels.ideasEyebrow} />;
|
||||
}
|
||||
|
||||
async function CourseSearchSection() {
|
||||
@@ -76,7 +71,6 @@ export default function HomePage() {
|
||||
<HomeIdeas />
|
||||
<CourseSearchSection />
|
||||
<HomeApproach />
|
||||
<HomeEventsTeaser />
|
||||
<HomeTeams />
|
||||
<HomeClosing />
|
||||
</main>
|
||||
|
||||
@@ -1,115 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
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 { CheckList } from "@/components/molecules/CheckList";
|
||||
import { DetailList } from "@/components/molecules/DetailList";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { SectionHeader } from "@/components/molecules/SectionHeader";
|
||||
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { getCourses } from "@/lib/data/courses";
|
||||
import { getProgramBySlug } from "@/lib/data/programs";
|
||||
import { pageMetadata, truncateMetaDescription } from "@/lib/seo/metadata";
|
||||
|
||||
type Props = { params: Promise<{ slug: string }> };
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const program = await getProgramBySlug(slug);
|
||||
if (!program) return { title: "برنامه یافت نشد" };
|
||||
return pageMetadata({
|
||||
title: program.title,
|
||||
description: truncateMetaDescription(program.blurb),
|
||||
path: `/programs/${slug}`,
|
||||
});
|
||||
}
|
||||
|
||||
export default async function ProgramDetailPage({ params }: Props) {
|
||||
const { slug } = await params;
|
||||
const [program, courses, t] = await Promise.all([
|
||||
getProgramBySlug(slug),
|
||||
getCourses(),
|
||||
getTranslations("pages"),
|
||||
]);
|
||||
if (!program) notFound();
|
||||
|
||||
const related = courses.slice(0, 3);
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<PageHero
|
||||
title={program.title}
|
||||
intro={program.blurb}
|
||||
eyebrow={program.tagline}
|
||||
/>
|
||||
<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">
|
||||
<p className="text-base leading-8 text-foreground/90">{program.body}</p>
|
||||
{program.highlights.length > 0 ? (
|
||||
<section className="space-y-4">
|
||||
<Heading level={3} as="h2">
|
||||
{t("highlights")}
|
||||
</Heading>
|
||||
<CheckList items={program.highlights} />
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
<aside className="min-w-0 space-y-4 lg:sticky lg:top-28">
|
||||
<SurfaceCard padded as="div">
|
||||
<DetailList
|
||||
items={[
|
||||
{ label: "مخاطب", value: program.audience },
|
||||
{ label: "مدت", value: program.durationLabel },
|
||||
{ label: "فرمت", value: program.formatLabel },
|
||||
]}
|
||||
/>
|
||||
<Link
|
||||
href="/professional"
|
||||
className={cn(buttonVariants({ size: "lg" }), "mt-6 w-full font-bold")}
|
||||
>
|
||||
مشاهده دوره ها
|
||||
</Link>
|
||||
</SurfaceCard>
|
||||
<TextLink href="/programs" className="block px-1 text-sm">
|
||||
{t("backToPrograms")}
|
||||
</TextLink>
|
||||
</aside>
|
||||
</Container>
|
||||
</Section>
|
||||
{related.length > 0 ? (
|
||||
<Section tone="muted">
|
||||
<Container>
|
||||
<SectionHeader title={t("relatedCourses")} />
|
||||
<ul className="grid gap-4 sm:grid-cols-3">
|
||||
{related.map((course) => (
|
||||
<li key={course.id}>
|
||||
<Link href={course.registrationUrl} className="group block h-full">
|
||||
<SurfaceCard padded as="div" interactive className="h-full">
|
||||
<Heading
|
||||
as="h3"
|
||||
level={4}
|
||||
className="transition-colors group-hover:text-accent"
|
||||
>
|
||||
{course.title}
|
||||
</Heading>
|
||||
<p className="mt-2 line-clamp-3 text-sm leading-7 text-muted-foreground">
|
||||
{course.summary}
|
||||
</p>
|
||||
</SurfaceCard>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Container>
|
||||
</Section>
|
||||
) : null}
|
||||
</main>
|
||||
);
|
||||
export default function ProgramDetailPage() {
|
||||
notFound();
|
||||
}
|
||||
@@ -1,93 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Heading } from "@/components/atoms/Heading";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { BadgeLabel } from "@/components/atoms/BadgeLabel";
|
||||
import { DetailList } from "@/components/molecules/DetailList";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { SectionHeader } from "@/components/molecules/SectionHeader";
|
||||
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { getPrograms } from "@/lib/data/programs";
|
||||
import { pageMetadata } from "@/lib/seo/metadata";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("pages");
|
||||
return pageMetadata({
|
||||
title: t("programsTitle"),
|
||||
description: t("programsIntro"),
|
||||
path: "/programs",
|
||||
});
|
||||
}
|
||||
|
||||
export default async function ProgramsPage() {
|
||||
const t = await getTranslations("pages");
|
||||
const programs = await getPrograms();
|
||||
const standard = programs.filter((p) => p.group === "standard");
|
||||
const executive = programs.filter((p) => p.group === "executive");
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<PageHero
|
||||
title={t("programsTitle")}
|
||||
intro={t("programsIntro")}
|
||||
imageUrl="/brand/neural-tree-knowledge.webp"
|
||||
/>
|
||||
<Section tone="subtle">
|
||||
<Container className="space-y-16">
|
||||
<ProgramGroup title={t("standardGroup")} items={standard} />
|
||||
<ProgramGroup title={t("executiveGroup")} items={executive} />
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function ProgramGroup({
|
||||
title,
|
||||
items,
|
||||
}: {
|
||||
title: string;
|
||||
items: Awaited<ReturnType<typeof getPrograms>>;
|
||||
}) {
|
||||
if (items.length === 0) return null;
|
||||
return (
|
||||
<div>
|
||||
<SectionHeader title={title} className="mb-6 sm:mb-8" />
|
||||
<div className="grid gap-5 md:grid-cols-2">
|
||||
{items.map((program) => (
|
||||
<SurfaceCard key={program.id} padded className="flex flex-col">
|
||||
{program.tagline ? (
|
||||
<BadgeLabel className="w-fit">{program.tagline}</BadgeLabel>
|
||||
) : null}
|
||||
<Heading as="h3" level={3} className="mt-3">
|
||||
<Link href={program.href} className="transition-colors hover:text-accent">
|
||||
{program.title}
|
||||
</Link>
|
||||
</Heading>
|
||||
<p className="mt-2 flex-1 text-sm leading-7 text-muted-foreground">
|
||||
{program.blurb}
|
||||
</p>
|
||||
<DetailList
|
||||
className="mt-5 border-t border-border pt-4"
|
||||
items={[
|
||||
{ label: "مخاطب", value: program.audience },
|
||||
{ label: "مدت", value: program.durationLabel },
|
||||
{ label: "فرمت", value: program.formatLabel },
|
||||
]}
|
||||
/>
|
||||
<Link
|
||||
href={program.href}
|
||||
className={cn(buttonVariants({ variant: "outline" }), "mt-6 w-fit")}
|
||||
>
|
||||
جزئیات برنامه
|
||||
</Link>
|
||||
</SurfaceCard>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
export default function ProgramsPage() {
|
||||
notFound();
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { notFound } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { CourseDetailTemplate } from "@/components/templates/CourseDetailTemplate";
|
||||
import { getCourseById } from "@/lib/data/courses";
|
||||
import { htmlToPlain } from "@/lib/html-text";
|
||||
import { pageMetadata, truncateMetaDescription } from "@/lib/seo/metadata";
|
||||
|
||||
type Props = { params: Promise<{ slug: string }> };
|
||||
@@ -15,7 +16,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
return pageMetadata({
|
||||
title: course.title,
|
||||
description: truncateMetaDescription(
|
||||
course.seoDescription || course.summary,
|
||||
course.seoDescription || htmlToPlain(course.summary),
|
||||
),
|
||||
path: `/register/${pathSlug}`,
|
||||
...(course.posterImageUrl ? { image: course.posterImageUrl } : {}),
|
||||
@@ -45,6 +46,7 @@ export default async function CourseRegisterPage({ params }: Props) {
|
||||
detailsTitle: t("courseDetailsTitle"),
|
||||
aboutTitle: t("courseAboutTitle"),
|
||||
duration: t("courseDuration"),
|
||||
date: t("courseDate"),
|
||||
format: t("courseFormat"),
|
||||
category: t("courseCategory"),
|
||||
price: t("coursePrice"),
|
||||
|
||||
@@ -1,69 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Section } from "@/components/atoms/Section";
|
||||
import { TextLink } from "@/components/atoms/TextLink";
|
||||
import { CheckList } from "@/components/molecules/CheckList";
|
||||
import { PageHero } from "@/components/molecules/PageHero";
|
||||
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { getTopicBySlug } from "@/lib/data/site";
|
||||
import { pageMetadata, truncateMetaDescription } from "@/lib/seo/metadata";
|
||||
|
||||
type Props = { params: Promise<{ slug: string }> };
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const topic = await getTopicBySlug(slug);
|
||||
if (!topic) return { title: "موضوع یافت نشد" };
|
||||
return pageMetadata({
|
||||
title: topic.title,
|
||||
description: truncateMetaDescription(topic.description),
|
||||
path: `/topics/${slug}`,
|
||||
image: topic.imageUrl,
|
||||
});
|
||||
}
|
||||
|
||||
export default async function TopicPage({ params }: Props) {
|
||||
const { slug } = await params;
|
||||
const topic = await getTopicBySlug(slug);
|
||||
if (!topic) notFound();
|
||||
|
||||
return (
|
||||
<main id="main-content">
|
||||
<PageHero
|
||||
title={topic.title}
|
||||
intro={topic.description}
|
||||
imageUrl={topic.imageUrl}
|
||||
/>
|
||||
<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-8">
|
||||
<p className="text-base leading-8 text-foreground/90">{topic.body}</p>
|
||||
{topic.highlights.length > 0 ? (
|
||||
<CheckList items={topic.highlights} />
|
||||
) : null}
|
||||
</div>
|
||||
<aside className="min-w-0 space-y-4 lg:sticky lg:top-28">
|
||||
<SurfaceCard padded as="div">
|
||||
<p className="text-sm leading-7 text-muted-foreground">
|
||||
دوره های مرتبط با این موضوع را در فهرست دوره های کوتاه ببینید.
|
||||
</p>
|
||||
<Link
|
||||
href="/professional"
|
||||
className={cn(buttonVariants({ size: "lg" }), "mt-5 w-full font-bold")}
|
||||
>
|
||||
مشاهده دوره ها
|
||||
</Link>
|
||||
</SurfaceCard>
|
||||
<TextLink href="/" className="block px-1 text-sm">
|
||||
بازگشت به خانه
|
||||
</TextLink>
|
||||
</aside>
|
||||
</Container>
|
||||
</Section>
|
||||
</main>
|
||||
);
|
||||
export default function TopicPage() {
|
||||
notFound();
|
||||
}
|
||||
@@ -43,7 +43,7 @@ export default async function ValuesPage() {
|
||||
<Heading as="h2" level={4} className="mt-2">
|
||||
{item.title}
|
||||
</Heading>
|
||||
<p className="mt-2 text-sm leading-7 text-muted-foreground">
|
||||
<p className="mt-2 text-justify text-sm leading-7 text-muted-foreground">
|
||||
{item.text}
|
||||
</p>
|
||||
</SurfaceCard>
|
||||
@@ -69,7 +69,7 @@ export default async function ValuesPage() {
|
||||
<Heading as="h3" level={4} className="group-hover:text-accent">
|
||||
{example.title}
|
||||
</Heading>
|
||||
<p className="mt-2 text-sm leading-7 text-muted-foreground">
|
||||
<p className="mt-2 text-justify text-sm leading-7 text-muted-foreground">
|
||||
{example.text}
|
||||
</p>
|
||||
<span className="mt-4 inline-flex items-center gap-1.5 text-sm font-semibold text-accent">
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToAlumniStory, type AlumniStoryRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { alumniPatchSchema } from "@/lib/validation/admin";
|
||||
import { alumniPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -40,7 +40,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = alumniPatchSchema.safeParse(body);
|
||||
const parsed = alumniPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToAlumniStory, type AlumniStoryRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { alumniCreateSchema } from "@/lib/validation/admin";
|
||||
import { alumniCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
||||
@@ -24,7 +24,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = alumniCreateSchema.safeParse(body);
|
||||
const parsed = alumniCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToArticle, type ArticleRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { articlePatchSchema } from "@/lib/validation/admin";
|
||||
import { articlePatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
@@ -43,7 +43,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = articlePatchSchema.safeParse(body);
|
||||
const parsed = articlePatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { randomUUID } from "node:crypto";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToArticle, type ArticleRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { articleCreateSchema } from "@/lib/validation/admin";
|
||||
import { articleCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
@@ -26,7 +26,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = articleCreateSchema.safeParse(body);
|
||||
const parsed = articleCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToCampaignBanner, type CampaignBannerRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { bannerPatchSchema } from "@/lib/validation/admin";
|
||||
import { bannerPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -34,7 +34,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = bannerPatchSchema.safeParse(body);
|
||||
const parsed = bannerPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToCampaignBanner, type CampaignBannerRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { bannerCreateSchema } from "@/lib/validation/admin";
|
||||
import { bannerCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = bannerCreateSchema.safeParse(body);
|
||||
const parsed = bannerCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { courseCategoryPatchSchema } from "@/lib/validation/admin";
|
||||
import { courseCategoryPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -33,7 +33,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = courseCategoryPatchSchema.safeParse(body);
|
||||
const parsed = courseCategoryPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { courseCategoryCreateSchema } from "@/lib/validation/admin";
|
||||
import { courseCategoryCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
@@ -20,7 +20,7 @@ export async function POST(request: Request) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = courseCategoryCreateSchema.safeParse(body);
|
||||
const parsed = courseCategoryCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { courseTagPatchSchema } from "@/lib/validation/admin";
|
||||
import { courseTagPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -34,7 +34,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = courseTagPatchSchema.safeParse(body);
|
||||
const parsed = courseTagPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { courseTagCreateSchema } from "@/lib/validation/admin";
|
||||
import { courseTagCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
@@ -20,7 +20,7 @@ export async function POST(request: Request) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = courseTagCreateSchema.safeParse(body);
|
||||
const parsed = courseTagCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { coursePatchSchema } from "@/lib/validation/admin";
|
||||
import { coursePatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
@@ -38,6 +38,7 @@ const COURSE_COLUMNS: Record<string, string> = {
|
||||
title: "title",
|
||||
summary: "summary",
|
||||
durationHours: "duration_hours",
|
||||
startDate: "start_date",
|
||||
format: "format",
|
||||
price: "price",
|
||||
registrationUrl: "registration_url",
|
||||
@@ -47,6 +48,8 @@ const COURSE_COLUMNS: Record<string, string> = {
|
||||
bodyHtml: "body_html",
|
||||
seoDescription: "seo_description",
|
||||
published: "published",
|
||||
featured: "featured",
|
||||
sortOrder: "sort_order",
|
||||
};
|
||||
|
||||
// PATCH /api/admin/courses/[id] — update course (admin only)
|
||||
@@ -66,7 +69,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = coursePatchSchema.safeParse(body);
|
||||
const parsed = coursePatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { query } from "@/lib/db";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { courseCreateSchema } from "@/lib/validation/admin";
|
||||
import { courseCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
@@ -53,7 +53,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = courseCreateSchema.safeParse(body);
|
||||
const parsed = courseCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
@@ -63,16 +63,17 @@ export async function POST(request: NextRequest) {
|
||||
try {
|
||||
await query(
|
||||
`INSERT INTO courses
|
||||
(id, slug, title, summary, duration_hours, format, price,
|
||||
(id, slug, title, summary, duration_hours, start_date, 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,$18)`,
|
||||
[
|
||||
id,
|
||||
d.slug,
|
||||
d.title,
|
||||
d.summary,
|
||||
d.durationHours ?? null,
|
||||
d.startDate ?? null,
|
||||
d.format,
|
||||
d.price ?? null,
|
||||
d.registrationUrl,
|
||||
@@ -83,6 +84,8 @@ export async function POST(request: NextRequest) {
|
||||
d.bodyHtml,
|
||||
d.seoDescription,
|
||||
d.published,
|
||||
d.featured,
|
||||
d.sortOrder,
|
||||
],
|
||||
);
|
||||
await setCourseCategories(id, d.categoryIds ?? []);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToEvent, type EventRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { eventPatchSchema } from "@/lib/validation/admin";
|
||||
import { eventPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -40,7 +40,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = eventPatchSchema.safeParse(body);
|
||||
const parsed = eventPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToEvent, type EventRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { eventCreateSchema } from "@/lib/validation/admin";
|
||||
import { eventCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
||||
@@ -24,7 +24,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = eventCreateSchema.safeParse(body);
|
||||
const parsed = eventCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToFacultyMember, type FacultyMemberRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { facultyPatchSchema } from "@/lib/validation/admin";
|
||||
import { facultyPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -42,7 +42,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = facultyPatchSchema.safeParse(body);
|
||||
const parsed = facultyPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToFacultyMember, type FacultyMemberRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { facultyCreateSchema } from "@/lib/validation/admin";
|
||||
import { facultyCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = facultyCreateSchema.safeParse(body);
|
||||
const parsed = facultyCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToLegalPage, type LegalPageRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { legalPatchSchema } from "@/lib/validation/admin";
|
||||
import { legalPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -32,7 +32,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = legalPatchSchema.safeParse(body);
|
||||
const parsed = legalPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToLegalPage, type LegalPageRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { legalCreateSchema } from "@/lib/validation/admin";
|
||||
import { legalCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
@@ -21,7 +21,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = legalCreateSchema.safeParse(body);
|
||||
const parsed = legalCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToNews, type NewsRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { newsPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const NEWS_COLUMNS: Record<string, string> = {
|
||||
title: "title",
|
||||
bannerImageUrl: "banner_image_url",
|
||||
body: "body",
|
||||
galleryImages: "gallery_images",
|
||||
publishedAt: "published_at",
|
||||
published: "published",
|
||||
};
|
||||
|
||||
// PATCH /api/admin/news/[id] — update a news item (admin only)
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
const session = await requireAdmin();
|
||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||
|
||||
const { id } = await params;
|
||||
|
||||
let body: unknown;
|
||||
try {
|
||||
body = await parseJsonBody(request);
|
||||
} catch {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = newsPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
const data: Record<string, unknown> = { ...parsed.data };
|
||||
if (data.galleryImages !== undefined) {
|
||||
data.galleryImages = JSON.stringify(data.galleryImages);
|
||||
}
|
||||
|
||||
const spec = buildUpdate("news_items", "id", NEWS_COLUMNS, data);
|
||||
if (spec.empty) return errorResponse("حداقل یک فیلد برای ویرایش لازم است", 400);
|
||||
|
||||
try {
|
||||
const res = await query<NewsRow>(spec.sql, [...spec.params, id]);
|
||||
if (res.rows.length === 0) return errorResponse("خبر یافت نشد", 404);
|
||||
const row = res.rows[0];
|
||||
return NextResponse.json({ ok: true, data: { ...rowToNews(row), published: row.published } });
|
||||
} catch (err) {
|
||||
console.error("admin update news error:", err);
|
||||
return errorResponse("خطای سرور", 500);
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE /api/admin/news/[id] — delete a news item (admin only)
|
||||
export async function DELETE(
|
||||
_request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
const session = await requireAdmin();
|
||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||
|
||||
const { id } = await params;
|
||||
try {
|
||||
const res = await query(`DELETE FROM news_items WHERE id = $1 RETURNING id`, [id]);
|
||||
if (res.rows.length === 0) return errorResponse("خبر یافت نشد", 404);
|
||||
revalidateSite();
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch (err) {
|
||||
console.error("admin delete news error:", err);
|
||||
return errorResponse("خطای سرور", 500);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToNews, type NewsRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { newsCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// POST /api/admin/news — create a news item (admin only)
|
||||
export async function POST(request: NextRequest) {
|
||||
const session = await requireAdmin();
|
||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||
|
||||
let body: unknown;
|
||||
try {
|
||||
body = await parseJsonBody(request);
|
||||
} catch {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = newsCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
const d = parsed.data;
|
||||
const id = makeId();
|
||||
|
||||
try {
|
||||
const { sql, params } = buildInsert(
|
||||
"news_items",
|
||||
["id", "title", "banner_image_url", "body", "gallery_images", "published_at", "published"],
|
||||
[
|
||||
id,
|
||||
d.title,
|
||||
d.bannerImageUrl,
|
||||
d.body,
|
||||
JSON.stringify(d.galleryImages),
|
||||
d.publishedAt,
|
||||
d.published,
|
||||
],
|
||||
);
|
||||
await query(sql, params);
|
||||
const res = await query<NewsRow>(`SELECT * FROM news_items WHERE id = $1`, [id]);
|
||||
const row = res.rows[0];
|
||||
return NextResponse.json(
|
||||
{ ok: true, data: { ...rowToNews(row), published: row.published } },
|
||||
{ status: 201 },
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("admin create news error:", err);
|
||||
return errorResponse("خطای سرور", 500);
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,12 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToProgram, type ProgramRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { programPatchSchema } from "@/lib/validation/admin";
|
||||
import { programPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -30,6 +31,9 @@ export async function PATCH(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
const disabled = disabledAdminEntityResponse("programs");
|
||||
if (disabled) return disabled;
|
||||
|
||||
const session = await requireAdmin();
|
||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||
|
||||
@@ -42,7 +46,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = programPatchSchema.safeParse(body);
|
||||
const parsed = programPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
@@ -74,6 +78,9 @@ export async function DELETE(
|
||||
_request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
const disabled = disabledAdminEntityResponse("programs");
|
||||
if (disabled) return disabled;
|
||||
|
||||
const session = await requireAdmin();
|
||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||
|
||||
|
||||
@@ -2,15 +2,19 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToProgram, type ProgramRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { programCreateSchema } from "@/lib/validation/admin";
|
||||
import { programCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// POST /api/admin/programs — create program (admin only)
|
||||
export async function POST(request: NextRequest) {
|
||||
const disabled = disabledAdminEntityResponse("programs");
|
||||
if (disabled) return disabled;
|
||||
|
||||
const session = await requireAdmin();
|
||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||
|
||||
@@ -21,7 +25,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = programCreateSchema.safeParse(body);
|
||||
const parsed = programCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { registrationStatusSchema } from "@/lib/validation/admin";
|
||||
import { registrationStatusSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { parseJsonBody } from "@/lib/api/crud";
|
||||
import type { RegistrationLeadRow } from "@/app/api/admin/registrations/route";
|
||||
@@ -25,7 +25,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = registrationStatusSchema.safeParse(body);
|
||||
const parsed = registrationStatusSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToSiteStat, type SiteStatRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { statPatchSchema } from "@/lib/validation/admin";
|
||||
import { statPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -32,7 +32,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = statPatchSchema.safeParse(body);
|
||||
const parsed = statPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToSiteStat, type SiteStatRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { statCreateSchema } from "@/lib/validation/admin";
|
||||
import { statCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = statCreateSchema.safeParse(body);
|
||||
const parsed = statCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToTestimonial, type TestimonialRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { testimonialPatchSchema } from "@/lib/validation/admin";
|
||||
import { testimonialPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -34,7 +34,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = testimonialPatchSchema.safeParse(body);
|
||||
const parsed = testimonialPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToTestimonial, type TestimonialRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { testimonialCreateSchema } from "@/lib/validation/admin";
|
||||
import { testimonialCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = testimonialCreateSchema.safeParse(body);
|
||||
const parsed = testimonialCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToIntersectionTopic, type IntersectionTopicRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { topicPatchSchema } from "@/lib/validation/admin";
|
||||
import { topicPatchSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { revalidateSite } from "@/lib/api/revalidate";
|
||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||
@@ -38,7 +38,7 @@ export async function PATCH(
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = topicPatchSchema.safeParse(body);
|
||||
const parsed = topicPatchSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { query } from "@/lib/db";
|
||||
import { rowToIntersectionTopic, type IntersectionTopicRow } from "@/lib/db/mappers";
|
||||
import { requireAdmin } from "@/lib/auth/admin";
|
||||
import { topicCreateSchema } from "@/lib/validation/admin";
|
||||
import { topicCreateSchema, normalizeRichWrite } from "@/lib/validation/admin";
|
||||
import { errorResponse } from "@/lib/api/response";
|
||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||
import { isUniqueViolation } from "@/lib/db/errors";
|
||||
@@ -21,7 +21,7 @@ export async function POST(request: NextRequest) {
|
||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||
}
|
||||
|
||||
const parsed = topicCreateSchema.safeParse(body);
|
||||
const parsed = topicCreateSchema.safeParse(normalizeRichWrite(body));
|
||||
if (!parsed.success) {
|
||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getArticleById } from "@/lib/data/articles";
|
||||
|
||||
type Params = { params: Promise<{ id: string }> };
|
||||
|
||||
export async function GET(_request: Request, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const article = await getArticleById(id);
|
||||
if (!article) {
|
||||
return NextResponse.json({ error: "Article not found" }, { status: 404 });
|
||||
}
|
||||
return NextResponse.json({ data: article });
|
||||
export function GET() {
|
||||
return new NextResponse(null, { status: 404 });
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getArticles } from "@/lib/data/articles";
|
||||
|
||||
export async function GET() {
|
||||
const data = await getArticles();
|
||||
return NextResponse.json({ data });
|
||||
export function GET() {
|
||||
return new NextResponse(null, { status: 404 });
|
||||
}
|
||||
@@ -1,13 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getEventById } from "@/lib/data/events";
|
||||
|
||||
type Params = { params: Promise<{ id: string }> };
|
||||
|
||||
export async function GET(_request: Request, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const event = await getEventById(id);
|
||||
if (!event) {
|
||||
return NextResponse.json({ error: "Event not found" }, { status: 404 });
|
||||
}
|
||||
return NextResponse.json({ data: event });
|
||||
export function GET() {
|
||||
return new NextResponse(null, { status: 404 });
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getEvents } from "@/lib/data/events";
|
||||
|
||||
export async function GET() {
|
||||
const data = await getEvents();
|
||||
return NextResponse.json({ data });
|
||||
export function GET() {
|
||||
return new NextResponse(null, { status: 404 });
|
||||
}
|
||||
@@ -1,13 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getProgramBySlug } from "@/lib/data/programs";
|
||||
|
||||
type Params = { params: Promise<{ slug: string }> };
|
||||
|
||||
export async function GET(_request: Request, { params }: Params) {
|
||||
const { slug } = await params;
|
||||
const program = await getProgramBySlug(slug);
|
||||
if (!program) {
|
||||
return NextResponse.json({ error: "Program not found" }, { status: 404 });
|
||||
}
|
||||
return NextResponse.json({ data: program });
|
||||
export function GET() {
|
||||
return new NextResponse(null, { status: 404 });
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getPrograms } from "@/lib/data/programs";
|
||||
|
||||
export async function GET() {
|
||||
const data = await getPrograms();
|
||||
return NextResponse.json({ data });
|
||||
export function GET() {
|
||||
return new NextResponse(null, { status: 404 });
|
||||
}
|
||||
@@ -184,6 +184,19 @@
|
||||
/* Metamorph field: static on purpose (animations removed for mobile perf).
|
||||
Legacy keyframes kept only so reduced-motion rules stay harmless. */
|
||||
|
||||
/* Persian paragraphs: even both edges. Last line stays natural. */
|
||||
.text-justify {
|
||||
text-justify: inter-word;
|
||||
}
|
||||
|
||||
.rich-text-editor p.is-editor-empty:first-child::before {
|
||||
float: inline-end;
|
||||
height: 0;
|
||||
color: var(--muted-foreground);
|
||||
content: attr(data-placeholder);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.page-hero::after,
|
||||
.home-hero::after {
|
||||
position: absolute;
|
||||
|
||||
@@ -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`}
|
||||
>
|
||||
<NextIntlClientProvider messages={messages}>
|
||||
<Suspense fallback={null}>
|
||||
<GlobalActionLoadingOverlay />
|
||||
</Suspense>
|
||||
<a
|
||||
href="#main-content"
|
||||
className="sr-only focus:not-sr-only focus:absolute focus:start-4 focus:top-4 focus:z-[100] focus:bg-card focus:px-3 focus:py-2"
|
||||
|
||||
@@ -39,6 +39,7 @@ const getCounts = async (): Promise<Record<string, number>> => {
|
||||
UNION ALL SELECT 'programs', count(*) FROM programs
|
||||
UNION ALL SELECT 'events', count(*) FROM events
|
||||
UNION ALL SELECT 'articles', count(*) FROM articles
|
||||
UNION ALL SELECT 'news', count(*) FROM news_items
|
||||
UNION ALL SELECT 'faculty', count(*) FROM faculty_members
|
||||
UNION ALL SELECT 'alumni', count(*) FROM alumni_stories`,
|
||||
);
|
||||
@@ -49,6 +50,7 @@ const countCards = [
|
||||
{ key: "courses", label: "دوره ها", href: "/mstcontroller/courses", icon: BookOpen },
|
||||
{ key: "programs", label: "برنامه ها", href: "/mstcontroller/programs", icon: GraduationCap },
|
||||
{ key: "events", label: "رویدادها", href: "/mstcontroller/events", icon: Calendar },
|
||||
{ key: "news", label: "اخبار", href: "/mstcontroller/news", icon: Newspaper },
|
||||
{ key: "articles", label: "مقالات", href: "/mstcontroller/articles", icon: Newspaper },
|
||||
{ key: "faculty", label: "اساتید", href: "/mstcontroller/faculty", icon: Users },
|
||||
{ key: "alumni", label: "دانش آموختگان", href: "/mstcontroller/alumni", icon: MessageSquareQuote },
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
import { useState, FormEvent, Suspense } from "react";
|
||||
import Image from "next/image";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useAppRouter } from "@/hooks/use-app-router";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
@@ -17,7 +18,7 @@ import {
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
function LoginForm() {
|
||||
const router = useRouter();
|
||||
const router = useAppRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const redirect = searchParams.get("redirect") || "/mstcontroller";
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import { SiteHeader } from "@/components/organisms/SiteHeader";
|
||||
import { buildCourseNavChildren } from "@/lib/course-nav";
|
||||
import { getCourses } from "@/lib/data/courses";
|
||||
import { listPublishedCourseTags } from "@/lib/data/taxonomy";
|
||||
import { getPrograms } from "@/lib/data/programs";
|
||||
import {
|
||||
courseNavParentTag,
|
||||
facultyNetworkUrl,
|
||||
facultySiteUrl,
|
||||
professionalNav,
|
||||
siteShortName,
|
||||
@@ -22,12 +22,10 @@ export default async function ProfessionalLayout({
|
||||
const t = await getTranslations();
|
||||
const year = new Date().getFullYear();
|
||||
let courses: Awaited<ReturnType<typeof getCourses>> = [];
|
||||
let programs: Awaited<ReturnType<typeof getPrograms>> = [];
|
||||
let navTags: Awaited<ReturnType<typeof listPublishedCourseTags>> = [];
|
||||
try {
|
||||
[courses, programs, navTags] = await Promise.all([
|
||||
[courses, navTags] = await Promise.all([
|
||||
getCourses(),
|
||||
getPrograms(),
|
||||
listPublishedCourseTags({ navOnly: true }),
|
||||
]);
|
||||
} catch (err) {
|
||||
@@ -53,7 +51,6 @@ export default async function ProfessionalLayout({
|
||||
brandSubtitle={t("nav.brandSubtitle")}
|
||||
variant="professional"
|
||||
courses={courses}
|
||||
programs={programs}
|
||||
/>
|
||||
<div className="min-w-0 flex-1 overflow-x-clip">{children}</div>
|
||||
<SiteFooter
|
||||
@@ -62,6 +59,7 @@ export default async function ProfessionalLayout({
|
||||
linksTitle={t("footer.links")}
|
||||
links={[
|
||||
{ label: t("footer.facultySite"), href: facultySiteUrl },
|
||||
{ label: t("footer.facultyNetwork"), href: facultyNetworkUrl },
|
||||
{ label: t("footer.press"), href: "/press" },
|
||||
{ label: t("footer.careers"), href: "/careers" },
|
||||
]}
|
||||
|
||||
+31
-79
@@ -1,9 +1,7 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { getArticles } from "@/lib/data/articles";
|
||||
import { getCourses } from "@/lib/data/courses";
|
||||
import { getEvents } from "@/lib/data/events";
|
||||
import { getPrograms } from "@/lib/data/programs";
|
||||
import { getTopics } from "@/lib/data/site";
|
||||
import { connection } from "next/server";
|
||||
import { getCoursesForSitemap } from "@/lib/data/courses";
|
||||
import { getNewsForSitemap } from "@/lib/data/news";
|
||||
|
||||
const BASE_URL = (
|
||||
process.env.NEXT_PUBLIC_SITE_URL ?? "https://edu.mstaut.ir"
|
||||
@@ -15,6 +13,9 @@ const LEGAL_SLUGS = ["press", "careers"] as const;
|
||||
type SitemapEntry = MetadataRoute.Sitemap[number];
|
||||
type ChangeFrequency = NonNullable<SitemapEntry["changeFrequency"]>;
|
||||
|
||||
/** Run on each request so published news and courses stay current. */
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
function sitemapEntry(
|
||||
path: string,
|
||||
options: {
|
||||
@@ -26,103 +27,54 @@ function sitemapEntry(
|
||||
const normalized = path.startsWith("/") ? path : `/${path}`;
|
||||
return {
|
||||
url: `${BASE_URL}${normalized}`,
|
||||
lastModified: options.lastModified ?? new Date(),
|
||||
...(options.lastModified ? { lastModified: options.lastModified } : {}),
|
||||
changeFrequency: options.changeFrequency ?? "monthly",
|
||||
priority: options.priority ?? 0.5,
|
||||
};
|
||||
}
|
||||
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
await connection();
|
||||
|
||||
const entries: MetadataRoute.Sitemap = [
|
||||
sitemapEntry("/", { changeFrequency: "weekly", priority: 1.0 }),
|
||||
sitemapEntry("/professional", { changeFrequency: "weekly", priority: 0.9 }),
|
||||
sitemapEntry("/about", { priority: 0.7 }),
|
||||
sitemapEntry("/contact", { priority: 0.7 }),
|
||||
sitemapEntry("/values", { priority: 0.7 }),
|
||||
sitemapEntry("/alumni", { priority: 0.6 }),
|
||||
sitemapEntry("/programs", { changeFrequency: "weekly", priority: 0.8 }),
|
||||
sitemapEntry("/insights", { changeFrequency: "weekly", priority: 0.7 }),
|
||||
sitemapEntry("/events", { changeFrequency: "weekly", priority: 0.7 }),
|
||||
sitemapEntry("/news", { changeFrequency: "weekly", priority: 0.6 }),
|
||||
...LEGAL_SLUGS.map((slug) =>
|
||||
sitemapEntry(`/${slug}`, { changeFrequency: "yearly", priority: 0.4 }),
|
||||
),
|
||||
];
|
||||
|
||||
try {
|
||||
const courses = await getCourses();
|
||||
for (const course of courses) {
|
||||
if (!course.slug) continue;
|
||||
const [newsResult, coursesResult] = await Promise.allSettled([
|
||||
getNewsForSitemap(),
|
||||
getCoursesForSitemap(),
|
||||
]);
|
||||
|
||||
if (newsResult.status === "fulfilled") {
|
||||
for (const item of newsResult.value) {
|
||||
entries.push(
|
||||
sitemapEntry(`/register/${course.slug}`, {
|
||||
sitemapEntry(`/news/${encodeURIComponent(item.id)}`, {
|
||||
changeFrequency: "weekly",
|
||||
priority: 0.6,
|
||||
lastModified: item.updatedAt,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (coursesResult.status === "fulfilled") {
|
||||
for (const course of coursesResult.value) {
|
||||
entries.push(
|
||||
sitemapEntry(`/register/${encodeURIComponent(course.slug)}`, {
|
||||
changeFrequency: "weekly",
|
||||
priority: 0.8,
|
||||
lastModified: course.updatedAt,
|
||||
}),
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
// DB unavailable at build time — omit dynamic course URLs
|
||||
}
|
||||
|
||||
try {
|
||||
const programs = await getPrograms();
|
||||
for (const program of programs) {
|
||||
if (!program.slug) continue;
|
||||
entries.push(
|
||||
sitemapEntry(`/programs/${program.slug}`, {
|
||||
changeFrequency: "monthly",
|
||||
priority: 0.75,
|
||||
}),
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
// omit
|
||||
}
|
||||
|
||||
try {
|
||||
const articles = await getArticles();
|
||||
for (const article of articles) {
|
||||
if (!article.id) continue;
|
||||
entries.push(
|
||||
sitemapEntry(`/insights/${article.id}`, {
|
||||
changeFrequency: "monthly",
|
||||
priority: 0.65,
|
||||
lastModified: article.publishedAt,
|
||||
}),
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
// omit
|
||||
}
|
||||
|
||||
try {
|
||||
const events = await getEvents();
|
||||
for (const event of events) {
|
||||
if (!event.id) continue;
|
||||
entries.push(
|
||||
sitemapEntry(`/events/${event.id}`, {
|
||||
changeFrequency: "weekly",
|
||||
priority: 0.65,
|
||||
lastModified: event.startDate,
|
||||
}),
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
// omit
|
||||
}
|
||||
|
||||
try {
|
||||
const topics = await getTopics();
|
||||
for (const topic of topics) {
|
||||
if (!topic.slug) continue;
|
||||
entries.push(
|
||||
sitemapEntry(`/topics/${topic.slug}`, {
|
||||
changeFrequency: "monthly",
|
||||
priority: 0.6,
|
||||
}),
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
// omit
|
||||
}
|
||||
|
||||
return entries;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { readFile, stat } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
mimeForUploadExt,
|
||||
resolveStoredUploadPath,
|
||||
} from "@/lib/uploads/image";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type RouteParams = { params: Promise<{ path: string[] }> };
|
||||
|
||||
async function lookupUpload(segments: string[]) {
|
||||
const absolutePath = resolveStoredUploadPath(segments);
|
||||
if (!absolutePath) return null;
|
||||
|
||||
try {
|
||||
const info = await stat(absolutePath);
|
||||
if (!info.isFile()) return null;
|
||||
const mime = mimeForUploadExt(path.extname(absolutePath));
|
||||
if (!mime) return null;
|
||||
return { absolutePath, info, mime };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function headersFor(file: { info: { size: number }; mime: string }) {
|
||||
return {
|
||||
"Content-Type": file.mime,
|
||||
"Content-Length": String(file.info.size),
|
||||
"Cache-Control": "public, max-age=31536000, immutable",
|
||||
};
|
||||
}
|
||||
|
||||
export async function GET(_request: Request, { params }: RouteParams) {
|
||||
const { path: segments } = await params;
|
||||
const file = await lookupUpload(segments);
|
||||
if (!file) {
|
||||
return new NextResponse("Not found", { status: 404 });
|
||||
}
|
||||
const buffer = await readFile(file.absolutePath);
|
||||
return new NextResponse(buffer, {
|
||||
status: 200,
|
||||
headers: headersFor(file),
|
||||
});
|
||||
}
|
||||
|
||||
export async function HEAD(_request: Request, { params }: RouteParams) {
|
||||
const { path: segments } = await params;
|
||||
const file = await lookupUpload(segments);
|
||||
if (!file) {
|
||||
return new NextResponse(null, { status: 404 });
|
||||
}
|
||||
return new NextResponse(null, {
|
||||
status: 200,
|
||||
headers: headersFor(file),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import Image, { type ImageProps } from "next/image";
|
||||
import { isRuntimeUploadSrc } from "@/lib/uploads/types";
|
||||
|
||||
/**
|
||||
* next/image optimizer reads from `public/` at build time. Runtime uploads
|
||||
* live outside that tree, so skip optimization for `/uploads/...`.
|
||||
*/
|
||||
export function CmsImage({ src, unoptimized, ...props }: ImageProps) {
|
||||
const skipOptimize =
|
||||
unoptimized ??
|
||||
(typeof src === "string" && isRuntimeUploadSrc(src));
|
||||
|
||||
return <Image src={src} unoptimized={skipOptimize} {...props} />;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { CmsImage } from "@/components/atoms/CmsImage";
|
||||
import { ArrowUpLeft, MapPin, Wifi } from "lucide-react";
|
||||
import {
|
||||
Card,
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "@/components/ui/card";
|
||||
import { blurDataURL } from "@/lib/images";
|
||||
import type { Program } from "@/lib/types";
|
||||
import { htmlToPlain } from "@/lib/html-text";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function ProgramCard({
|
||||
@@ -33,7 +34,7 @@ export function ProgramCard({
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<CardDescription className="leading-relaxed">
|
||||
{program.blurb}
|
||||
{htmlToPlain(program.blurb)}
|
||||
</CardDescription>
|
||||
<span className="mt-5 inline-flex items-center gap-1 text-xs font-bold text-accent">
|
||||
جزئیات برنامه
|
||||
@@ -65,7 +66,7 @@ export function ArticleCard({
|
||||
return (
|
||||
<article className="group grid overflow-hidden border-b border-border py-7 first:pt-0 last:border-b-0 sm:grid-cols-[14rem_1fr] sm:gap-8 lg:grid-cols-[19rem_1fr] lg:py-9">
|
||||
<Link href={href} className="relative aspect-[16/10] overflow-hidden rounded-xl bg-muted sm:aspect-auto sm:min-h-44">
|
||||
<Image src={imageUrl} alt={title} fill placeholder="blur" blurDataURL={blurDataURL} className="object-cover transition-transform duration-500 group-hover:scale-[1.025]" sizes="(max-width:640px) 100vw, 304px" />
|
||||
<CmsImage src={imageUrl} alt={title} fill placeholder="blur" blurDataURL={blurDataURL} className="object-cover transition-transform duration-500 group-hover:scale-[1.025]" sizes="(max-width:640px) 100vw, 304px" />
|
||||
</Link>
|
||||
<div className="flex min-w-0 flex-col justify-center pt-5 sm:pt-0">
|
||||
<p className="text-xs font-bold text-accent">{category}</p>
|
||||
@@ -101,7 +102,7 @@ export function ArticleCard({
|
||||
featured ? "aspect-[16/10]" : "aspect-[4/3]",
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
<CmsImage
|
||||
src={imageUrl}
|
||||
alt={title}
|
||||
fill
|
||||
@@ -236,7 +237,7 @@ export function IntersectionCard({
|
||||
className="group relative block min-h-[16rem] overflow-hidden rounded-2xl bg-primary shadow-sm sm:min-h-[18rem]"
|
||||
>
|
||||
<div className="absolute inset-0 overflow-hidden">
|
||||
<Image
|
||||
<CmsImage
|
||||
src={imageUrl}
|
||||
alt={title}
|
||||
fill
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Image from "next/image";
|
||||
import { CmsImage } from "@/components/atoms/CmsImage";
|
||||
|
||||
/** Card media: banner image when set; otherwise course title on themed surface. */
|
||||
export function CourseCardBanner({
|
||||
@@ -13,7 +13,7 @@ export function CourseCardBanner({
|
||||
return (
|
||||
<div className="pointer-events-none relative aspect-video overflow-hidden bg-primary-foreground/10">
|
||||
{hasBanner ? (
|
||||
<Image
|
||||
<CmsImage
|
||||
src={bannerUrl!}
|
||||
alt=""
|
||||
fill
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import Link from "next/link";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { CourseCardBanner } from "@/components/molecules/CourseCardBanner";
|
||||
import type { Course } from "@/lib/types";
|
||||
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
||||
import { formatCourseScheduleLine } from "@/lib/format-date";
|
||||
import { htmlToPlain } from "@/lib/html-text";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function CourseCatalogCard({
|
||||
course,
|
||||
variant,
|
||||
categorySlug,
|
||||
tagSlug,
|
||||
categoryHref,
|
||||
tagHref,
|
||||
}: {
|
||||
course: Course;
|
||||
variant: "current" | "archive";
|
||||
categorySlug: string;
|
||||
tagSlug: string;
|
||||
categoryHref: (slug: string) => string;
|
||||
tagHref: (slug: string) => string;
|
||||
}) {
|
||||
const priceLabel = formatCoursePrice(course.price);
|
||||
const schedule = formatCourseScheduleLine(course);
|
||||
const isArchive = variant === "archive";
|
||||
const showFeatured = !isArchive && Boolean(course.featured);
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={cn(
|
||||
"group relative gap-0 overflow-hidden py-0 text-primary-foreground transition-colors",
|
||||
isArchive
|
||||
? "bg-primary-foreground/[0.03] opacity-80 ring-primary-foreground/5 hover:ring-primary-foreground/20"
|
||||
: "bg-primary-foreground/5 ring-primary-foreground/10 hover:ring-primary-foreground/30",
|
||||
)}
|
||||
>
|
||||
<Link
|
||||
href={course.registrationUrl}
|
||||
className="absolute inset-0 z-0"
|
||||
aria-label={course.title}
|
||||
tabIndex={-1}
|
||||
/>
|
||||
<CourseCardBanner title={course.title} bannerUrl={course.posterImageUrl} />
|
||||
<CardHeader className="pointer-events-none relative z-[1] gap-1 px-4 pt-4">
|
||||
{showFeatured ? (
|
||||
<Badge
|
||||
variant="outline"
|
||||
className="w-fit border-secondary bg-secondary/20 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
ویژه
|
||||
</Badge>
|
||||
) : null}
|
||||
<CardTitle className="text-base text-primary-foreground">
|
||||
{course.title}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="pointer-events-none relative z-[1] space-y-3 px-4 pb-4">
|
||||
<CardDescription className="line-clamp-3 text-primary-foreground/70">
|
||||
{htmlToPlain(course.summary)}
|
||||
</CardDescription>
|
||||
{course.categories.length > 0 || course.tags.length > 0 ? (
|
||||
<div className="pointer-events-auto flex flex-wrap gap-1.5">
|
||||
{course.categories.map((c) => {
|
||||
const href = categoryHref(c.slug);
|
||||
const active = categorySlug === c.slug;
|
||||
return (
|
||||
<Link
|
||||
key={`cat:${c.id}`}
|
||||
href={href}
|
||||
className="relative z-[2]"
|
||||
aria-current={active ? "true" : undefined}
|
||||
>
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"cursor-pointer border-primary-foreground/25 text-[11px] font-semibold text-primary-foreground/90 hover:bg-primary-foreground/15",
|
||||
active && "border-secondary bg-secondary/25 text-secondary",
|
||||
)}
|
||||
>
|
||||
{c.label}
|
||||
</Badge>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
{course.tags.map((t) => {
|
||||
const href = tagHref(t.slug);
|
||||
const active = tagSlug === t.slug;
|
||||
return (
|
||||
<Link
|
||||
key={`tag:${t.id}`}
|
||||
href={href}
|
||||
className="relative z-[2]"
|
||||
aria-current={active ? "true" : undefined}
|
||||
>
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"cursor-pointer border-primary-foreground/25 text-[10px] text-primary-foreground/75 hover:bg-primary-foreground/15",
|
||||
active && "border-secondary bg-secondary/25 text-secondary",
|
||||
)}
|
||||
>
|
||||
{t.label}
|
||||
</Badge>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-primary-foreground/55">
|
||||
<span>
|
||||
{course.durationHours
|
||||
? `${course.durationHours} ساعت · ${formatLabel(course.format)}`
|
||||
: formatLabel(course.format)}
|
||||
</span>
|
||||
{priceLabel ? (
|
||||
<span className="font-semibold text-primary-foreground/90">
|
||||
{priceLabel}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
{schedule ? (
|
||||
<p className="text-xs text-primary-foreground/70">برگزاری {schedule}</p>
|
||||
) : null}
|
||||
<span className="inline-flex text-sm font-semibold text-primary-foreground underline-offset-4 group-hover:underline">
|
||||
{isArchive ? "مشاهده جزئیات" : "جزئیات و ثبت نام"}
|
||||
</span>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import Image from "next/image";
|
||||
import { CmsImage } from "@/components/atoms/CmsImage";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ export function CourseMediaFigure({
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
<CmsImage
|
||||
src={src}
|
||||
alt={alt}
|
||||
width={width}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Image from "next/image";
|
||||
import { ExternalLink, GraduationCap } from "lucide-react";
|
||||
import { CmsImage } from "@/components/atoms/CmsImage";
|
||||
import { Heading } from "@/components/atoms/Heading";
|
||||
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
@@ -25,7 +25,7 @@ export function FacultyMemberCard({ member }: { member: FacultyMember }) {
|
||||
<SurfaceCard className="group flex h-full flex-col rounded-2xl">
|
||||
<div className="relative mb-5 aspect-[4/3] overflow-hidden rounded-xl bg-muted">
|
||||
{photo ? (
|
||||
<Image
|
||||
<CmsImage
|
||||
src={member.imageUrl}
|
||||
alt={member.name}
|
||||
fill
|
||||
|
||||
@@ -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<string | null>(null);
|
||||
const finishTimerRef = useRef<number | null>(null);
|
||||
const hideTimerRef = useRef<number | null>(null);
|
||||
const stallTimerRef = useRef<number | null>(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 (
|
||||
<div
|
||||
aria-hidden={!visible}
|
||||
aria-busy={visible}
|
||||
className={cn(
|
||||
"pointer-events-none fixed inset-0 z-[200] bg-background/40 backdrop-blur-[1px] transition-opacity duration-200 motion-reduce:transition-none",
|
||||
visible ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -42,18 +42,18 @@ export function HeroFeatured({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Container className="relative z-[2] flex min-h-[34rem] min-w-0 items-center py-16 sm:min-h-[36rem] sm:py-20">
|
||||
<div className="home-hero__copy w-full min-w-0 max-w-2xl text-start lg:max-w-3xl">
|
||||
<div className="max-w-full space-y-1 text-sm font-medium text-primary-foreground/60">
|
||||
<Container className="relative z-[2] grid min-h-[32rem] min-w-0 items-center py-16 sm:min-h-[36rem] sm:py-20 lg:grid-cols-[minmax(0,42rem)_minmax(12rem,1fr)] lg:gap-12">
|
||||
<div className="home-hero__copy w-full min-w-0 text-start">
|
||||
<div className="w-full space-y-1 text-sm font-medium text-primary-foreground/60">
|
||||
<p className="leading-7 text-pretty">{hero.university}</p>
|
||||
<p className="leading-7 text-pretty text-primary-foreground/75">
|
||||
{hero.center}
|
||||
</p>
|
||||
</div>
|
||||
<Heading as="h1" level={1} className="mt-6 max-w-4xl">
|
||||
<Heading as="h1" level={1} className="mt-6">
|
||||
{hero.title}
|
||||
</Heading>
|
||||
<p className="mt-6 max-w-2xl border-t border-secondary/50 pt-5 text-base leading-7 text-pretty text-primary-foreground/65 sm:text-lg sm:leading-8">
|
||||
<p className="mt-6 w-full border-t border-secondary/50 pt-5 text-justify text-base leading-7 text-pretty text-primary-foreground/65 sm:text-lg sm:leading-8">
|
||||
{hero.description}
|
||||
</p>
|
||||
<div className="mt-9 flex flex-wrap gap-3">
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useId, useRef, useState, type ReactNode } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { CalendarDays, ChevronLeft, ChevronRight } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
JALALI_MONTHS,
|
||||
JALALI_WEEKDAYS,
|
||||
daysInJalaliMonth,
|
||||
formatJalaliDate,
|
||||
isoToJalali,
|
||||
jalaliMonthLeadingBlanks,
|
||||
jalaliToIso,
|
||||
todayJalali,
|
||||
toPersianDigits,
|
||||
} from "@/lib/jalali";
|
||||
|
||||
type JalaliDateFieldProps = {
|
||||
id?: string;
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
placeholder?: string;
|
||||
};
|
||||
|
||||
type View = { jy: number; jm: number };
|
||||
|
||||
const PANEL_WIDTH = 292;
|
||||
const PANEL_HEIGHT = 352;
|
||||
|
||||
export function JalaliDateField({
|
||||
id,
|
||||
value,
|
||||
onChange,
|
||||
placeholder = "انتخاب تاریخ",
|
||||
}: JalaliDateFieldProps) {
|
||||
const reactId = useId();
|
||||
const panelId = `${reactId}-panel`;
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
const panelRef = useRef<HTMLDivElement>(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [view, setView] = useState<View>(() => {
|
||||
const current = value ? isoToJalali(value) : null;
|
||||
const base = current ?? todayJalali();
|
||||
return { jy: base.jy, jm: base.jm };
|
||||
});
|
||||
const [position, setPosition] = useState<{ top: number; left: number; width: number } | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
|
||||
function place() {
|
||||
const root = rootRef.current;
|
||||
if (!root) return;
|
||||
const rect = root.getBoundingClientRect();
|
||||
const margin = 8;
|
||||
const width = Math.min(PANEL_WIDTH, window.innerWidth - margin * 2);
|
||||
let left = rect.left;
|
||||
if (left + width > window.innerWidth - margin) {
|
||||
left = Math.max(margin, window.innerWidth - width - margin);
|
||||
}
|
||||
let top = rect.bottom + 4;
|
||||
if (top + PANEL_HEIGHT > window.innerHeight - margin && rect.top > PANEL_HEIGHT + margin) {
|
||||
top = rect.top - PANEL_HEIGHT - 4;
|
||||
}
|
||||
setPosition({ top, left, width });
|
||||
}
|
||||
|
||||
function onPointerDown(event: MouseEvent) {
|
||||
const target = event.target;
|
||||
if (!(target instanceof Node)) return;
|
||||
if (rootRef.current?.contains(target) || panelRef.current?.contains(target)) return;
|
||||
setOpen(false);
|
||||
}
|
||||
|
||||
function onKeyDown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") setOpen(false);
|
||||
}
|
||||
|
||||
place();
|
||||
document.addEventListener("mousedown", onPointerDown);
|
||||
document.addEventListener("keydown", onKeyDown);
|
||||
window.addEventListener("resize", place);
|
||||
window.addEventListener("scroll", place, true);
|
||||
return () => {
|
||||
document.removeEventListener("mousedown", onPointerDown);
|
||||
document.removeEventListener("keydown", onKeyDown);
|
||||
window.removeEventListener("resize", place);
|
||||
window.removeEventListener("scroll", place, true);
|
||||
};
|
||||
}, [open]);
|
||||
|
||||
function openPanel() {
|
||||
const current = value ? isoToJalali(value) : null;
|
||||
const base = current ?? todayJalali();
|
||||
setView({ jy: base.jy, jm: base.jm });
|
||||
setOpen(true);
|
||||
}
|
||||
|
||||
function shiftMonth(delta: number) {
|
||||
setView((current) => {
|
||||
const index = current.jy * 12 + (current.jm - 1) + delta;
|
||||
const jm = ((index % 12) + 12) % 12;
|
||||
return { jy: Math.floor(index / 12), jm: jm + 1 };
|
||||
});
|
||||
}
|
||||
|
||||
function selectDay(day: number) {
|
||||
onChange(jalaliToIso(view.jy, view.jm, day));
|
||||
setOpen(false);
|
||||
}
|
||||
|
||||
const selected = value ? isoToJalali(value) : null;
|
||||
const today = todayJalali();
|
||||
const monthName = JALALI_MONTHS[view.jm - 1] ?? "";
|
||||
const dayCount = daysInJalaliMonth(view.jy, view.jm);
|
||||
const leading = jalaliMonthLeadingBlanks(view.jy, view.jm);
|
||||
const label = value ? formatJalaliDate(value) : null;
|
||||
|
||||
const panel =
|
||||
open && position
|
||||
? createPortal(
|
||||
<div
|
||||
ref={panelRef}
|
||||
id={panelId}
|
||||
role="dialog"
|
||||
aria-label="تقویم شمسی"
|
||||
style={{ top: position.top, left: position.left, width: position.width }}
|
||||
className="fixed z-50 rounded-lg border border-border bg-popover p-3 text-popover-foreground shadow-md"
|
||||
>
|
||||
<div className="mb-2 grid grid-cols-[1.75rem_1fr_1.75rem] items-center gap-1">
|
||||
<CalendarNavButton label="ماه قبل" onClick={() => shiftMonth(-1)}>
|
||||
<ChevronRight />
|
||||
</CalendarNavButton>
|
||||
<p className="text-center text-sm font-medium">
|
||||
{monthName} {toPersianDigits(view.jy)}
|
||||
</p>
|
||||
<CalendarNavButton label="ماه بعد" onClick={() => shiftMonth(1)}>
|
||||
<ChevronLeft />
|
||||
</CalendarNavButton>
|
||||
</div>
|
||||
<div className="mb-2 flex items-center justify-center gap-3 text-xs">
|
||||
<button type="button" className="text-accent hover:underline" onClick={() => shiftMonth(-12)}>
|
||||
سال قبل
|
||||
</button>
|
||||
<button type="button" className="text-accent hover:underline" onClick={() => shiftMonth(12)}>
|
||||
سال بعد
|
||||
</button>
|
||||
</div>
|
||||
<div className="grid grid-cols-7 gap-1 text-center text-xs text-muted-foreground">
|
||||
{JALALI_WEEKDAYS.map((weekday) => (
|
||||
<span key={weekday} className="py-1">
|
||||
{weekday}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<div className="grid grid-cols-7 gap-1">
|
||||
{Array.from({ length: leading }, (_, index) => (
|
||||
<span key={`blank-${index}`} />
|
||||
))}
|
||||
{Array.from({ length: dayCount }, (_, index) => {
|
||||
const day = index + 1;
|
||||
const isSelected =
|
||||
selected?.jy === view.jy && selected.jm === view.jm && selected.jd === day;
|
||||
const isToday = today.jy === view.jy && today.jm === view.jm && today.jd === day;
|
||||
return (
|
||||
<button
|
||||
key={day}
|
||||
type="button"
|
||||
onClick={() => selectDay(day)}
|
||||
className={cn(
|
||||
"flex aspect-square w-full items-center justify-center rounded-lg text-sm hover:bg-muted",
|
||||
isSelected && "bg-primary text-primary-foreground hover:bg-primary/80",
|
||||
isToday && !isSelected && "border border-primary text-primary",
|
||||
)}
|
||||
>
|
||||
{toPersianDigits(day)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="mt-2 flex items-center justify-between border-t border-border pt-2">
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-accent hover:underline"
|
||||
onClick={() => {
|
||||
const now = todayJalali();
|
||||
onChange(jalaliToIso(now.jy, now.jm, now.jd));
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
امروز
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs text-muted-foreground hover:text-foreground disabled:opacity-40"
|
||||
disabled={!value}
|
||||
onClick={() => {
|
||||
onChange("");
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
پاک کردن
|
||||
</button>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
)
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div ref={rootRef} className="relative">
|
||||
<button
|
||||
type="button"
|
||||
id={id}
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={open}
|
||||
aria-controls={panelId}
|
||||
onClick={() => (open ? setOpen(false) : openPanel())}
|
||||
className="flex h-8 w-full items-center justify-between rounded-lg border border-input bg-transparent px-2.5 text-start text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"
|
||||
>
|
||||
<span className={label ? undefined : "text-muted-foreground"}>{label ?? placeholder}</span>
|
||||
<CalendarDays className="size-4 text-muted-foreground" />
|
||||
</button>
|
||||
{panel}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function CalendarNavButton({
|
||||
label,
|
||||
onClick,
|
||||
children,
|
||||
}: {
|
||||
label: string;
|
||||
onClick: () => void;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={label}
|
||||
onClick={onClick}
|
||||
className="inline-flex size-7 items-center justify-center rounded-lg text-foreground hover:bg-muted [&_svg]:size-4"
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import Link from "next/link";
|
||||
import { CmsImage } from "@/components/atoms/CmsImage";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { newsExcerpt } from "@/lib/data/news";
|
||||
import { formatPersianDate } from "@/lib/format-date";
|
||||
import type { NewsItem } from "@/lib/types";
|
||||
|
||||
export function NewsCard({ item }: { item: NewsItem }) {
|
||||
return (
|
||||
<Link href={`/news/${item.id}`} className="group block h-full">
|
||||
<Card className="h-full pt-0 shadow-none transition-colors group-hover:bg-muted/40">
|
||||
<div className="relative aspect-[16/9] bg-muted">
|
||||
<CmsImage
|
||||
src={item.bannerImageUrl}
|
||||
alt=""
|
||||
fill
|
||||
className="object-cover"
|
||||
sizes="(min-width: 1024px) 33vw, (min-width: 640px) 50vw, 100vw"
|
||||
/>
|
||||
</div>
|
||||
<CardHeader>
|
||||
<p className="text-xs text-muted-foreground">{formatPersianDate(item.publishedAt)}</p>
|
||||
<CardTitle className="text-lg leading-8 group-hover:text-accent">{item.title}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="line-clamp-3 leading-7 text-muted-foreground">{newsExcerpt(item.body)}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ReactNode } from "react";
|
||||
import Image from "next/image";
|
||||
import { CmsImage } from "@/components/atoms/CmsImage";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Heading } from "@/components/atoms/Heading";
|
||||
import { MetamorphField } from "@/components/atoms/MetamorphField";
|
||||
@@ -31,11 +31,11 @@ export function PageHero({
|
||||
className={cn(
|
||||
"page-hero relative isolate flex items-center overflow-hidden bg-primary text-primary-foreground",
|
||||
size === "lg"
|
||||
? "min-h-[34rem] py-16 sm:min-h-[38rem] sm:py-20"
|
||||
: "py-16 sm:py-24",
|
||||
? "min-h-[32rem] py-16 sm:min-h-[36rem] sm:py-20"
|
||||
: "min-h-[22rem] py-14 sm:min-h-[26rem] sm:py-16",
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
<CmsImage
|
||||
src={imageUrl ?? "/brand/neural-learning-wave.webp"}
|
||||
alt=""
|
||||
fill
|
||||
@@ -54,36 +54,36 @@ export function PageHero({
|
||||
: "bg-gradient-to-l from-primary via-primary/90 to-primary/65",
|
||||
)}
|
||||
/>
|
||||
{showField ? (
|
||||
<MetamorphField
|
||||
tone="dark"
|
||||
density="normal"
|
||||
className="end-0 start-auto w-[min(75vw,42rem)] opacity-40"
|
||||
/>
|
||||
) : null}
|
||||
<div className="absolute end-0 top-0 h-px w-1/3 bg-gradient-to-l from-secondary to-transparent" />
|
||||
<Container className="relative z-[2] min-w-0">
|
||||
<div className="page-hero__content w-full min-w-0 max-w-4xl text-start">
|
||||
{eyebrow ? (
|
||||
<p className="mb-4 inline-flex rounded-full border border-primary-foreground/15 bg-primary-foreground/5 px-3 py-1.5 text-xs font-semibold text-secondary backdrop-blur-sm">
|
||||
{eyebrow}
|
||||
</p>
|
||||
) : null}
|
||||
<Heading as="h1" level={1} className="max-w-4xl text-primary-foreground">
|
||||
{title}
|
||||
</Heading>
|
||||
{intro ? (
|
||||
<div className="mt-5 max-w-2xl border-t border-secondary/50 pt-5 text-pretty text-primary-foreground/70">
|
||||
{typeof intro === "string" ? (
|
||||
<p className="text-base leading-7 sm:text-lg sm:leading-8">{intro}</p>
|
||||
) : (
|
||||
intro
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
{actions ? (
|
||||
<div className="mt-8 flex flex-wrap gap-3">{actions}</div>
|
||||
) : null}
|
||||
<div className="grid items-center lg:grid-cols-[minmax(0,42rem)_minmax(12rem,1fr)] lg:gap-12">
|
||||
<div className="page-hero__content w-full min-w-0 text-start">
|
||||
{eyebrow ? (
|
||||
<p className="mb-4 inline-flex rounded-full border border-primary-foreground/15 bg-primary-foreground/5 px-3 py-1.5 text-xs font-semibold text-secondary backdrop-blur-sm">
|
||||
{eyebrow}
|
||||
</p>
|
||||
) : null}
|
||||
<Heading as="h1" level={1} className="text-primary-foreground">
|
||||
{title}
|
||||
</Heading>
|
||||
{intro ? (
|
||||
<div className="mt-5 w-full border-t border-secondary/50 pt-5 text-justify text-pretty text-primary-foreground/70">
|
||||
{typeof intro === "string" ? (
|
||||
<p className="text-base leading-7 sm:text-lg sm:leading-8">{intro}</p>
|
||||
) : (
|
||||
intro
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
{actions ? (
|
||||
<div className="mt-8 flex flex-wrap gap-3">{actions}</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="relative hidden min-h-48 self-stretch lg:block" aria-hidden>
|
||||
{showField ? (
|
||||
<MetamorphField tone="dark" density="normal" className="opacity-60" />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</header>
|
||||
|
||||
@@ -5,7 +5,7 @@ type RichHtmlTone = "default" | "onPrimary";
|
||||
|
||||
const toneClass: Record<RichHtmlTone, string> = {
|
||||
default: cn(
|
||||
"max-w-none text-base leading-7 text-foreground/90",
|
||||
"max-w-none text-justify text-base leading-7 text-foreground/90",
|
||||
"[&_h2]:mt-8 [&_h2]:mb-3 [&_h2]:text-lg [&_h2]:font-bold [&_h2]:text-foreground",
|
||||
"[&_h3]:mt-6 [&_h3]:mb-2 [&_h3]:text-base [&_h3]:font-bold [&_h3]:text-foreground",
|
||||
"[&_h4]:mt-4 [&_h4]:mb-2 [&_h4]:text-sm [&_h4]:font-semibold",
|
||||
@@ -18,7 +18,7 @@ const toneClass: Record<RichHtmlTone, string> = {
|
||||
"[&_hr]:my-6 [&_hr]:border-border",
|
||||
),
|
||||
onPrimary: cn(
|
||||
"max-w-none text-base leading-7 text-primary-foreground/75 sm:text-lg sm:leading-8",
|
||||
"max-w-none text-justify text-base leading-7 text-primary-foreground/75 sm:text-lg sm:leading-8",
|
||||
"[&_h2]:mt-4 [&_h2]:mb-2 [&_h2]:text-lg [&_h2]:font-bold [&_h2]:text-primary-foreground",
|
||||
"[&_h3]:mt-3 [&_h3]:mb-2 [&_h3]:text-base [&_h3]:font-bold [&_h3]:text-primary-foreground",
|
||||
"[&_p]:mb-3 [&_p:last-child]:mb-0",
|
||||
|
||||
@@ -54,7 +54,8 @@ export function SectionHeader({
|
||||
{description ? (
|
||||
<p
|
||||
className={cn(
|
||||
"mt-3 max-w-2xl text-base leading-7 sm:mt-4 sm:text-lg sm:leading-8",
|
||||
"mt-3 w-full text-base leading-7 sm:mt-4 sm:text-lg sm:leading-8",
|
||||
align === "center" ? "text-center" : "text-justify",
|
||||
inverse ? "opacity-75" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { X } from "lucide-react";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { DotCta } from "@/components/atoms/DotCta";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { htmlToPlain } from "@/lib/html-text";
|
||||
import type { Program } from "@/lib/types";
|
||||
|
||||
export function AcademicsOverlay({
|
||||
@@ -71,7 +72,7 @@ export function AcademicsOverlay({
|
||||
{program.title}
|
||||
</span>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
{program.blurb}
|
||||
{htmlToPlain(program.blurb)}
|
||||
</p>
|
||||
</Link>
|
||||
</li>
|
||||
@@ -93,7 +94,7 @@ export function AcademicsOverlay({
|
||||
{program.title}
|
||||
</span>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
{program.blurb}
|
||||
{htmlToPlain(program.blurb)}
|
||||
</p>
|
||||
</Link>
|
||||
</li>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { X } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Container } from "@/components/atoms/Container";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { htmlToPlain } from "@/lib/html-text";
|
||||
import type { CampaignBanner } from "@/lib/types";
|
||||
|
||||
const STORAGE_PREFIX = "aut-banner:v1:";
|
||||
@@ -50,7 +51,7 @@ export function CampaignBanners({ banners }: { banners: CampaignBanner[] }) {
|
||||
<div className="bg-primary text-primary-foreground">
|
||||
<Container className="flex min-w-0 items-center justify-between gap-3 py-3 sm:gap-4">
|
||||
<p className="min-w-0 flex-1 text-sm leading-relaxed break-words">
|
||||
<span className="text-primary-foreground/90">{banner.text}</span>{" "}
|
||||
<span className="text-primary-foreground/90">{htmlToPlain(banner.text)}</span>{" "}
|
||||
<Link
|
||||
href={banner.href}
|
||||
className="font-bold text-secondary underline-offset-4 hover:underline"
|
||||
|
||||
@@ -7,22 +7,21 @@ 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 { htmlToPlain } from "@/lib/html-text";
|
||||
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 =
|
||||
@@ -114,11 +113,25 @@ export function CategoryCourseExplorer({
|
||||
const matchesQuery =
|
||||
!deferredQuery ||
|
||||
course.title.includes(deferredQuery) ||
|
||||
course.summary.includes(deferredQuery);
|
||||
htmlToPlain(course.summary).includes(deferredQuery);
|
||||
return matchesCategory && matchesTag && matchesQuery;
|
||||
});
|
||||
}, [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 +350,78 @@ export function CategoryCourseExplorer({
|
||||
دوره ای با این فیلتر ها یافت نشد.
|
||||
</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="group relative gap-0 overflow-hidden bg-primary-foreground/5 py-0 text-primary-foreground ring-primary-foreground/10 transition-colors hover:ring-primary-foreground/30"
|
||||
>
|
||||
{/* 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}
|
||||
tabIndex={-1}
|
||||
/>
|
||||
<CourseCardBanner
|
||||
title={course.title}
|
||||
bannerUrl={course.posterImageUrl}
|
||||
/>
|
||||
<CardHeader className="pointer-events-none relative z-[1] gap-1 px-4 pt-4">
|
||||
<CardTitle className="text-base text-primary-foreground">
|
||||
{course.title}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="pointer-events-none relative z-[1] space-y-3 px-4 pb-4">
|
||||
<CardDescription className="line-clamp-3 text-primary-foreground/70">
|
||||
{course.summary}
|
||||
</CardDescription>
|
||||
{(course.categories.length > 0 || course.tags.length > 0) && (
|
||||
<div className="pointer-events-auto flex flex-wrap gap-1.5">
|
||||
{course.categories.map((c) => {
|
||||
const href = categoryHref(c.slug);
|
||||
const active = categorySlug === c.slug;
|
||||
return (
|
||||
<Link
|
||||
key={`cat:${c.id}`}
|
||||
href={href}
|
||||
className="relative z-[2]"
|
||||
aria-current={active ? "true" : undefined}
|
||||
>
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"cursor-pointer border-primary-foreground/25 text-[11px] font-semibold text-primary-foreground/90 hover:bg-primary-foreground/15",
|
||||
active && "border-secondary bg-secondary/25 text-secondary",
|
||||
)}
|
||||
>
|
||||
{c.label}
|
||||
</Badge>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
{course.tags.map((t) => {
|
||||
const href = tagHref(t.slug);
|
||||
const active = tagSlug === t.slug;
|
||||
return (
|
||||
<Link
|
||||
key={`tag:${t.id}`}
|
||||
href={href}
|
||||
className="relative z-[2]"
|
||||
aria-current={active ? "true" : undefined}
|
||||
>
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"cursor-pointer border-primary-foreground/25 text-[10px] text-primary-foreground/75 hover:bg-primary-foreground/15",
|
||||
active && "border-secondary bg-secondary/25 text-secondary",
|
||||
)}
|
||||
>
|
||||
{t.label}
|
||||
</Badge>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-primary-foreground/55">
|
||||
<span>
|
||||
{course.durationHours
|
||||
? `${course.durationHours} ساعت · ${formatLabel(course.format)}`
|
||||
: formatLabel(course.format)}
|
||||
</span>
|
||||
{priceLabel ? (
|
||||
<span className="font-semibold text-primary-foreground/90">
|
||||
{priceLabel}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<span className="inline-flex text-sm font-semibold text-primary-foreground underline-offset-4 group-hover:underline">
|
||||
جزئیات و ثبت نام
|
||||
</span>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
<div className="space-y-10">
|
||||
{currentCourses.length > 0 ? (
|
||||
<CourseCatalogGrid
|
||||
courses={currentCourses}
|
||||
variant="current"
|
||||
isStale={isStale}
|
||||
categorySlug={categorySlug}
|
||||
tagSlug={tagSlug}
|
||||
categoryHref={categoryHref}
|
||||
tagHref={tagHref}
|
||||
/>
|
||||
) : null}
|
||||
{currentCourses.length > 0 && archiveCourses.length > 0 ? (
|
||||
<Separator className="bg-primary-foreground/15" />
|
||||
) : null}
|
||||
{archiveCourses.length > 0 ? (
|
||||
<div className="space-y-5">
|
||||
<Heading level={4} as="h2">
|
||||
{archiveLabel}
|
||||
</Heading>
|
||||
<CourseCatalogGrid
|
||||
courses={archiveCourses}
|
||||
variant="archive"
|
||||
isStale={isStale}
|
||||
categorySlug={categorySlug}
|
||||
tagSlug={tagSlug}
|
||||
categoryHref={categoryHref}
|
||||
tagHref={tagHref}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<div
|
||||
className={cn(
|
||||
"grid gap-5 transition-opacity sm:grid-cols-2 lg:grid-cols-3",
|
||||
isStale && "opacity-70",
|
||||
)}
|
||||
>
|
||||
{courses.map((course) => (
|
||||
<CourseCatalogCard
|
||||
key={course.id}
|
||||
course={course}
|
||||
variant={variant}
|
||||
categorySlug={categorySlug}
|
||||
tagSlug={tagSlug}
|
||||
categoryHref={categoryHref}
|
||||
tagHref={tagHref}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user