Remove unused redirects from the Next.js configuration and update package dependencies to include new Tiptap extensions for enhanced text editing capabilities. Clean up the database seeding script by removing commented-out code and ensuring proper deletion of obsolete entries. Update various pages to handle not found scenarios gracefully, improving user experience across the application.
This commit is contained in:
1 parent
4b84409ed7
commit
2858b9c746
106 files changed
+2516
-1004
No files matched your search
@@ -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;
|
||||||
+11
-33
@@ -8,17 +8,11 @@ import { fileURLToPath } from "node:url";
|
|||||||
import pg from "pg";
|
import pg from "pg";
|
||||||
|
|
||||||
import { courses } from "../src/lib/mock/courses.ts";
|
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 {
|
import {
|
||||||
alumniStories,
|
|
||||||
campaignBanners,
|
campaignBanners,
|
||||||
faculty,
|
faculty,
|
||||||
intersections,
|
|
||||||
legalPages,
|
legalPages,
|
||||||
stats,
|
stats,
|
||||||
testimonials,
|
|
||||||
} from "../src/lib/mock/site.ts";
|
} from "../src/lib/mock/site.ts";
|
||||||
import {
|
import {
|
||||||
SEED_COURSE_CATEGORIES,
|
SEED_COURSE_CATEGORIES,
|
||||||
@@ -26,17 +20,11 @@ import {
|
|||||||
} from "../src/lib/taxonomy.ts";
|
} from "../src/lib/taxonomy.ts";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
alumniStoryToRow,
|
|
||||||
articleToRow,
|
|
||||||
campaignBannerToRow,
|
campaignBannerToRow,
|
||||||
courseToRow,
|
courseToRow,
|
||||||
eventToRow,
|
|
||||||
facultyMemberToRow,
|
facultyMemberToRow,
|
||||||
intersectionTopicToRow,
|
|
||||||
legalPageToRow,
|
legalPageToRow,
|
||||||
programToRow,
|
|
||||||
siteStatToRow,
|
siteStatToRow,
|
||||||
testimonialToRow,
|
|
||||||
} from "../src/lib/db/mappers.ts";
|
} from "../src/lib/db/mappers.ts";
|
||||||
|
|
||||||
if (!process.env.DATABASE_URL) {
|
if (!process.env.DATABASE_URL) {
|
||||||
@@ -156,29 +144,22 @@ async function main() {
|
|||||||
}
|
}
|
||||||
results.push(["course_category_links", catLinks]);
|
results.push(["course_category_links", catLinks]);
|
||||||
results.push(["course_tag_links", tagLinks]);
|
results.push(["course_tag_links", tagLinks]);
|
||||||
await upsert("programs", programs.map(programToRow), [
|
for (const table of [
|
||||||
"id", "slug", "title", "blurb", "group_key", "href", "tagline", "audience",
|
"programs",
|
||||||
"duration_label", "format_label", "highlights", "body", "published",
|
"events",
|
||||||
]);
|
"articles",
|
||||||
await upsert("events", events.map(eventToRow), [
|
"intersection_topics",
|
||||||
"id", "title", "start_date", "end_date", "location", "href", "summary", "published",
|
"alumni_stories",
|
||||||
]);
|
"testimonials",
|
||||||
await upsert("articles", articles.map(articleToRow), [
|
]) {
|
||||||
"id", "title", "category", "excerpt", "image_url", "href", "featured",
|
const deleted = await client.query(`DELETE FROM ${table}`);
|
||||||
"body", "published_at", "author", "published",
|
results.push([`${table}_cleared`, deleted.rowCount]);
|
||||||
]);
|
}
|
||||||
await client.query(`DELETE FROM intersection_topics`);
|
|
||||||
await upsert("intersection_topics", intersections.map(intersectionTopicToRow), [
|
|
||||||
"id", "slug", "title", "description", "href", "image_url", "body", "highlights", "published",
|
|
||||||
]);
|
|
||||||
await upsert("faculty_members", faculty.map(facultyMemberToRow), [
|
await upsert("faculty_members", faculty.map(facultyMemberToRow), [
|
||||||
"id", "name", "title", "focus", "bio", "image_url",
|
"id", "name", "title", "focus", "bio", "image_url",
|
||||||
"email", "office", "phone", "department", "linkedin_url", "scholar_url",
|
"email", "office", "phone", "department", "linkedin_url", "scholar_url",
|
||||||
"published",
|
"published",
|
||||||
]);
|
]);
|
||||||
await upsert("alumni_stories", alumniStories.map(alumniStoryToRow), [
|
|
||||||
"id", "title", "excerpt", "name", "program", "image_url", "href", "published",
|
|
||||||
]);
|
|
||||||
await upsert("campaign_banners", campaignBanners.map(campaignBannerToRow), [
|
await upsert("campaign_banners", campaignBanners.map(campaignBannerToRow), [
|
||||||
"id", "version", "text", "href", "cta", "published",
|
"id", "version", "text", "href", "cta", "published",
|
||||||
]);
|
]);
|
||||||
@@ -188,9 +169,6 @@ async function main() {
|
|||||||
await upsert("site_stats", stats.map(siteStatToRow), [
|
await upsert("site_stats", stats.map(siteStatToRow), [
|
||||||
"id", "value", "label", "published",
|
"id", "value", "label", "published",
|
||||||
]);
|
]);
|
||||||
await upsert("testimonials", testimonials.map(testimonialToRow), [
|
|
||||||
"id", "quote", "name", "role", "course_title", "published",
|
|
||||||
]);
|
|
||||||
|
|
||||||
const counts = await client.query(`
|
const counts = await client.query(`
|
||||||
SELECT (SELECT count(*) FROM courses) AS courses,
|
SELECT (SELECT count(*) FROM courses) AS courses,
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
"insightsIntro": "نکات کاربردی مدیریت و فناوری برای کار و سازمان.",
|
"insightsIntro": "نکات کاربردی مدیریت و فناوری برای کار و سازمان.",
|
||||||
"eventsTitle": "رویداد ها",
|
"eventsTitle": "رویداد ها",
|
||||||
"eventsIntro": "وبینار ها، بازدیدها و نشست های معرفی برنامه.",
|
"eventsIntro": "وبینار ها، بازدیدها و نشست های معرفی برنامه.",
|
||||||
|
"newsTitle": "اخبار",
|
||||||
|
"newsIntro": "اطلاعیه ها و خبرهای مرکز آموزش های آزاد.",
|
||||||
|
"newsEmpty": "هنوز خبری منتشر نشده است.",
|
||||||
"aboutTitle": "درباره مرکز آموزش های آزاد",
|
"aboutTitle": "درباره مرکز آموزش های آزاد",
|
||||||
"valuesTitle": "ارزش های ما",
|
"valuesTitle": "ارزش های ما",
|
||||||
"alumniTitle": "دانش آموختگان",
|
"alumniTitle": "دانش آموختگان",
|
||||||
@@ -60,6 +63,7 @@
|
|||||||
"courseAboutTitle": "درباره این دوره",
|
"courseAboutTitle": "درباره این دوره",
|
||||||
"courseDetailsTitle": "جزئیات برگزاری",
|
"courseDetailsTitle": "جزئیات برگزاری",
|
||||||
"courseDuration": "مدت",
|
"courseDuration": "مدت",
|
||||||
|
"courseDate": "تاریخ برگزاری",
|
||||||
"courseFormat": "قالب",
|
"courseFormat": "قالب",
|
||||||
"courseCategory": "دسته بندی",
|
"courseCategory": "دسته بندی",
|
||||||
"coursePrice": "شهریه",
|
"coursePrice": "شهریه",
|
||||||
|
|||||||
@@ -24,11 +24,6 @@ const nextConfig: NextConfig = {
|
|||||||
},
|
},
|
||||||
async redirects() {
|
async redirects() {
|
||||||
return [
|
return [
|
||||||
{
|
|
||||||
source: "/faculty",
|
|
||||||
destination: "https://mst.aut.ac.ir/content/31094/شبکه-اساتید",
|
|
||||||
permanent: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
source: "/images/faculty/placeholder.png",
|
source: "/images/faculty/placeholder.png",
|
||||||
destination: "/images/faculty/placeholder.webp",
|
destination: "/images/faculty/placeholder.webp",
|
||||||
|
|||||||
Generated
+651
-3
@@ -9,10 +9,18 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@base-ui/react": "^1.8.0",
|
"@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",
|
"class-variance-authority": "^0.7.1",
|
||||||
"cn": "^0.3.2",
|
"cn": "^0.3.2",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
"isomorphic-dompurify": "^4.6.0",
|
"isomorphic-dompurify": "^4.6.0",
|
||||||
|
"jalaali-js": "^2.0.1",
|
||||||
"lucide-react": "^1.47.0",
|
"lucide-react": "^1.47.0",
|
||||||
"next": "16.3.5",
|
"next": "16.3.5",
|
||||||
"next-intl": "^4.14.6",
|
"next-intl": "^4.14.6",
|
||||||
@@ -3123,6 +3131,462 @@
|
|||||||
"tailwindcss": "4.3.3"
|
"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": {
|
"node_modules/@ts-morph/common": {
|
||||||
"version": "0.27.0",
|
"version": "0.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.27.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.27.0.tgz",
|
||||||
@@ -3266,7 +3730,6 @@
|
|||||||
"version": "19.3.0",
|
"version": "19.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz",
|
||||||
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
|
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
|
||||||
"devOptional": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.2.2"
|
"csstype": "^3.2.2"
|
||||||
@@ -3276,7 +3739,6 @@
|
|||||||
"version": "19.3.0",
|
"version": "19.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz",
|
||||||
"integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==",
|
"integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@types/react": "^19.3.0"
|
"@types/react": "^19.3.0"
|
||||||
@@ -3289,6 +3751,12 @@
|
|||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/@types/validate-npm-package-name": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/validate-npm-package-name/-/validate-npm-package-name-4.0.2.tgz",
|
"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",
|
"version": "3.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||||
"devOptional": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/damerau-levenshtein": {
|
"node_modules/damerau-levenshtein": {
|
||||||
@@ -6082,6 +6549,15 @@
|
|||||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/fast-glob": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz",
|
||||||
@@ -7443,6 +7919,15 @@
|
|||||||
"node": ">= 0.4"
|
"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": {
|
"node_modules/jiti": {
|
||||||
"version": "2.7.0",
|
"version": "2.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",
|
||||||
@@ -7964,6 +8449,12 @@
|
|||||||
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
|
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/locate-path": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
"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"
|
"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": {
|
"node_modules/own-keys": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.2.tgz",
|
||||||
@@ -9253,6 +9750,145 @@
|
|||||||
"react-is": "^16.13.1"
|
"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": {
|
"node_modules/proxy-addr": {
|
||||||
"version": "2.0.8",
|
"version": "2.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
|
||||||
@@ -9530,6 +10166,12 @@
|
|||||||
"node": ">=0.10.0"
|
"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": {
|
"node_modules/router": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
||||||
@@ -11024,6 +11666,12 @@
|
|||||||
"integrity": "sha512-fbjNc0CMjazZpIegWzz9OHGzI1APFboT+x7ZecXlUCtDe/nkyx7gtCTZnWS/+eeXG7fbfXymCPKJI8EsnM3iqw==",
|
"integrity": "sha512-fbjNc0CMjazZpIegWzz9OHGzI1APFboT+x7ZecXlUCtDe/nkyx7gtCTZnWS/+eeXG7fbfXymCPKJI8EsnM3iqw==",
|
||||||
"license": "OFL"
|
"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": {
|
"node_modules/w3c-xmlserializer": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz",
|
||||||
|
|||||||
@@ -14,10 +14,18 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@base-ui/react": "^1.8.0",
|
"@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",
|
"class-variance-authority": "^0.7.1",
|
||||||
"cn": "^0.3.2",
|
"cn": "^0.3.2",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
"isomorphic-dompurify": "^4.6.0",
|
"isomorphic-dompurify": "^4.6.0",
|
||||||
|
"jalaali-js": "^2.0.1",
|
||||||
"lucide-react": "^1.47.0",
|
"lucide-react": "^1.47.0",
|
||||||
"next": "16.3.5",
|
"next": "16.3.5",
|
||||||
"next-intl": "^4.14.6",
|
"next-intl": "^4.14.6",
|
||||||
|
|||||||
+8
-3
@@ -28,10 +28,15 @@ async function readJson(res) {
|
|||||||
async function main() {
|
async function main() {
|
||||||
console.log(`Smoke: ${BASE}`);
|
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);
|
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) {
|
if (!ADMIN_EMAIL || !ADMIN_PASSWORD) {
|
||||||
|
|||||||
@@ -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">
|
<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">
|
<div className="min-w-0 space-y-5">
|
||||||
{page.body.map((paragraph) => (
|
{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}
|
{paragraph}
|
||||||
</p>
|
</p>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,69 +1,5 @@
|
|||||||
import type { Metadata } from "next";
|
import { notFound } from "next/navigation";
|
||||||
import { getTranslations } from "next-intl/server";
|
|
||||||
import { CmsImage } from "@/components/atoms/CmsImage";
|
|
||||||
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";
|
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export default function AlumniPage() {
|
||||||
const t = await getTranslations("pages");
|
notFound();
|
||||||
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">
|
|
||||||
<CmsImage
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,90 +1,5 @@
|
|||||||
import type { Metadata } from "next";
|
|
||||||
import { notFound } from "next/navigation";
|
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 }> };
|
export default function EventDetailPage() {
|
||||||
|
notFound();
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,37 +1,5 @@
|
|||||||
import type { Metadata } from "next";
|
import { notFound } from "next/navigation";
|
||||||
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";
|
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export default function EventsPage() {
|
||||||
const t = await getTranslations("pages");
|
notFound();
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -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() {
|
export default function FacultyPage() {
|
||||||
redirect("/");
|
notFound();
|
||||||
}
|
}
|
||||||
@@ -1,78 +1,5 @@
|
|||||||
import type { Metadata } from "next";
|
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { CmsImage } from "@/components/atoms/CmsImage";
|
|
||||||
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 default function InsightArticlePage() {
|
||||||
|
notFound();
|
||||||
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">
|
|
||||||
<CmsImage
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,49 +1,5 @@
|
|||||||
import type { Metadata } from "next";
|
import { notFound } from "next/navigation";
|
||||||
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";
|
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export default function InsightsPage() {
|
||||||
const t = await getTranslations("pages");
|
notFound();
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,12 @@ import { SiteHeader } from "@/components/organisms/SiteHeader";
|
|||||||
import { buildHomeNavWithCourseTags } from "@/lib/course-nav";
|
import { buildHomeNavWithCourseTags } from "@/lib/course-nav";
|
||||||
import { getCourses } from "@/lib/data/courses";
|
import { getCourses } from "@/lib/data/courses";
|
||||||
import { listPublishedCourseTags } from "@/lib/data/taxonomy";
|
import { listPublishedCourseTags } from "@/lib/data/taxonomy";
|
||||||
import { getPrograms } from "@/lib/data/programs";
|
|
||||||
import { getCampaignBanners } from "@/lib/data/site";
|
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
|
// Public CMS pages must read Postgres at request time — static bake at Docker
|
||||||
// build often has no DATABASE_URL and ships empty lists.
|
// build often has no DATABASE_URL and ships empty lists.
|
||||||
@@ -21,13 +24,11 @@ export default async function MainLayout({
|
|||||||
const t = await getTranslations();
|
const t = await getTranslations();
|
||||||
const year = new Date().getFullYear();
|
const year = new Date().getFullYear();
|
||||||
let courses: Awaited<ReturnType<typeof getCourses>> = [];
|
let courses: Awaited<ReturnType<typeof getCourses>> = [];
|
||||||
let programs: Awaited<ReturnType<typeof getPrograms>> = [];
|
|
||||||
let banners: Awaited<ReturnType<typeof getCampaignBanners>> = [];
|
let banners: Awaited<ReturnType<typeof getCampaignBanners>> = [];
|
||||||
let navTags: Awaited<ReturnType<typeof listPublishedCourseTags>> = [];
|
let navTags: Awaited<ReturnType<typeof listPublishedCourseTags>> = [];
|
||||||
try {
|
try {
|
||||||
[courses, programs, banners, navTags] = await Promise.all([
|
[courses, banners, navTags] = await Promise.all([
|
||||||
getCourses(),
|
getCourses(),
|
||||||
getPrograms(),
|
|
||||||
getCampaignBanners(),
|
getCampaignBanners(),
|
||||||
listPublishedCourseTags({ navOnly: true }),
|
listPublishedCourseTags({ navOnly: true }),
|
||||||
]);
|
]);
|
||||||
@@ -47,7 +48,6 @@ export default async function MainLayout({
|
|||||||
brandSubtitle={t("nav.brandSubtitle")}
|
brandSubtitle={t("nav.brandSubtitle")}
|
||||||
variant="home"
|
variant="home"
|
||||||
courses={courses}
|
courses={courses}
|
||||||
programs={programs}
|
|
||||||
/>
|
/>
|
||||||
<CampaignBanners banners={banners} />
|
<CampaignBanners banners={banners} />
|
||||||
<div className="min-w-0 flex-1 overflow-x-clip">{children}</div>
|
<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")}
|
linksTitle={t("footer.links")}
|
||||||
links={[
|
links={[
|
||||||
{ label: t("footer.facultySite"), href: facultySiteUrl },
|
{ label: t("footer.facultySite"), href: facultySiteUrl },
|
||||||
|
{ label: t("footer.facultyNetwork"), href: facultyNetworkUrl },
|
||||||
{ label: t("footer.press"), href: "/press" },
|
{ label: t("footer.press"), href: "/press" },
|
||||||
{ label: t("footer.careers"), href: "/careers" },
|
{ 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,
|
HomeApproach,
|
||||||
HomeClosing,
|
HomeClosing,
|
||||||
HomeCourseSearch,
|
HomeCourseSearch,
|
||||||
HomeEventsTeaser,
|
|
||||||
HomeHero,
|
HomeHero,
|
||||||
HomeIdeas,
|
HomeIdeas,
|
||||||
HomeTeams,
|
HomeTeams,
|
||||||
type HomeLabels,
|
type HomeLabels,
|
||||||
} from "@/components/templates/HomeTemplate";
|
} from "@/components/templates/HomeTemplate";
|
||||||
import { getFeaturedArticle } from "@/lib/data/articles";
|
|
||||||
import { getLatestCourses } from "@/lib/data/courses";
|
import { getLatestCourses } from "@/lib/data/courses";
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
@@ -46,11 +44,8 @@ async function orFallback<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function HeroSection() {
|
async function HeroSection() {
|
||||||
const [featured, labels] = await Promise.all([
|
const labels = await getLabels();
|
||||||
orFallback("featured article", getFeaturedArticle, null),
|
return <HomeHero featured={null} eyebrow={labels.ideasEyebrow} />;
|
||||||
getLabels(),
|
|
||||||
]);
|
|
||||||
return <HomeHero featured={featured} eyebrow={labels.ideasEyebrow} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function CourseSearchSection() {
|
async function CourseSearchSection() {
|
||||||
@@ -76,7 +71,6 @@ export default function HomePage() {
|
|||||||
<HomeIdeas />
|
<HomeIdeas />
|
||||||
<CourseSearchSection />
|
<CourseSearchSection />
|
||||||
<HomeApproach />
|
<HomeApproach />
|
||||||
<HomeEventsTeaser />
|
|
||||||
<HomeTeams />
|
<HomeTeams />
|
||||||
<HomeClosing />
|
<HomeClosing />
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,115 +1,5 @@
|
|||||||
import type { Metadata } from "next";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { notFound } from "next/navigation";
|
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 default function ProgramDetailPage() {
|
||||||
|
notFound();
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,93 +1,5 @@
|
|||||||
import type { Metadata } from "next";
|
import { notFound } from "next/navigation";
|
||||||
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";
|
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export default function ProgramsPage() {
|
||||||
const t = await getTranslations("pages");
|
notFound();
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import { notFound } from "next/navigation";
|
|||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { CourseDetailTemplate } from "@/components/templates/CourseDetailTemplate";
|
import { CourseDetailTemplate } from "@/components/templates/CourseDetailTemplate";
|
||||||
import { getCourseById } from "@/lib/data/courses";
|
import { getCourseById } from "@/lib/data/courses";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import { pageMetadata, truncateMetaDescription } from "@/lib/seo/metadata";
|
import { pageMetadata, truncateMetaDescription } from "@/lib/seo/metadata";
|
||||||
|
|
||||||
type Props = { params: Promise<{ slug: string }> };
|
type Props = { params: Promise<{ slug: string }> };
|
||||||
@@ -15,7 +16,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|||||||
return pageMetadata({
|
return pageMetadata({
|
||||||
title: course.title,
|
title: course.title,
|
||||||
description: truncateMetaDescription(
|
description: truncateMetaDescription(
|
||||||
course.seoDescription || course.summary,
|
course.seoDescription || htmlToPlain(course.summary),
|
||||||
),
|
),
|
||||||
path: `/register/${pathSlug}`,
|
path: `/register/${pathSlug}`,
|
||||||
...(course.posterImageUrl ? { image: course.posterImageUrl } : {}),
|
...(course.posterImageUrl ? { image: course.posterImageUrl } : {}),
|
||||||
@@ -45,6 +46,7 @@ export default async function CourseRegisterPage({ params }: Props) {
|
|||||||
detailsTitle: t("courseDetailsTitle"),
|
detailsTitle: t("courseDetailsTitle"),
|
||||||
aboutTitle: t("courseAboutTitle"),
|
aboutTitle: t("courseAboutTitle"),
|
||||||
duration: t("courseDuration"),
|
duration: t("courseDuration"),
|
||||||
|
date: t("courseDate"),
|
||||||
format: t("courseFormat"),
|
format: t("courseFormat"),
|
||||||
category: t("courseCategory"),
|
category: t("courseCategory"),
|
||||||
price: t("coursePrice"),
|
price: t("coursePrice"),
|
||||||
|
|||||||
@@ -1,69 +1,5 @@
|
|||||||
import type { Metadata } from "next";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { notFound } from "next/navigation";
|
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 default function TopicPage() {
|
||||||
|
notFound();
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ export default async function ValuesPage() {
|
|||||||
<Heading as="h2" level={4} className="mt-2">
|
<Heading as="h2" level={4} className="mt-2">
|
||||||
{item.title}
|
{item.title}
|
||||||
</Heading>
|
</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}
|
{item.text}
|
||||||
</p>
|
</p>
|
||||||
</SurfaceCard>
|
</SurfaceCard>
|
||||||
@@ -69,7 +69,7 @@ export default async function ValuesPage() {
|
|||||||
<Heading as="h3" level={4} className="group-hover:text-accent">
|
<Heading as="h3" level={4} className="group-hover:text-accent">
|
||||||
{example.title}
|
{example.title}
|
||||||
</Heading>
|
</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}
|
{example.text}
|
||||||
</p>
|
</p>
|
||||||
<span className="mt-4 inline-flex items-center gap-1.5 text-sm font-semibold text-accent">
|
<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 { query } from "@/lib/db";
|
||||||
import { rowToAlumniStory, type AlumniStoryRow } from "@/lib/db/mappers";
|
import { rowToAlumniStory, type AlumniStoryRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -40,7 +40,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = alumniPatchSchema.safeParse(body);
|
const parsed = alumniPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToAlumniStory, type AlumniStoryRow } from "@/lib/db/mappers";
|
import { rowToAlumniStory, type AlumniStoryRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
||||||
@@ -24,7 +24,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = alumniCreateSchema.safeParse(body);
|
const parsed = alumniCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToArticle, type ArticleRow } from "@/lib/db/mappers";
|
import { rowToArticle, type ArticleRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
@@ -43,7 +43,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = articlePatchSchema.safeParse(body);
|
const parsed = articlePatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { randomUUID } from "node:crypto";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToArticle, type ArticleRow } from "@/lib/db/mappers";
|
import { rowToArticle, type ArticleRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
@@ -26,7 +26,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = articleCreateSchema.safeParse(body);
|
const parsed = articleCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToCampaignBanner, type CampaignBannerRow } from "@/lib/db/mappers";
|
import { rowToCampaignBanner, type CampaignBannerRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -34,7 +34,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = bannerPatchSchema.safeParse(body);
|
const parsed = bannerPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToCampaignBanner, type CampaignBannerRow } from "@/lib/db/mappers";
|
import { rowToCampaignBanner, type CampaignBannerRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = bannerCreateSchema.safeParse(body);
|
const parsed = bannerCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -33,7 +33,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = courseCategoryPatchSchema.safeParse(body);
|
const parsed = courseCategoryPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
@@ -20,7 +20,7 @@ export async function POST(request: Request) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = courseCategoryCreateSchema.safeParse(body);
|
const parsed = courseCategoryCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -34,7 +34,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = courseTagPatchSchema.safeParse(body);
|
const parsed = courseTagPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
@@ -20,7 +20,7 @@ export async function POST(request: Request) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = courseTagCreateSchema.safeParse(body);
|
const parsed = courseTagCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
@@ -38,6 +38,7 @@ const COURSE_COLUMNS: Record<string, string> = {
|
|||||||
title: "title",
|
title: "title",
|
||||||
summary: "summary",
|
summary: "summary",
|
||||||
durationHours: "duration_hours",
|
durationHours: "duration_hours",
|
||||||
|
startDate: "start_date",
|
||||||
format: "format",
|
format: "format",
|
||||||
price: "price",
|
price: "price",
|
||||||
registrationUrl: "registration_url",
|
registrationUrl: "registration_url",
|
||||||
@@ -68,7 +69,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = coursePatchSchema.safeParse(body);
|
const parsed = coursePatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
@@ -53,7 +53,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = courseCreateSchema.safeParse(body);
|
const parsed = courseCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
@@ -63,16 +63,17 @@ export async function POST(request: NextRequest) {
|
|||||||
try {
|
try {
|
||||||
await query(
|
await query(
|
||||||
`INSERT INTO courses
|
`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,
|
registration_url, poster_image_url, brochure_image_url, image_url,
|
||||||
lead_html, body_html, seo_description, published, featured, sort_order)
|
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)`,
|
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18)`,
|
||||||
[
|
[
|
||||||
id,
|
id,
|
||||||
d.slug,
|
d.slug,
|
||||||
d.title,
|
d.title,
|
||||||
d.summary,
|
d.summary,
|
||||||
d.durationHours ?? null,
|
d.durationHours ?? null,
|
||||||
|
d.startDate ?? null,
|
||||||
d.format,
|
d.format,
|
||||||
d.price ?? null,
|
d.price ?? null,
|
||||||
d.registrationUrl,
|
d.registrationUrl,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToEvent, type EventRow } from "@/lib/db/mappers";
|
import { rowToEvent, type EventRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -40,7 +40,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = eventPatchSchema.safeParse(body);
|
const parsed = eventPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToEvent, type EventRow } from "@/lib/db/mappers";
|
import { rowToEvent, type EventRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
||||||
@@ -24,7 +24,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = eventCreateSchema.safeParse(body);
|
const parsed = eventCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToFacultyMember, type FacultyMemberRow } from "@/lib/db/mappers";
|
import { rowToFacultyMember, type FacultyMemberRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -42,7 +42,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = facultyPatchSchema.safeParse(body);
|
const parsed = facultyPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToFacultyMember, type FacultyMemberRow } from "@/lib/db/mappers";
|
import { rowToFacultyMember, type FacultyMemberRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = facultyCreateSchema.safeParse(body);
|
const parsed = facultyCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToLegalPage, type LegalPageRow } from "@/lib/db/mappers";
|
import { rowToLegalPage, type LegalPageRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -32,7 +32,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = legalPatchSchema.safeParse(body);
|
const parsed = legalPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToLegalPage, type LegalPageRow } from "@/lib/db/mappers";
|
import { rowToLegalPage, type LegalPageRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
@@ -21,7 +21,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = legalCreateSchema.safeParse(body);
|
const parsed = legalCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
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 { query } from "@/lib/db";
|
||||||
import { rowToProgram, type ProgramRow } from "@/lib/db/mappers";
|
import { rowToProgram, type ProgramRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
|
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
@@ -30,6 +31,9 @@ export async function PATCH(
|
|||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
{ params }: { params: Promise<{ id: string }> },
|
{ params }: { params: Promise<{ id: string }> },
|
||||||
) {
|
) {
|
||||||
|
const disabled = disabledAdminEntityResponse("programs");
|
||||||
|
if (disabled) return disabled;
|
||||||
|
|
||||||
const session = await requireAdmin();
|
const session = await requireAdmin();
|
||||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||||
|
|
||||||
@@ -42,7 +46,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = programPatchSchema.safeParse(body);
|
const parsed = programPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
@@ -74,6 +78,9 @@ export async function DELETE(
|
|||||||
_request: NextRequest,
|
_request: NextRequest,
|
||||||
{ params }: { params: Promise<{ id: string }> },
|
{ params }: { params: Promise<{ id: string }> },
|
||||||
) {
|
) {
|
||||||
|
const disabled = disabledAdminEntityResponse("programs");
|
||||||
|
if (disabled) return disabled;
|
||||||
|
|
||||||
const session = await requireAdmin();
|
const session = await requireAdmin();
|
||||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,19 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToProgram, type ProgramRow } from "@/lib/db/mappers";
|
import { rowToProgram, type ProgramRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
|
import { disabledAdminEntityResponse } from "@/lib/admin/disabled-entities";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
// POST /api/admin/programs — create program (admin only)
|
// POST /api/admin/programs — create program (admin only)
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
|
const disabled = disabledAdminEntityResponse("programs");
|
||||||
|
if (disabled) return disabled;
|
||||||
|
|
||||||
const session = await requireAdmin();
|
const session = await requireAdmin();
|
||||||
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
|
||||||
|
|
||||||
@@ -21,7 +25,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = programCreateSchema.safeParse(body);
|
const parsed = programCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { parseJsonBody } from "@/lib/api/crud";
|
import { parseJsonBody } from "@/lib/api/crud";
|
||||||
import type { RegistrationLeadRow } from "@/app/api/admin/registrations/route";
|
import type { RegistrationLeadRow } from "@/app/api/admin/registrations/route";
|
||||||
@@ -25,7 +25,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = registrationStatusSchema.safeParse(body);
|
const parsed = registrationStatusSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToSiteStat, type SiteStatRow } from "@/lib/db/mappers";
|
import { rowToSiteStat, type SiteStatRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -32,7 +32,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = statPatchSchema.safeParse(body);
|
const parsed = statPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToSiteStat, type SiteStatRow } from "@/lib/db/mappers";
|
import { rowToSiteStat, type SiteStatRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = statCreateSchema.safeParse(body);
|
const parsed = statCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToTestimonial, type TestimonialRow } from "@/lib/db/mappers";
|
import { rowToTestimonial, type TestimonialRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -34,7 +34,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = testimonialPatchSchema.safeParse(body);
|
const parsed = testimonialPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToTestimonial, type TestimonialRow } from "@/lib/db/mappers";
|
import { rowToTestimonial, type TestimonialRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = testimonialCreateSchema.safeParse(body);
|
const parsed = testimonialCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToIntersectionTopic, type IntersectionTopicRow } from "@/lib/db/mappers";
|
import { rowToIntersectionTopic, type IntersectionTopicRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { revalidateSite } from "@/lib/api/revalidate";
|
import { revalidateSite } from "@/lib/api/revalidate";
|
||||||
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
import { parseJsonBody, buildUpdate } from "@/lib/api/crud";
|
||||||
@@ -38,7 +38,7 @@ export async function PATCH(
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = topicPatchSchema.safeParse(body);
|
const parsed = topicPatchSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { query } from "@/lib/db";
|
import { query } from "@/lib/db";
|
||||||
import { rowToIntersectionTopic, type IntersectionTopicRow } from "@/lib/db/mappers";
|
import { rowToIntersectionTopic, type IntersectionTopicRow } from "@/lib/db/mappers";
|
||||||
import { requireAdmin } from "@/lib/auth/admin";
|
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 { errorResponse } from "@/lib/api/response";
|
||||||
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
import { makeId, parseJsonBody, buildInsert } from "@/lib/api/crud";
|
||||||
import { isUniqueViolation } from "@/lib/db/errors";
|
import { isUniqueViolation } from "@/lib/db/errors";
|
||||||
@@ -21,7 +21,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
return errorResponse("بدنه درخواست JSON معتبر نیست", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsed = topicCreateSchema.safeParse(body);
|
const parsed = topicCreateSchema.safeParse(normalizeRichWrite(body));
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { getArticleById } from "@/lib/data/articles";
|
|
||||||
|
|
||||||
type Params = { params: Promise<{ id: string }> };
|
export function GET() {
|
||||||
|
return new NextResponse(null, { status: 404 });
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { getArticles } from "@/lib/data/articles";
|
|
||||||
|
|
||||||
export async function GET() {
|
export function GET() {
|
||||||
const data = await getArticles();
|
return new NextResponse(null, { status: 404 });
|
||||||
return NextResponse.json({ data });
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { getEventById } from "@/lib/data/events";
|
|
||||||
|
|
||||||
type Params = { params: Promise<{ id: string }> };
|
export function GET() {
|
||||||
|
return new NextResponse(null, { status: 404 });
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { getEvents } from "@/lib/data/events";
|
|
||||||
|
|
||||||
export async function GET() {
|
export function GET() {
|
||||||
const data = await getEvents();
|
return new NextResponse(null, { status: 404 });
|
||||||
return NextResponse.json({ data });
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { getProgramBySlug } from "@/lib/data/programs";
|
|
||||||
|
|
||||||
type Params = { params: Promise<{ slug: string }> };
|
export function GET() {
|
||||||
|
return new NextResponse(null, { status: 404 });
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { getPrograms } from "@/lib/data/programs";
|
|
||||||
|
|
||||||
export async function GET() {
|
export function GET() {
|
||||||
const data = await getPrograms();
|
return new NextResponse(null, { status: 404 });
|
||||||
return NextResponse.json({ data });
|
|
||||||
}
|
}
|
||||||
@@ -184,6 +184,19 @@
|
|||||||
/* Metamorph field: static on purpose (animations removed for mobile perf).
|
/* Metamorph field: static on purpose (animations removed for mobile perf).
|
||||||
Legacy keyframes kept only so reduced-motion rules stay harmless. */
|
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,
|
.page-hero::after,
|
||||||
.home-hero::after {
|
.home-hero::after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const getCounts = async (): Promise<Record<string, number>> => {
|
|||||||
UNION ALL SELECT 'programs', count(*) FROM programs
|
UNION ALL SELECT 'programs', count(*) FROM programs
|
||||||
UNION ALL SELECT 'events', count(*) FROM events
|
UNION ALL SELECT 'events', count(*) FROM events
|
||||||
UNION ALL SELECT 'articles', count(*) FROM articles
|
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 'faculty', count(*) FROM faculty_members
|
||||||
UNION ALL SELECT 'alumni', count(*) FROM alumni_stories`,
|
UNION ALL SELECT 'alumni', count(*) FROM alumni_stories`,
|
||||||
);
|
);
|
||||||
@@ -49,6 +50,7 @@ const countCards = [
|
|||||||
{ key: "courses", label: "دوره ها", href: "/mstcontroller/courses", icon: BookOpen },
|
{ key: "courses", label: "دوره ها", href: "/mstcontroller/courses", icon: BookOpen },
|
||||||
{ key: "programs", label: "برنامه ها", href: "/mstcontroller/programs", icon: GraduationCap },
|
{ key: "programs", label: "برنامه ها", href: "/mstcontroller/programs", icon: GraduationCap },
|
||||||
{ key: "events", label: "رویدادها", href: "/mstcontroller/events", icon: Calendar },
|
{ 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: "articles", label: "مقالات", href: "/mstcontroller/articles", icon: Newspaper },
|
||||||
{ key: "faculty", label: "اساتید", href: "/mstcontroller/faculty", icon: Users },
|
{ key: "faculty", label: "اساتید", href: "/mstcontroller/faculty", icon: Users },
|
||||||
{ key: "alumni", label: "دانش آموختگان", href: "/mstcontroller/alumni", icon: MessageSquareQuote },
|
{ key: "alumni", label: "دانش آموختگان", href: "/mstcontroller/alumni", icon: MessageSquareQuote },
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { SiteHeader } from "@/components/organisms/SiteHeader";
|
|||||||
import { buildCourseNavChildren } from "@/lib/course-nav";
|
import { buildCourseNavChildren } from "@/lib/course-nav";
|
||||||
import { getCourses } from "@/lib/data/courses";
|
import { getCourses } from "@/lib/data/courses";
|
||||||
import { listPublishedCourseTags } from "@/lib/data/taxonomy";
|
import { listPublishedCourseTags } from "@/lib/data/taxonomy";
|
||||||
import { getPrograms } from "@/lib/data/programs";
|
|
||||||
import {
|
import {
|
||||||
courseNavParentTag,
|
courseNavParentTag,
|
||||||
|
facultyNetworkUrl,
|
||||||
facultySiteUrl,
|
facultySiteUrl,
|
||||||
professionalNav,
|
professionalNav,
|
||||||
siteShortName,
|
siteShortName,
|
||||||
@@ -22,12 +22,10 @@ export default async function ProfessionalLayout({
|
|||||||
const t = await getTranslations();
|
const t = await getTranslations();
|
||||||
const year = new Date().getFullYear();
|
const year = new Date().getFullYear();
|
||||||
let courses: Awaited<ReturnType<typeof getCourses>> = [];
|
let courses: Awaited<ReturnType<typeof getCourses>> = [];
|
||||||
let programs: Awaited<ReturnType<typeof getPrograms>> = [];
|
|
||||||
let navTags: Awaited<ReturnType<typeof listPublishedCourseTags>> = [];
|
let navTags: Awaited<ReturnType<typeof listPublishedCourseTags>> = [];
|
||||||
try {
|
try {
|
||||||
[courses, programs, navTags] = await Promise.all([
|
[courses, navTags] = await Promise.all([
|
||||||
getCourses(),
|
getCourses(),
|
||||||
getPrograms(),
|
|
||||||
listPublishedCourseTags({ navOnly: true }),
|
listPublishedCourseTags({ navOnly: true }),
|
||||||
]);
|
]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -53,7 +51,6 @@ export default async function ProfessionalLayout({
|
|||||||
brandSubtitle={t("nav.brandSubtitle")}
|
brandSubtitle={t("nav.brandSubtitle")}
|
||||||
variant="professional"
|
variant="professional"
|
||||||
courses={courses}
|
courses={courses}
|
||||||
programs={programs}
|
|
||||||
/>
|
/>
|
||||||
<div className="min-w-0 flex-1 overflow-x-clip">{children}</div>
|
<div className="min-w-0 flex-1 overflow-x-clip">{children}</div>
|
||||||
<SiteFooter
|
<SiteFooter
|
||||||
@@ -62,6 +59,7 @@ export default async function ProfessionalLayout({
|
|||||||
linksTitle={t("footer.links")}
|
linksTitle={t("footer.links")}
|
||||||
links={[
|
links={[
|
||||||
{ label: t("footer.facultySite"), href: facultySiteUrl },
|
{ label: t("footer.facultySite"), href: facultySiteUrl },
|
||||||
|
{ label: t("footer.facultyNetwork"), href: facultyNetworkUrl },
|
||||||
{ label: t("footer.press"), href: "/press" },
|
{ label: t("footer.press"), href: "/press" },
|
||||||
{ label: t("footer.careers"), href: "/careers" },
|
{ label: t("footer.careers"), href: "/careers" },
|
||||||
]}
|
]}
|
||||||
|
|||||||
+31
-79
@@ -1,9 +1,7 @@
|
|||||||
import type { MetadataRoute } from "next";
|
import type { MetadataRoute } from "next";
|
||||||
import { getArticles } from "@/lib/data/articles";
|
import { connection } from "next/server";
|
||||||
import { getCourses } from "@/lib/data/courses";
|
import { getCoursesForSitemap } from "@/lib/data/courses";
|
||||||
import { getEvents } from "@/lib/data/events";
|
import { getNewsForSitemap } from "@/lib/data/news";
|
||||||
import { getPrograms } from "@/lib/data/programs";
|
|
||||||
import { getTopics } from "@/lib/data/site";
|
|
||||||
|
|
||||||
const BASE_URL = (
|
const BASE_URL = (
|
||||||
process.env.NEXT_PUBLIC_SITE_URL ?? "https://edu.mstaut.ir"
|
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 SitemapEntry = MetadataRoute.Sitemap[number];
|
||||||
type ChangeFrequency = NonNullable<SitemapEntry["changeFrequency"]>;
|
type ChangeFrequency = NonNullable<SitemapEntry["changeFrequency"]>;
|
||||||
|
|
||||||
|
/** Run on each request so published news and courses stay current. */
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
function sitemapEntry(
|
function sitemapEntry(
|
||||||
path: string,
|
path: string,
|
||||||
options: {
|
options: {
|
||||||
@@ -26,103 +27,54 @@ function sitemapEntry(
|
|||||||
const normalized = path.startsWith("/") ? path : `/${path}`;
|
const normalized = path.startsWith("/") ? path : `/${path}`;
|
||||||
return {
|
return {
|
||||||
url: `${BASE_URL}${normalized}`,
|
url: `${BASE_URL}${normalized}`,
|
||||||
lastModified: options.lastModified ?? new Date(),
|
...(options.lastModified ? { lastModified: options.lastModified } : {}),
|
||||||
changeFrequency: options.changeFrequency ?? "monthly",
|
changeFrequency: options.changeFrequency ?? "monthly",
|
||||||
priority: options.priority ?? 0.5,
|
priority: options.priority ?? 0.5,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||||
|
await connection();
|
||||||
|
|
||||||
const entries: MetadataRoute.Sitemap = [
|
const entries: MetadataRoute.Sitemap = [
|
||||||
sitemapEntry("/", { changeFrequency: "weekly", priority: 1.0 }),
|
sitemapEntry("/", { changeFrequency: "weekly", priority: 1.0 }),
|
||||||
sitemapEntry("/professional", { changeFrequency: "weekly", priority: 0.9 }),
|
sitemapEntry("/professional", { changeFrequency: "weekly", priority: 0.9 }),
|
||||||
sitemapEntry("/about", { priority: 0.7 }),
|
sitemapEntry("/about", { priority: 0.7 }),
|
||||||
sitemapEntry("/contact", { priority: 0.7 }),
|
sitemapEntry("/contact", { priority: 0.7 }),
|
||||||
sitemapEntry("/values", { priority: 0.7 }),
|
sitemapEntry("/values", { priority: 0.7 }),
|
||||||
sitemapEntry("/alumni", { priority: 0.6 }),
|
sitemapEntry("/news", { changeFrequency: "weekly", priority: 0.6 }),
|
||||||
sitemapEntry("/programs", { changeFrequency: "weekly", priority: 0.8 }),
|
|
||||||
sitemapEntry("/insights", { changeFrequency: "weekly", priority: 0.7 }),
|
|
||||||
sitemapEntry("/events", { changeFrequency: "weekly", priority: 0.7 }),
|
|
||||||
...LEGAL_SLUGS.map((slug) =>
|
...LEGAL_SLUGS.map((slug) =>
|
||||||
sitemapEntry(`/${slug}`, { changeFrequency: "yearly", priority: 0.4 }),
|
sitemapEntry(`/${slug}`, { changeFrequency: "yearly", priority: 0.4 }),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
const [newsResult, coursesResult] = await Promise.allSettled([
|
||||||
const courses = await getCourses();
|
getNewsForSitemap(),
|
||||||
for (const course of courses) {
|
getCoursesForSitemap(),
|
||||||
if (!course.slug) continue;
|
]);
|
||||||
|
|
||||||
|
if (newsResult.status === "fulfilled") {
|
||||||
|
for (const item of newsResult.value) {
|
||||||
entries.push(
|
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",
|
changeFrequency: "weekly",
|
||||||
priority: 0.8,
|
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;
|
return entries;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
} from "@/components/ui/card";
|
} from "@/components/ui/card";
|
||||||
import { blurDataURL } from "@/lib/images";
|
import { blurDataURL } from "@/lib/images";
|
||||||
import type { Program } from "@/lib/types";
|
import type { Program } from "@/lib/types";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
export function ProgramCard({
|
export function ProgramCard({
|
||||||
@@ -33,7 +34,7 @@ export function ProgramCard({
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<CardDescription className="leading-relaxed">
|
<CardDescription className="leading-relaxed">
|
||||||
{program.blurb}
|
{htmlToPlain(program.blurb)}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
<span className="mt-5 inline-flex items-center gap-1 text-xs font-bold text-accent">
|
<span className="mt-5 inline-flex items-center gap-1 text-xs font-bold text-accent">
|
||||||
جزئیات برنامه
|
جزئیات برنامه
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import {
|
|||||||
import { CourseCardBanner } from "@/components/molecules/CourseCardBanner";
|
import { CourseCardBanner } from "@/components/molecules/CourseCardBanner";
|
||||||
import type { Course } from "@/lib/types";
|
import type { Course } from "@/lib/types";
|
||||||
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
||||||
|
import { formatCourseScheduleLine } from "@/lib/format-date";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
export function CourseCatalogCard({
|
export function CourseCatalogCard({
|
||||||
@@ -28,6 +30,7 @@ export function CourseCatalogCard({
|
|||||||
tagHref: (slug: string) => string;
|
tagHref: (slug: string) => string;
|
||||||
}) {
|
}) {
|
||||||
const priceLabel = formatCoursePrice(course.price);
|
const priceLabel = formatCoursePrice(course.price);
|
||||||
|
const schedule = formatCourseScheduleLine(course);
|
||||||
const isArchive = variant === "archive";
|
const isArchive = variant === "archive";
|
||||||
const showFeatured = !isArchive && Boolean(course.featured);
|
const showFeatured = !isArchive && Boolean(course.featured);
|
||||||
|
|
||||||
@@ -62,7 +65,7 @@ export function CourseCatalogCard({
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="pointer-events-none relative z-[1] space-y-3 px-4 pb-4">
|
<CardContent className="pointer-events-none relative z-[1] space-y-3 px-4 pb-4">
|
||||||
<CardDescription className="line-clamp-3 text-primary-foreground/70">
|
<CardDescription className="line-clamp-3 text-primary-foreground/70">
|
||||||
{course.summary}
|
{htmlToPlain(course.summary)}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
{course.categories.length > 0 || course.tags.length > 0 ? (
|
{course.categories.length > 0 || course.tags.length > 0 ? (
|
||||||
<div className="pointer-events-auto flex flex-wrap gap-1.5">
|
<div className="pointer-events-auto flex flex-wrap gap-1.5">
|
||||||
@@ -124,6 +127,9 @@ export function CourseCatalogCard({
|
|||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</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">
|
<span className="inline-flex text-sm font-semibold text-primary-foreground underline-offset-4 group-hover:underline">
|
||||||
{isArchive ? "مشاهده جزئیات" : "جزئیات و ثبت نام"}
|
{isArchive ? "مشاهده جزئیات" : "جزئیات و ثبت نام"}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -42,18 +42,18 @@ export function HeroFeatured({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Container className="relative z-[2] flex min-h-[34rem] min-w-0 items-center py-16 sm:min-h-[36rem] sm:py-20">
|
<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 max-w-2xl text-start lg:max-w-3xl">
|
<div className="home-hero__copy w-full min-w-0 text-start">
|
||||||
<div className="max-w-full space-y-1 text-sm font-medium text-primary-foreground/60">
|
<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">{hero.university}</p>
|
||||||
<p className="leading-7 text-pretty text-primary-foreground/75">
|
<p className="leading-7 text-pretty text-primary-foreground/75">
|
||||||
{hero.center}
|
{hero.center}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Heading as="h1" level={1} className="mt-6 max-w-4xl">
|
<Heading as="h1" level={1} className="mt-6">
|
||||||
{hero.title}
|
{hero.title}
|
||||||
</Heading>
|
</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}
|
{hero.description}
|
||||||
</p>
|
</p>
|
||||||
<div className="mt-9 flex flex-wrap gap-3">
|
<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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -31,8 +31,8 @@ export function PageHero({
|
|||||||
className={cn(
|
className={cn(
|
||||||
"page-hero relative isolate flex items-center overflow-hidden bg-primary text-primary-foreground",
|
"page-hero relative isolate flex items-center overflow-hidden bg-primary text-primary-foreground",
|
||||||
size === "lg"
|
size === "lg"
|
||||||
? "min-h-[34rem] py-16 sm:min-h-[38rem] sm:py-20"
|
? "min-h-[32rem] py-16 sm:min-h-[36rem] sm:py-20"
|
||||||
: "py-16 sm:py-24",
|
: "min-h-[22rem] py-14 sm:min-h-[26rem] sm:py-16",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<CmsImage
|
<CmsImage
|
||||||
@@ -54,36 +54,36 @@ export function PageHero({
|
|||||||
: "bg-gradient-to-l from-primary via-primary/90 to-primary/65",
|
: "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" />
|
<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">
|
<Container className="relative z-[2] min-w-0">
|
||||||
<div className="page-hero__content w-full min-w-0 max-w-4xl text-start">
|
<div className="grid items-center lg:grid-cols-[minmax(0,42rem)_minmax(12rem,1fr)] lg:gap-12">
|
||||||
{eyebrow ? (
|
<div className="page-hero__content w-full min-w-0 text-start">
|
||||||
<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 ? (
|
||||||
{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">
|
||||||
</p>
|
{eyebrow}
|
||||||
) : null}
|
</p>
|
||||||
<Heading as="h1" level={1} className="max-w-4xl text-primary-foreground">
|
) : null}
|
||||||
{title}
|
<Heading as="h1" level={1} className="text-primary-foreground">
|
||||||
</Heading>
|
{title}
|
||||||
{intro ? (
|
</Heading>
|
||||||
<div className="mt-5 max-w-2xl border-t border-secondary/50 pt-5 text-pretty text-primary-foreground/70">
|
{intro ? (
|
||||||
{typeof intro === "string" ? (
|
<div className="mt-5 w-full border-t border-secondary/50 pt-5 text-justify text-pretty text-primary-foreground/70">
|
||||||
<p className="text-base leading-7 sm:text-lg sm:leading-8">{intro}</p>
|
{typeof intro === "string" ? (
|
||||||
) : (
|
<p className="text-base leading-7 sm:text-lg sm:leading-8">{intro}</p>
|
||||||
intro
|
) : (
|
||||||
)}
|
intro
|
||||||
</div>
|
)}
|
||||||
) : null}
|
</div>
|
||||||
{actions ? (
|
) : null}
|
||||||
<div className="mt-8 flex flex-wrap gap-3">{actions}</div>
|
{actions ? (
|
||||||
) : null}
|
<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>
|
</div>
|
||||||
</Container>
|
</Container>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ type RichHtmlTone = "default" | "onPrimary";
|
|||||||
|
|
||||||
const toneClass: Record<RichHtmlTone, string> = {
|
const toneClass: Record<RichHtmlTone, string> = {
|
||||||
default: cn(
|
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",
|
"[&_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",
|
"[&_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",
|
"[&_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",
|
"[&_hr]:my-6 [&_hr]:border-border",
|
||||||
),
|
),
|
||||||
onPrimary: cn(
|
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",
|
"[&_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",
|
"[&_h3]:mt-3 [&_h3]:mb-2 [&_h3]:text-base [&_h3]:font-bold [&_h3]:text-primary-foreground",
|
||||||
"[&_p]:mb-3 [&_p:last-child]:mb-0",
|
"[&_p]:mb-3 [&_p:last-child]:mb-0",
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ export function SectionHeader({
|
|||||||
{description ? (
|
{description ? (
|
||||||
<p
|
<p
|
||||||
className={cn(
|
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",
|
inverse ? "opacity-75" : "text-muted-foreground",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { X } from "lucide-react";
|
|||||||
import { Container } from "@/components/atoms/Container";
|
import { Container } from "@/components/atoms/Container";
|
||||||
import { DotCta } from "@/components/atoms/DotCta";
|
import { DotCta } from "@/components/atoms/DotCta";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import type { Program } from "@/lib/types";
|
import type { Program } from "@/lib/types";
|
||||||
|
|
||||||
export function AcademicsOverlay({
|
export function AcademicsOverlay({
|
||||||
@@ -71,7 +72,7 @@ export function AcademicsOverlay({
|
|||||||
{program.title}
|
{program.title}
|
||||||
</span>
|
</span>
|
||||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||||
{program.blurb}
|
{htmlToPlain(program.blurb)}
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
@@ -93,7 +94,7 @@ export function AcademicsOverlay({
|
|||||||
{program.title}
|
{program.title}
|
||||||
</span>
|
</span>
|
||||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||||
{program.blurb}
|
{htmlToPlain(program.blurb)}
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { X } from "lucide-react";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Container } from "@/components/atoms/Container";
|
import { Container } from "@/components/atoms/Container";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import type { CampaignBanner } from "@/lib/types";
|
import type { CampaignBanner } from "@/lib/types";
|
||||||
|
|
||||||
const STORAGE_PREFIX = "aut-banner:v1:";
|
const STORAGE_PREFIX = "aut-banner:v1:";
|
||||||
@@ -50,7 +51,7 @@ export function CampaignBanners({ banners }: { banners: CampaignBanner[] }) {
|
|||||||
<div className="bg-primary text-primary-foreground">
|
<div className="bg-primary text-primary-foreground">
|
||||||
<Container className="flex min-w-0 items-center justify-between gap-3 py-3 sm:gap-4">
|
<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">
|
<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
|
<Link
|
||||||
href={banner.href}
|
href={banner.href}
|
||||||
className="font-bold text-secondary underline-offset-4 hover:underline"
|
className="font-bold text-secondary underline-offset-4 hover:underline"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { Label } from "@/components/ui/label";
|
|||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { Heading } from "@/components/atoms/Heading";
|
import { Heading } from "@/components/atoms/Heading";
|
||||||
import { CourseCatalogCard } from "@/components/molecules/CourseCatalogCard";
|
import { CourseCatalogCard } from "@/components/molecules/CourseCatalogCard";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import type { Course, TaxonomyRef } from "@/lib/types";
|
import type { Course, TaxonomyRef } from "@/lib/types";
|
||||||
import {
|
import {
|
||||||
ARCHIVE_SECTION_LABEL,
|
ARCHIVE_SECTION_LABEL,
|
||||||
@@ -112,7 +113,7 @@ export function CategoryCourseExplorer({
|
|||||||
const matchesQuery =
|
const matchesQuery =
|
||||||
!deferredQuery ||
|
!deferredQuery ||
|
||||||
course.title.includes(deferredQuery) ||
|
course.title.includes(deferredQuery) ||
|
||||||
course.summary.includes(deferredQuery);
|
htmlToPlain(course.summary).includes(deferredQuery);
|
||||||
return matchesCategory && matchesTag && matchesQuery;
|
return matchesCategory && matchesTag && matchesQuery;
|
||||||
});
|
});
|
||||||
}, [courses, categorySlug, tagSlug, deferredQuery]);
|
}, [courses, categorySlug, tagSlug, deferredQuery]);
|
||||||
|
|||||||
@@ -0,0 +1,237 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||||
|
import { CmsImage } from "@/components/atoms/CmsImage";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const imageFrameClass = "relative aspect-[4/3] w-full overflow-hidden rounded-xl bg-muted";
|
||||||
|
const imageSizes = "(min-width: 1280px) 24rem, (min-width: 1024px) 20rem, 100vw";
|
||||||
|
|
||||||
|
const faNumber = new Intl.NumberFormat("fa-IR");
|
||||||
|
|
||||||
|
function photoLabel(title: string, index: number, total: number) {
|
||||||
|
return `${title}، تصویر ${faNumber.format(index + 1)} از ${faNumber.format(total)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NewsPhotoLayout({
|
||||||
|
title,
|
||||||
|
banner,
|
||||||
|
gallery,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
title: string;
|
||||||
|
banner: string;
|
||||||
|
gallery: string[];
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
const images = [banner, ...gallery].map((src) => src.trim()).filter(Boolean);
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [index, setIndex] = useState(0);
|
||||||
|
const total = images.length;
|
||||||
|
const hasBanner = Boolean(banner.trim());
|
||||||
|
const hasGallery = gallery.some((src) => src.trim());
|
||||||
|
const hasImages = total > 0;
|
||||||
|
|
||||||
|
function openAt(next: number) {
|
||||||
|
setIndex(next);
|
||||||
|
setOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function step(delta: number) {
|
||||||
|
setIndex((current) => (current + delta + total) % total);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open || total < 2) return;
|
||||||
|
function onKey(event: KeyboardEvent) {
|
||||||
|
if (event.key === "ArrowLeft") {
|
||||||
|
event.preventDefault();
|
||||||
|
setIndex((current) => (current + 1) % total);
|
||||||
|
} else if (event.key === "ArrowRight") {
|
||||||
|
event.preventDefault();
|
||||||
|
setIndex((current) => (current - 1 + total) % total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.addEventListener("keydown", onKey);
|
||||||
|
return () => window.removeEventListener("keydown", onKey);
|
||||||
|
}, [open, total]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-no-action-loading
|
||||||
|
className={cn(
|
||||||
|
"mt-10 grid grid-cols-1 gap-10 lg:mt-12",
|
||||||
|
hasImages &&
|
||||||
|
"lg:grid-cols-[minmax(0,1fr)_20rem] lg:items-start lg:gap-x-12 lg:gap-y-4 xl:grid-cols-[minmax(0,1fr)_24rem]",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{hasBanner ? (
|
||||||
|
<PhotoButton
|
||||||
|
src={images[0]}
|
||||||
|
label={photoLabel(title, 0, total)}
|
||||||
|
className="lg:col-start-2 lg:row-start-1"
|
||||||
|
priority
|
||||||
|
onOpen={() => openAt(0)}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"min-w-0",
|
||||||
|
hasImages && "lg:col-start-1 lg:row-start-1",
|
||||||
|
hasBanner && hasGallery && "lg:row-span-2",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{hasGallery ? (
|
||||||
|
<aside
|
||||||
|
aria-label="تصاویر خبر"
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col gap-4 lg:col-start-2",
|
||||||
|
hasBanner ? "lg:row-start-2" : "lg:row-start-1",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{images.slice(hasBanner ? 1 : 0).map((src, extraIndex) => {
|
||||||
|
const imageIndex = (hasBanner ? 1 : 0) + extraIndex;
|
||||||
|
return (
|
||||||
|
<PhotoButton
|
||||||
|
key={`${src}-${imageIndex}`}
|
||||||
|
src={src}
|
||||||
|
label={photoLabel(title, imageIndex, total)}
|
||||||
|
onOpen={() => openAt(imageIndex)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</aside>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
|
<DialogContent
|
||||||
|
data-no-action-loading
|
||||||
|
className="max-h-[calc(100%-2rem)] w-full max-w-[calc(100%-2rem)] gap-3 overflow-y-auto bg-card p-3 text-card-foreground sm:max-w-5xl sm:p-4"
|
||||||
|
>
|
||||||
|
<DialogTitle className="sr-only">گالری {title}</DialogTitle>
|
||||||
|
<DialogDescription className="sr-only">
|
||||||
|
{total > 0 ? photoLabel(title, index, total) : title}
|
||||||
|
</DialogDescription>
|
||||||
|
{total > 0 ? (
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
<div className="relative flex min-h-64 items-center justify-center sm:min-h-80">
|
||||||
|
<CmsImage
|
||||||
|
key={images[index]}
|
||||||
|
src={images[index]}
|
||||||
|
alt={photoLabel(title, index, total)}
|
||||||
|
width={1600}
|
||||||
|
height={1200}
|
||||||
|
className="max-h-[70vh] w-auto max-w-full object-contain"
|
||||||
|
sizes="(min-width: 1024px) 64rem, 100vw"
|
||||||
|
/>
|
||||||
|
{total > 1 ? (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="secondary"
|
||||||
|
size="icon"
|
||||||
|
className="absolute start-2 top-1/2 -translate-y-1/2"
|
||||||
|
aria-label="تصویر قبلی"
|
||||||
|
onClick={() => step(-1)}
|
||||||
|
>
|
||||||
|
<ChevronRight />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="secondary"
|
||||||
|
size="icon"
|
||||||
|
className="absolute end-2 top-1/2 -translate-y-1/2"
|
||||||
|
aria-label="تصویر بعدی"
|
||||||
|
onClick={() => step(1)}
|
||||||
|
>
|
||||||
|
<ChevronLeft />
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
<p className="text-center text-sm text-muted-foreground">
|
||||||
|
{faNumber.format(index + 1)} از {faNumber.format(total)}
|
||||||
|
</p>
|
||||||
|
{total > 1 ? (
|
||||||
|
<div className="flex gap-2 overflow-x-auto pb-1">
|
||||||
|
{images.map((src, imageIndex) => {
|
||||||
|
const selected = imageIndex === index;
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={`${src}-${imageIndex}`}
|
||||||
|
type="button"
|
||||||
|
aria-label={photoLabel(title, imageIndex, total)}
|
||||||
|
aria-current={selected ? "true" : undefined}
|
||||||
|
className={cn(
|
||||||
|
"relative size-16 shrink-0 overflow-hidden rounded-lg bg-muted",
|
||||||
|
selected ? "ring-2 ring-primary" : "opacity-70 hover:opacity-100",
|
||||||
|
)}
|
||||||
|
onClick={() => setIndex(imageIndex)}
|
||||||
|
>
|
||||||
|
<CmsImage
|
||||||
|
src={src}
|
||||||
|
alt=""
|
||||||
|
fill
|
||||||
|
className="object-cover"
|
||||||
|
sizes="64px"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function PhotoButton({
|
||||||
|
src,
|
||||||
|
label,
|
||||||
|
className,
|
||||||
|
priority = false,
|
||||||
|
onOpen,
|
||||||
|
}: {
|
||||||
|
src: string;
|
||||||
|
label: string;
|
||||||
|
className?: string;
|
||||||
|
priority?: boolean;
|
||||||
|
onOpen: () => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={cn(
|
||||||
|
imageFrameClass,
|
||||||
|
"cursor-pointer focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
aria-label={label}
|
||||||
|
onClick={onOpen}
|
||||||
|
>
|
||||||
|
<CmsImage
|
||||||
|
src={src}
|
||||||
|
alt=""
|
||||||
|
fill
|
||||||
|
priority={priority}
|
||||||
|
className="object-cover"
|
||||||
|
sizes={imageSizes}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,16 +6,15 @@ import { useDeferredValue, useEffect, useMemo, useState } from "react";
|
|||||||
import { createPortal } from "react-dom";
|
import { createPortal } from "react-dom";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import type { Course, Program } from "@/lib/types";
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
|
import type { Course } from "@/lib/types";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
export function SearchOverlay({
|
export function SearchOverlay({
|
||||||
courses,
|
courses,
|
||||||
programs,
|
|
||||||
label,
|
label,
|
||||||
}: {
|
}: {
|
||||||
courses: Course[];
|
courses: Course[];
|
||||||
programs: Program[];
|
|
||||||
label: string;
|
label: string;
|
||||||
}) {
|
}) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -46,18 +45,11 @@ export function SearchOverlay({
|
|||||||
|
|
||||||
const results = useMemo(() => {
|
const results = useMemo(() => {
|
||||||
const q = deferredQuery.trim();
|
const q = deferredQuery.trim();
|
||||||
if (!q) {
|
if (!q) return courses.slice(0, 8);
|
||||||
return { programs: programs.slice(0, 4), courses: courses.slice(0, 4) };
|
return courses.filter(
|
||||||
}
|
(c) => c.title.includes(q) || htmlToPlain(c.summary).includes(q),
|
||||||
return {
|
);
|
||||||
programs: programs.filter(
|
}, [deferredQuery, courses]);
|
||||||
(p) => p.title.includes(q) || p.blurb.includes(q),
|
|
||||||
),
|
|
||||||
courses: courses.filter(
|
|
||||||
(c) => c.title.includes(q) || c.summary.includes(q),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}, [deferredQuery, programs, courses]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -100,30 +92,16 @@ export function SearchOverlay({
|
|||||||
autoFocus
|
autoFocus
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
placeholder="جستجوی برنامه یا دوره…"
|
placeholder="جستجوی دوره…"
|
||||||
className="h-14 rounded-xl border-border bg-card px-4 text-lg text-foreground shadow-sm placeholder:text-muted-foreground focus-visible:border-primary focus-visible:ring-primary/20 sm:text-xl"
|
className="h-14 rounded-xl border-border bg-card px-4 text-lg text-foreground shadow-sm placeholder:text-muted-foreground focus-visible:border-primary focus-visible:ring-primary/20 sm:text-xl"
|
||||||
/>
|
/>
|
||||||
<div
|
<div className={cn("transition-opacity", isStale && "opacity-70")}>
|
||||||
className={cn(
|
|
||||||
"grid gap-8 transition-opacity sm:grid-cols-2",
|
|
||||||
isStale && "opacity-70",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<ResultGroup
|
|
||||||
title="برنامه ها"
|
|
||||||
items={results.programs.map((p) => ({
|
|
||||||
href: p.href,
|
|
||||||
title: p.title,
|
|
||||||
subtitle: p.tagline,
|
|
||||||
}))}
|
|
||||||
onNavigate={() => setOpen(false)}
|
|
||||||
/>
|
|
||||||
<ResultGroup
|
<ResultGroup
|
||||||
title="دوره ها"
|
title="دوره ها"
|
||||||
items={results.courses.map((c) => ({
|
items={results.map((c) => ({
|
||||||
href: c.registrationUrl,
|
href: c.registrationUrl,
|
||||||
title: c.title,
|
title: c.title,
|
||||||
subtitle: c.summary,
|
subtitle: htmlToPlain(c.summary),
|
||||||
}))}
|
}))}
|
||||||
onNavigate={() => setOpen(false)}
|
onNavigate={() => setOpen(false)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -42,16 +42,21 @@ export function SiteFooter({
|
|||||||
{linksTitle}
|
{linksTitle}
|
||||||
</p>
|
</p>
|
||||||
<ul className="flex flex-col gap-2.5 text-sm font-medium">
|
<ul className="flex flex-col gap-2.5 text-sm font-medium">
|
||||||
{links.map((link) => (
|
{links.map((link) => {
|
||||||
<li key={link.href}>
|
const external = link.href.startsWith("http");
|
||||||
<Link
|
return (
|
||||||
href={link.href}
|
<li key={link.href}>
|
||||||
className="text-primary-foreground/80 transition-colors hover:text-primary-foreground"
|
<Link
|
||||||
>
|
href={link.href}
|
||||||
{link.label}
|
target={external ? "_blank" : undefined}
|
||||||
</Link>
|
rel={external ? "noopener noreferrer" : undefined}
|
||||||
</li>
|
className="text-primary-foreground/80 transition-colors hover:text-primary-foreground"
|
||||||
))}
|
>
|
||||||
|
{link.label}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import { SearchOverlay } from "@/components/organisms/SearchOverlay";
|
import { SearchOverlay } from "@/components/organisms/SearchOverlay";
|
||||||
import type { Course, NavItem, Program } from "@/lib/types";
|
import type { Course, NavItem } from "@/lib/types";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
function NavLink({
|
function NavLink({
|
||||||
@@ -54,7 +54,7 @@ function NavDropdown({
|
|||||||
<DropdownMenuTrigger
|
<DropdownMenuTrigger
|
||||||
data-no-action-loading
|
data-no-action-loading
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-flex cursor-pointer items-center gap-1 rounded-lg px-3 py-2 text-sm font-semibold transition-colors outline-none",
|
"inline-flex cursor-pointer items-center gap-1 rounded-lg px-2.5 py-2 text-sm font-semibold transition-colors outline-none xl:px-3",
|
||||||
isDark
|
isDark
|
||||||
? "text-primary-foreground/80 hover:text-primary-foreground"
|
? "text-primary-foreground/80 hover:text-primary-foreground"
|
||||||
: "text-foreground/75 hover:bg-muted hover:text-accent",
|
: "text-foreground/75 hover:bg-muted hover:text-accent",
|
||||||
@@ -87,7 +87,6 @@ export function SiteHeader({
|
|||||||
brandSubtitle,
|
brandSubtitle,
|
||||||
variant = "home",
|
variant = "home",
|
||||||
courses = [],
|
courses = [],
|
||||||
programs = [],
|
|
||||||
}: {
|
}: {
|
||||||
items: NavItem[];
|
items: NavItem[];
|
||||||
searchLabel: string;
|
searchLabel: string;
|
||||||
@@ -97,7 +96,6 @@ export function SiteHeader({
|
|||||||
brandSubtitle?: string;
|
brandSubtitle?: string;
|
||||||
variant?: "home" | "professional";
|
variant?: "home" | "professional";
|
||||||
courses?: Course[];
|
courses?: Course[];
|
||||||
programs?: Program[];
|
|
||||||
}) {
|
}) {
|
||||||
const [mobileOpen, setMobileOpen] = useState(false);
|
const [mobileOpen, setMobileOpen] = useState(false);
|
||||||
const isDark = variant === "professional";
|
const isDark = variant === "professional";
|
||||||
@@ -132,7 +130,7 @@ export function SiteHeader({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
className="hidden min-w-0 flex-1 items-center justify-start gap-2 xl:flex"
|
className="hidden min-w-0 flex-1 items-center justify-start gap-1 lg:flex xl:gap-2"
|
||||||
aria-label="منوی اصلی"
|
aria-label="منوی اصلی"
|
||||||
>
|
>
|
||||||
{items.map((item) => {
|
{items.map((item) => {
|
||||||
@@ -152,7 +150,7 @@ export function SiteHeader({
|
|||||||
item={item}
|
item={item}
|
||||||
isDark={isDark}
|
isDark={isDark}
|
||||||
className={cn(
|
className={cn(
|
||||||
"rounded-lg px-3 py-2 text-sm font-semibold transition-colors",
|
"rounded-lg px-2.5 py-2 text-sm font-semibold transition-colors xl:px-3",
|
||||||
isDark
|
isDark
|
||||||
? "text-primary-foreground/80 hover:text-primary-foreground"
|
? "text-primary-foreground/80 hover:text-primary-foreground"
|
||||||
: "text-foreground/75 hover:bg-muted hover:text-accent",
|
: "text-foreground/75 hover:bg-muted hover:text-accent",
|
||||||
@@ -164,7 +162,7 @@ export function SiteHeader({
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"ms-auto flex shrink-0 items-center gap-2 xl:ms-0",
|
"ms-auto flex shrink-0 items-center gap-2 lg:ms-0",
|
||||||
isDark && "text-primary-foreground",
|
isDark && "text-primary-foreground",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -179,15 +177,11 @@ export function SiteHeader({
|
|||||||
>
|
>
|
||||||
{contactLabel}
|
{contactLabel}
|
||||||
</Link>
|
</Link>
|
||||||
<SearchOverlay
|
<SearchOverlay courses={courses} label={searchLabel} />
|
||||||
courses={courses}
|
|
||||||
programs={programs}
|
|
||||||
label={searchLabel}
|
|
||||||
/>
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="xl:hidden"
|
className="lg:hidden"
|
||||||
data-no-action-loading
|
data-no-action-loading
|
||||||
aria-label={mobileOpen ? "بستن منو" : "باز کردن منو"}
|
aria-label={mobileOpen ? "بستن منو" : "باز کردن منو"}
|
||||||
aria-expanded={mobileOpen}
|
aria-expanded={mobileOpen}
|
||||||
@@ -205,7 +199,7 @@ export function SiteHeader({
|
|||||||
|
|
||||||
{mobileOpen ? (
|
{mobileOpen ? (
|
||||||
<div
|
<div
|
||||||
className="fixed inset-0 z-[60] flex flex-col bg-primary text-primary-foreground pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] xl:hidden"
|
className="fixed inset-0 z-[60] flex flex-col bg-primary text-primary-foreground pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] lg:hidden"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-label="منوی اصلی"
|
aria-label="منوی اصلی"
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ const NAV_GROUPS = [
|
|||||||
},
|
},
|
||||||
{ href: "/mstcontroller/programs", label: "برنامه ها", icon: GraduationCap, entity: "programs" },
|
{ href: "/mstcontroller/programs", label: "برنامه ها", icon: GraduationCap, entity: "programs" },
|
||||||
{ href: "/mstcontroller/events", label: "رویدادها", icon: Calendar, entity: "events" },
|
{ href: "/mstcontroller/events", label: "رویدادها", icon: Calendar, entity: "events" },
|
||||||
|
{ href: "/mstcontroller/news", label: "اخبار", icon: Newspaper, entity: "news" },
|
||||||
{ href: "/mstcontroller/articles", label: "مقالات", icon: Newspaper, entity: "articles" },
|
{ href: "/mstcontroller/articles", label: "مقالات", icon: Newspaper, entity: "articles" },
|
||||||
{ href: "/mstcontroller/topics", label: "موضوعات", icon: Tags, entity: "topics" },
|
{ href: "/mstcontroller/topics", label: "موضوعات", icon: Tags, entity: "topics" },
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,214 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
import { useEditor, useEditorState, EditorContent, type Editor } from "@tiptap/react";
|
||||||
|
import StarterKit from "@tiptap/starter-kit";
|
||||||
|
import Placeholder from "@tiptap/extension-placeholder";
|
||||||
|
import {
|
||||||
|
Bold,
|
||||||
|
Heading2,
|
||||||
|
Heading3,
|
||||||
|
Italic,
|
||||||
|
Link2,
|
||||||
|
List,
|
||||||
|
ListOrdered,
|
||||||
|
Minus,
|
||||||
|
Quote,
|
||||||
|
Redo2,
|
||||||
|
Strikethrough,
|
||||||
|
Underline,
|
||||||
|
Undo2,
|
||||||
|
} from "lucide-react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { normalizeRichHtml } from "@/lib/sanitize-html";
|
||||||
|
|
||||||
|
function ToolbarButton({
|
||||||
|
label,
|
||||||
|
pressed,
|
||||||
|
onClick,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
pressed?: boolean;
|
||||||
|
onClick: () => void;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant={pressed ? "secondary" : "ghost"}
|
||||||
|
size="icon-sm"
|
||||||
|
aria-label={label}
|
||||||
|
aria-pressed={pressed}
|
||||||
|
onMouseDown={(event) => event.preventDefault()}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setLink(editor: Editor) {
|
||||||
|
const previous = editor.getAttributes("link").href as string | undefined;
|
||||||
|
const href = window.prompt("نشانی پیوند", previous ?? "https://")?.trim();
|
||||||
|
if (href === undefined) return;
|
||||||
|
if (!href) {
|
||||||
|
editor.chain().focus().unsetLink().run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
editor.chain().focus().extendMarkRange("link").setLink({ href }).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin rich text control. The value is HTML, sanitized on save.
|
||||||
|
*/
|
||||||
|
export function RichTextField({
|
||||||
|
id,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
}: {
|
||||||
|
id?: string;
|
||||||
|
value: string;
|
||||||
|
onChange: (html: string) => void;
|
||||||
|
}) {
|
||||||
|
const editor = useEditor({
|
||||||
|
immediatelyRender: false,
|
||||||
|
extensions: [
|
||||||
|
StarterKit.configure({
|
||||||
|
heading: { levels: [2, 3, 4] },
|
||||||
|
code: false,
|
||||||
|
codeBlock: false,
|
||||||
|
link: { openOnClick: false, autolink: true },
|
||||||
|
}),
|
||||||
|
Placeholder.configure({ placeholder: "متن را بنویسید…" }),
|
||||||
|
],
|
||||||
|
content: normalizeRichHtml(value) || "",
|
||||||
|
editorProps: {
|
||||||
|
attributes: {
|
||||||
|
dir: "rtl",
|
||||||
|
class:
|
||||||
|
"rich-text-editor min-h-56 px-4 py-3 text-base leading-8 text-foreground outline-none text-justify [&_a]:text-primary [&_a]:underline [&_blockquote]:my-3 [&_blockquote]:border-s-2 [&_blockquote]:border-border [&_blockquote]:ps-3 [&_h2]:mb-2 [&_h2]:text-lg [&_h2]:font-bold [&_h3]:mb-2 [&_h3]:text-base [&_h3]:font-bold [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:ps-5 [&_p]:mb-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:ps-5",
|
||||||
|
...(id ? { id } : {}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onUpdate: ({ editor: current }) => onChange(current.getHTML()),
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!editor || editor.isFocused) return;
|
||||||
|
const next = normalizeRichHtml(value);
|
||||||
|
if (normalizeRichHtml(editor.getHTML()) === next) return;
|
||||||
|
editor.commands.setContent(next || "", { emitUpdate: false });
|
||||||
|
}, [editor, value]);
|
||||||
|
|
||||||
|
const active = useEditorState({
|
||||||
|
editor,
|
||||||
|
selector: ({ editor: current }) => {
|
||||||
|
if (!current) return null;
|
||||||
|
return {
|
||||||
|
bold: current.isActive("bold"),
|
||||||
|
italic: current.isActive("italic"),
|
||||||
|
underline: current.isActive("underline"),
|
||||||
|
strike: current.isActive("strike"),
|
||||||
|
h2: current.isActive("heading", { level: 2 }),
|
||||||
|
h3: current.isActive("heading", { level: 3 }),
|
||||||
|
bullet: current.isActive("bulletList"),
|
||||||
|
ordered: current.isActive("orderedList"),
|
||||||
|
quote: current.isActive("blockquote"),
|
||||||
|
link: current.isActive("link"),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!editor) {
|
||||||
|
return <div className="min-h-56 rounded-xl border border-input bg-card" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div data-no-action-loading className="overflow-hidden rounded-xl border border-input bg-card">
|
||||||
|
<div className="flex flex-wrap items-center gap-1 border-b border-border bg-muted/50 p-2">
|
||||||
|
<ToolbarButton
|
||||||
|
label="ضخیم"
|
||||||
|
pressed={active?.bold}
|
||||||
|
onClick={() => editor.chain().focus().toggleBold().run()}
|
||||||
|
>
|
||||||
|
<Bold />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="مورب"
|
||||||
|
pressed={active?.italic}
|
||||||
|
onClick={() => editor.chain().focus().toggleItalic().run()}
|
||||||
|
>
|
||||||
|
<Italic />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="زیرخط"
|
||||||
|
pressed={active?.underline}
|
||||||
|
onClick={() => editor.chain().focus().toggleUnderline().run()}
|
||||||
|
>
|
||||||
|
<Underline />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="خطخورده"
|
||||||
|
pressed={active?.strike}
|
||||||
|
onClick={() => editor.chain().focus().toggleStrike().run()}
|
||||||
|
>
|
||||||
|
<Strikethrough />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="عنوان"
|
||||||
|
pressed={active?.h2}
|
||||||
|
onClick={() => editor.chain().focus().toggleHeading({ level: 2 }).run()}
|
||||||
|
>
|
||||||
|
<Heading2 />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="زیرعنوان"
|
||||||
|
pressed={active?.h3}
|
||||||
|
onClick={() => editor.chain().focus().toggleHeading({ level: 3 }).run()}
|
||||||
|
>
|
||||||
|
<Heading3 />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="فهرست"
|
||||||
|
pressed={active?.bullet}
|
||||||
|
onClick={() => editor.chain().focus().toggleBulletList().run()}
|
||||||
|
>
|
||||||
|
<List />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="فهرست عددی"
|
||||||
|
pressed={active?.ordered}
|
||||||
|
onClick={() => editor.chain().focus().toggleOrderedList().run()}
|
||||||
|
>
|
||||||
|
<ListOrdered />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="نقلقول"
|
||||||
|
pressed={active?.quote}
|
||||||
|
onClick={() => editor.chain().focus().toggleBlockquote().run()}
|
||||||
|
>
|
||||||
|
<Quote />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton label="خط جداکننده" onClick={() => editor.chain().focus().setHorizontalRule().run()}>
|
||||||
|
<Minus />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton
|
||||||
|
label="پیوند"
|
||||||
|
pressed={active?.link}
|
||||||
|
onClick={() => setLink(editor)}
|
||||||
|
>
|
||||||
|
<Link2 />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton label="بازگشت" onClick={() => editor.chain().focus().undo().run()}>
|
||||||
|
<Undo2 />
|
||||||
|
</ToolbarButton>
|
||||||
|
<ToolbarButton label="ازنو" onClick={() => editor.chain().focus().redo().run()}>
|
||||||
|
<Redo2 />
|
||||||
|
</ToolbarButton>
|
||||||
|
</div>
|
||||||
|
<EditorContent editor={editor} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -19,8 +19,11 @@ import {
|
|||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import type { AdminCourse } from "@/lib/data/admin/courses";
|
import type { AdminCourse } from "@/lib/data/admin/courses";
|
||||||
import type { AdminCourseCategory, AdminCourseTag } from "@/lib/data/admin/taxonomy";
|
import type { AdminCourseCategory, AdminCourseTag } from "@/lib/data/admin/taxonomy";
|
||||||
|
import { JalaliDateField } from "@/components/molecules/JalaliDateField";
|
||||||
import { AdminFormCard } from "@/components/organisms/admin/AdminPage";
|
import { AdminFormCard } from "@/components/organisms/admin/AdminPage";
|
||||||
import { ImageUploadField } from "@/components/organisms/admin/ImageUploadField";
|
import { ImageUploadField } from "@/components/organisms/admin/ImageUploadField";
|
||||||
|
import { RichTextField } from "@/components/organisms/admin/RichTextField";
|
||||||
|
import { htmlToPlain, normalizeRichHtml } from "@/lib/sanitize-html";
|
||||||
|
|
||||||
type FacultyOption = { id: string; name: string; title: string };
|
type FacultyOption = { id: string; name: string; title: string };
|
||||||
|
|
||||||
@@ -32,6 +35,7 @@ type Payload = {
|
|||||||
tagIds: string[];
|
tagIds: string[];
|
||||||
facultyIds: string[];
|
facultyIds: string[];
|
||||||
durationHours: number | null;
|
durationHours: number | null;
|
||||||
|
startDate: string;
|
||||||
format: string;
|
format: string;
|
||||||
price: number | null;
|
price: number | null;
|
||||||
registrationUrl: string;
|
registrationUrl: string;
|
||||||
@@ -72,6 +76,7 @@ export function CourseForm({
|
|||||||
tagIds: initial?.tagIds ?? [],
|
tagIds: initial?.tagIds ?? [],
|
||||||
facultyIds: initial?.facultyIds ?? [],
|
facultyIds: initial?.facultyIds ?? [],
|
||||||
durationHours: initial?.durationHours ?? null,
|
durationHours: initial?.durationHours ?? null,
|
||||||
|
startDate: initial?.startDate ?? "",
|
||||||
format: initial?.format ?? "in-person",
|
format: initial?.format ?? "in-person",
|
||||||
price: initial?.price ?? null,
|
price: initial?.price ?? null,
|
||||||
registrationUrl: initial?.registrationUrl ?? "/register/",
|
registrationUrl: initial?.registrationUrl ?? "/register/",
|
||||||
@@ -107,6 +112,13 @@ export function CourseForm({
|
|||||||
|
|
||||||
async function handleSubmit(e: React.FormEvent) {
|
async function handleSubmit(e: React.FormEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const summary = normalizeRichHtml(form.summary);
|
||||||
|
const leadHtml = normalizeRichHtml(form.leadHtml);
|
||||||
|
const bodyHtml = normalizeRichHtml(form.bodyHtml);
|
||||||
|
if (!htmlToPlain(summary)) {
|
||||||
|
setError("خلاصه کارت الزامی است");
|
||||||
|
return;
|
||||||
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError("");
|
setError("");
|
||||||
try {
|
try {
|
||||||
@@ -115,7 +127,13 @@ export function CourseForm({
|
|||||||
{
|
{
|
||||||
method: isEdit ? "PATCH" : "POST",
|
method: isEdit ? "PATCH" : "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify(form),
|
body: JSON.stringify({
|
||||||
|
...form,
|
||||||
|
summary,
|
||||||
|
leadHtml,
|
||||||
|
bodyHtml,
|
||||||
|
startDate: form.startDate || null,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
@@ -185,39 +203,29 @@ export function CourseForm({
|
|||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5 sm:col-span-2">
|
<div className="space-y-1.5 sm:col-span-2">
|
||||||
<Label htmlFor="summary">خلاصه کارت *</Label>
|
<Label htmlFor="summary">خلاصه کارت *</Label>
|
||||||
<Textarea
|
<RichTextField
|
||||||
id="summary"
|
id="summary"
|
||||||
value={form.summary}
|
value={form.summary}
|
||||||
onChange={(e) => set("summary", e.target.value)}
|
onChange={(html) => set("summary", html)}
|
||||||
required
|
|
||||||
rows={3}
|
|
||||||
/>
|
/>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
متن کوتاه برای کارتهای فهرست؛ آگهی زیر عنوان جداگانه است.
|
متن کوتاه برای کارتهای فهرست؛ آگهی زیر عنوان جداگانه است.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5 sm:col-span-2">
|
<div className="space-y-1.5 sm:col-span-2">
|
||||||
<Label htmlFor="leadHtml">آگهی زیر عنوان (HTML)</Label>
|
<Label htmlFor="leadHtml">آگهی زیر عنوان</Label>
|
||||||
<Textarea
|
<RichTextField
|
||||||
id="leadHtml"
|
id="leadHtml"
|
||||||
value={form.leadHtml}
|
value={form.leadHtml}
|
||||||
onChange={(e) => set("leadHtml", e.target.value)}
|
onChange={(html) => set("leadHtml", html)}
|
||||||
rows={8}
|
|
||||||
className="font-mono text-xs"
|
|
||||||
placeholder="<p><strong>شعار</strong></p><p>متن آگهی…</p>"
|
|
||||||
dir="ltr"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-1.5 sm:col-span-2">
|
<div className="space-y-1.5 sm:col-span-2">
|
||||||
<Label htmlFor="bodyHtml">بدنه دوره (HTML)</Label>
|
<Label htmlFor="bodyHtml">بدنه دوره</Label>
|
||||||
<Textarea
|
<RichTextField
|
||||||
id="bodyHtml"
|
id="bodyHtml"
|
||||||
value={form.bodyHtml}
|
value={form.bodyHtml}
|
||||||
onChange={(e) => set("bodyHtml", e.target.value)}
|
onChange={(html) => set("bodyHtml", html)}
|
||||||
rows={12}
|
|
||||||
className="font-mono text-xs"
|
|
||||||
placeholder="<h2>درباره</h2><p>…</p><h2>سرفصلها</h2><ol><li>…</li></ol>"
|
|
||||||
dir="ltr"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -229,7 +237,7 @@ export function CourseForm({
|
|||||||
<div>
|
<div>
|
||||||
<h2 className="text-sm font-semibold text-foreground">برگزاری و قیمت</h2>
|
<h2 className="text-sm font-semibold text-foreground">برگزاری و قیمت</h2>
|
||||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
<p className="mt-0.5 text-xs text-muted-foreground">
|
||||||
قالب، مدت و هزینه اختیاری
|
قالب، مدت، تاریخ برگزاری و هزینه اختیاری
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-4 sm:grid-cols-3">
|
<div className="grid gap-4 sm:grid-cols-3">
|
||||||
@@ -260,6 +268,14 @@ export function CourseForm({
|
|||||||
placeholder="اختیاری"
|
placeholder="اختیاری"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<Label htmlFor="startDate">تاریخ برگزاری</Label>
|
||||||
|
<JalaliDateField
|
||||||
|
id="startDate"
|
||||||
|
value={form.startDate}
|
||||||
|
onChange={(next) => set("startDate", next)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="space-y-1.5 sm:col-span-3">
|
<div className="space-y-1.5 sm:col-span-3">
|
||||||
<Label htmlFor="price">قیمت (تومان)</Label>
|
<Label htmlFor="price">قیمت (تومان)</Label>
|
||||||
<Input
|
<Input
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import type { AdminCourse } from "@/lib/data/admin/courses";
|
import type { AdminCourse } from "@/lib/data/admin/courses";
|
||||||
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
||||||
|
import { formatPersianDate } from "@/lib/format-date";
|
||||||
import { PublishToggle } from "@/components/organisms/admin/courses/PublishToggle";
|
import { PublishToggle } from "@/components/organisms/admin/courses/PublishToggle";
|
||||||
import { DeleteCourseDialog } from "@/components/organisms/admin/courses/DeleteCourseDialog";
|
import { DeleteCourseDialog } from "@/components/organisms/admin/courses/DeleteCourseDialog";
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ export function CourseTable({ courses }: { courses: AdminCourse[] }) {
|
|||||||
<TableHead>دسته</TableHead>
|
<TableHead>دسته</TableHead>
|
||||||
<TableHead>قالب</TableHead>
|
<TableHead>قالب</TableHead>
|
||||||
<TableHead>مدت (ساعت)</TableHead>
|
<TableHead>مدت (ساعت)</TableHead>
|
||||||
|
<TableHead>برگزاری</TableHead>
|
||||||
<TableHead>قیمت</TableHead>
|
<TableHead>قیمت</TableHead>
|
||||||
<TableHead>ویژه</TableHead>
|
<TableHead>ویژه</TableHead>
|
||||||
<TableHead>ترتیب</TableHead>
|
<TableHead>ترتیب</TableHead>
|
||||||
@@ -79,6 +81,9 @@ export function CourseTable({ courses }: { courses: AdminCourse[] }) {
|
|||||||
<TableCell className="text-muted-foreground">
|
<TableCell className="text-muted-foreground">
|
||||||
{course.durationHours ?? "—"}
|
{course.durationHours ?? "—"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell className="text-muted-foreground">
|
||||||
|
{course.startDate ? formatPersianDate(course.startDate) : "—"}
|
||||||
|
</TableCell>
|
||||||
<TableCell className="text-muted-foreground">
|
<TableCell className="text-muted-foreground">
|
||||||
{formatCoursePrice(course.price) ?? "—"}
|
{formatCoursePrice(course.price) ?? "—"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
@@ -20,16 +20,19 @@ import {
|
|||||||
type GenericFormSpec,
|
type GenericFormSpec,
|
||||||
} from "@/lib/admin/entities";
|
} from "@/lib/admin/entities";
|
||||||
import { AdminFormCard } from "@/components/organisms/admin/AdminPage";
|
import { AdminFormCard } from "@/components/organisms/admin/AdminPage";
|
||||||
|
import { JalaliDateField } from "@/components/molecules/JalaliDateField";
|
||||||
import { ImageUploadField } from "@/components/organisms/admin/ImageUploadField";
|
import { ImageUploadField } from "@/components/organisms/admin/ImageUploadField";
|
||||||
|
import { RichTextField } from "@/components/organisms/admin/RichTextField";
|
||||||
|
import { htmlToPlain, normalizeRichHtml } from "@/lib/sanitize-html";
|
||||||
|
|
||||||
function defaultValue(field: AdminFieldSpec): unknown {
|
function defaultValue(field: AdminFieldSpec): unknown {
|
||||||
if (field.type === "stringList") return [];
|
if (field.type === "stringList" || field.type === "imageList") return [];
|
||||||
if (field.type === "boolean") return Boolean(field.defaultValue ?? false);
|
if (field.type === "boolean") return Boolean(field.defaultValue ?? false);
|
||||||
return field.defaultValue ?? "";
|
return field.defaultValue ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function finalValue(field: AdminFieldSpec, value: unknown): unknown {
|
function finalValue(field: AdminFieldSpec, value: unknown): unknown {
|
||||||
if (field.type === "stringList") {
|
if (field.type === "stringList" || field.type === "imageList") {
|
||||||
return (value as string[]).map((s) => s.trim()).filter(Boolean);
|
return (value as string[]).map((s) => s.trim()).filter(Boolean);
|
||||||
}
|
}
|
||||||
if (field.type === "number") return Number(value);
|
if (field.type === "number") return Number(value);
|
||||||
@@ -93,6 +96,16 @@ export function GenericForm({
|
|||||||
|
|
||||||
const payload: Record<string, unknown> = {};
|
const payload: Record<string, unknown> = {};
|
||||||
for (const field of spec.fields) {
|
for (const field of spec.fields) {
|
||||||
|
if (field.type === "richtext") {
|
||||||
|
const html = normalizeRichHtml(String(form[field.name] ?? ""));
|
||||||
|
if (field.required && !htmlToPlain(html)) {
|
||||||
|
setError(`${field.label} الزامی است`);
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
payload[field.name] = html;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
payload[field.name] = finalValue(field, form[field.name]);
|
payload[field.name] = finalValue(field, form[field.name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,12 +131,20 @@ export function GenericForm({
|
|||||||
const value = form[field.name];
|
const value = form[field.name];
|
||||||
|
|
||||||
switch (field.type) {
|
switch (field.type) {
|
||||||
|
case "richtext":
|
||||||
|
return (
|
||||||
|
<RichTextField
|
||||||
|
id={field.name}
|
||||||
|
value={String(value ?? "")}
|
||||||
|
onChange={(html) => set(field.name, html)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
case "textarea":
|
case "textarea":
|
||||||
return (
|
return (
|
||||||
<Textarea
|
<Textarea
|
||||||
value={String(value ?? "")}
|
value={String(value ?? "")}
|
||||||
onChange={(e) => set(field.name, e.target.value)}
|
onChange={(e) => set(field.name, e.target.value)}
|
||||||
rows={4}
|
rows={field.rows ?? 4}
|
||||||
required={field.required}
|
required={field.required}
|
||||||
placeholder={field.placeholder}
|
placeholder={field.placeholder}
|
||||||
/>
|
/>
|
||||||
@@ -140,11 +161,10 @@ export function GenericForm({
|
|||||||
);
|
);
|
||||||
case "date":
|
case "date":
|
||||||
return (
|
return (
|
||||||
<Input
|
<JalaliDateField
|
||||||
type="date"
|
id={field.name}
|
||||||
value={String(value ?? "")}
|
value={String(value ?? "").slice(0, 10)}
|
||||||
onChange={(e) => set(field.name, e.target.value)}
|
onChange={(next) => set(field.name, next)}
|
||||||
required={field.required}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "select":
|
case "select":
|
||||||
@@ -221,6 +241,33 @@ export function GenericForm({
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
case "imageList":
|
||||||
|
return (
|
||||||
|
<div className="space-y-3">
|
||||||
|
{((value as string[]) ?? []).map((item, index) => (
|
||||||
|
<div key={index} className="space-y-2 rounded-xl border border-border p-3">
|
||||||
|
<ImageUploadField
|
||||||
|
id={`${field.name}-${index}`}
|
||||||
|
value={item}
|
||||||
|
onChange={(url) => setListItem(field.name, index, url)}
|
||||||
|
folder={field.uploadFolder ?? "general"}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => removeListItem(field.name, index)}
|
||||||
|
>
|
||||||
|
حذف
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<Button type="button" variant="outline" size="sm" onClick={() => addListItem(field.name)}>
|
||||||
|
+ تصویر
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<Input
|
<Input
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
|||||||
import { buttonVariants } from "@/components/ui/button";
|
import { buttonVariants } from "@/components/ui/button";
|
||||||
import { aboutContent } from "@/lib/site-config";
|
import { aboutContent } from "@/lib/site-config";
|
||||||
import type { IntersectionTopic } from "@/lib/types";
|
import type { IntersectionTopic } from "@/lib/types";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
function ProseBlock({ paragraphs }: { paragraphs: string[] }) {
|
function ProseBlock({ paragraphs }: { paragraphs: string[] }) {
|
||||||
@@ -18,7 +19,7 @@ function ProseBlock({ paragraphs }: { paragraphs: string[] }) {
|
|||||||
{paragraphs.map((paragraph, index) => (
|
{paragraphs.map((paragraph, index) => (
|
||||||
<p
|
<p
|
||||||
key={index}
|
key={index}
|
||||||
className="text-base leading-7 text-muted-foreground sm:text-lg sm:leading-8"
|
className="text-justify text-base leading-7 text-muted-foreground sm:text-lg sm:leading-8"
|
||||||
>
|
>
|
||||||
{paragraph}
|
{paragraph}
|
||||||
</p>
|
</p>
|
||||||
@@ -41,7 +42,7 @@ export function AboutTemplate({ topics }: { topics: IntersectionTopic[] }) {
|
|||||||
|
|
||||||
<Section tone="subtle">
|
<Section tone="subtle">
|
||||||
<Container>
|
<Container>
|
||||||
<p className="max-w-3xl text-base leading-7 text-foreground sm:text-lg sm:leading-8">
|
<p className="max-w-3xl text-justify text-base leading-7 text-foreground sm:text-lg sm:leading-8">
|
||||||
{aboutContent.introFollowUp}
|
{aboutContent.introFollowUp}
|
||||||
</p>
|
</p>
|
||||||
</Container>
|
</Container>
|
||||||
@@ -98,14 +99,14 @@ export function AboutTemplate({ topics }: { topics: IntersectionTopic[] }) {
|
|||||||
</Heading>
|
</Heading>
|
||||||
<ArrowUpLeft className="mt-1 size-4 shrink-0 text-muted-foreground transition-colors group-hover:text-primary" />
|
<ArrowUpLeft className="mt-1 size-4 shrink-0 text-muted-foreground transition-colors group-hover:text-primary" />
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-2 text-sm leading-7 text-muted-foreground">
|
<p className="mt-2 text-justify text-sm leading-7 text-muted-foreground">
|
||||||
{topic.description}
|
{htmlToPlain(topic.description)}
|
||||||
</p>
|
</p>
|
||||||
</SurfaceCard>
|
</SurfaceCard>
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-6 max-w-3xl text-sm leading-7 text-muted-foreground">
|
<p className="mt-6 max-w-3xl text-justify text-sm leading-7 text-muted-foreground">
|
||||||
{topicsCopy.note}
|
{topicsCopy.note}
|
||||||
</p>
|
</p>
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Clock, Layers, Wallet } from "lucide-react";
|
import { Clock, CalendarDays, Layers, Wallet } from "lucide-react";
|
||||||
import { Container } from "@/components/atoms/Container";
|
import { Container } from "@/components/atoms/Container";
|
||||||
import { Heading } from "@/components/atoms/Heading";
|
import { Heading } from "@/components/atoms/Heading";
|
||||||
import { Section } from "@/components/atoms/Section";
|
import { Section } from "@/components/atoms/Section";
|
||||||
@@ -11,9 +11,11 @@ import { RichHtmlContent } from "@/components/molecules/RichHtmlContent";
|
|||||||
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
|
||||||
import { CourseRegisterGate } from "@/components/organisms/CourseRegisterGate";
|
import { CourseRegisterGate } from "@/components/organisms/CourseRegisterGate";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import type { Course } from "@/lib/types";
|
import type { Course } from "@/lib/types";
|
||||||
import { courseCategoryHref, courseTagHref } from "@/lib/course-nav";
|
import { courseCategoryHref, courseTagHref } from "@/lib/course-nav";
|
||||||
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
||||||
|
import { formatPersianDate } from "@/lib/format-date";
|
||||||
import { JsonLd, courseJsonLd } from "@/lib/seo/json-ld";
|
import { JsonLd, courseJsonLd } from "@/lib/seo/json-ld";
|
||||||
|
|
||||||
/** Portrait brochure delivery assets (~A4). */
|
/** Portrait brochure delivery assets (~A4). */
|
||||||
@@ -31,6 +33,7 @@ export type CourseDetailLabels = {
|
|||||||
detailsTitle: string;
|
detailsTitle: string;
|
||||||
aboutTitle: string;
|
aboutTitle: string;
|
||||||
duration: string;
|
duration: string;
|
||||||
|
date: string;
|
||||||
format: string;
|
format: string;
|
||||||
category: string;
|
category: string;
|
||||||
price: string;
|
price: string;
|
||||||
@@ -56,6 +59,15 @@ export function CourseDetailTemplate({
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
|
...(course.startDate
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
icon: CalendarDays,
|
||||||
|
label: labels.date,
|
||||||
|
value: formatPersianDate(course.startDate),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
{
|
{
|
||||||
icon: Wallet,
|
icon: Wallet,
|
||||||
label: labels.price,
|
label: labels.price,
|
||||||
@@ -70,7 +82,7 @@ export function CourseDetailTemplate({
|
|||||||
const heroIntro = leadHtml ? (
|
const heroIntro = leadHtml ? (
|
||||||
<RichHtmlContent html={leadHtml} tone="onPrimary" />
|
<RichHtmlContent html={leadHtml} tone="onPrimary" />
|
||||||
) : (
|
) : (
|
||||||
course.summary
|
htmlToPlain(course.summary)
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -103,7 +115,7 @@ export function CourseDetailTemplate({
|
|||||||
{bodyHtml ? (
|
{bodyHtml ? (
|
||||||
<RichHtmlContent html={bodyHtml} />
|
<RichHtmlContent html={bodyHtml} />
|
||||||
) : (
|
) : (
|
||||||
<p className="text-base leading-7 text-foreground/90">
|
<p className="text-justify text-base leading-7 text-foreground/90">
|
||||||
{course.seoDescription}
|
{course.seoDescription}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@/components/ui/card";
|
} from "@/components/ui/card";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { CourseCardBanner } from "@/components/molecules/CourseCardBanner";
|
import { CourseCardBanner } from "@/components/molecules/CourseCardBanner";
|
||||||
import { HeroFeatured } from "@/components/molecules/HeroFeatured";
|
import { HeroFeatured } from "@/components/molecules/HeroFeatured";
|
||||||
@@ -21,6 +22,7 @@ import { SectionHeader } from "@/components/molecules/SectionHeader";
|
|||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import type { Article, Course } from "@/lib/types";
|
import type { Article, Course } from "@/lib/types";
|
||||||
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
import { formatCoursePrice, formatLabel } from "@/lib/labels";
|
||||||
|
import { formatCourseScheduleLine } from "@/lib/format-date";
|
||||||
import { homeContent } from "@/lib/site-config";
|
import { homeContent } from "@/lib/site-config";
|
||||||
|
|
||||||
const whyIcons = [Compass, BookOpen, Building2] as const;
|
const whyIcons = [Compass, BookOpen, Building2] as const;
|
||||||
@@ -86,7 +88,7 @@ export function HomeIdeas() {
|
|||||||
<Heading as="h3" level={3}>
|
<Heading as="h3" level={3}>
|
||||||
{item.title}
|
{item.title}
|
||||||
</Heading>
|
</Heading>
|
||||||
<p className="mt-2 text-base leading-7 text-muted-foreground">
|
<p className="mt-2 text-justify text-base leading-7 text-muted-foreground">
|
||||||
{item.text}
|
{item.text}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -126,6 +128,7 @@ export function HomeCourseSearch({
|
|||||||
<div className="grid gap-5 sm:grid-cols-2 lg:grid-cols-3">
|
<div className="grid gap-5 sm:grid-cols-2 lg:grid-cols-3">
|
||||||
{courses.map((course) => {
|
{courses.map((course) => {
|
||||||
const priceLabel = formatCoursePrice(course.price);
|
const priceLabel = formatCoursePrice(course.price);
|
||||||
|
const schedule = formatCourseScheduleLine(course);
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={course.id}
|
key={course.id}
|
||||||
@@ -157,7 +160,7 @@ export function HomeCourseSearch({
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="pointer-events-none relative z-[1] space-y-3 px-4 pb-4">
|
<CardContent className="pointer-events-none relative z-[1] space-y-3 px-4 pb-4">
|
||||||
<CardDescription className="line-clamp-2 text-primary-foreground/70">
|
<CardDescription className="line-clamp-2 text-primary-foreground/70">
|
||||||
{course.summary}
|
{htmlToPlain(course.summary)}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-primary-foreground/55">
|
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-primary-foreground/55">
|
||||||
<span>
|
<span>
|
||||||
@@ -171,6 +174,9 @@ export function HomeCourseSearch({
|
|||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
{schedule ? (
|
||||||
|
<p className="text-xs text-primary-foreground/70">برگزاری {schedule}</p>
|
||||||
|
) : null}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
@@ -238,28 +244,6 @@ export function HomeApproach() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HomeEventsTeaser() {
|
|
||||||
const { events } = homeContent;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Section>
|
|
||||||
<Container>
|
|
||||||
<div className="grid min-w-0 gap-8 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end lg:gap-12">
|
|
||||||
<SectionHeader
|
|
||||||
className="mb-0 sm:mb-0"
|
|
||||||
eyebrow={events.eyebrow}
|
|
||||||
title={events.title}
|
|
||||||
description={events.description}
|
|
||||||
/>
|
|
||||||
<div className="shrink-0">
|
|
||||||
<DotCta href="/events">{events.ctaLabel}</DotCta>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Container>
|
|
||||||
</Section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function HomeTeams() {
|
export function HomeTeams() {
|
||||||
const { teams } = homeContent;
|
const { teams } = homeContent;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import Link from "next/link";
|
||||||
|
import { Container } from "@/components/atoms/Container";
|
||||||
|
import { Heading } from "@/components/atoms/Heading";
|
||||||
|
import { Section } from "@/components/atoms/Section";
|
||||||
|
import { RichHtmlContent } from "@/components/molecules/RichHtmlContent";
|
||||||
|
import { NewsPhotoLayout } from "@/components/organisms/NewsPhotoLayout";
|
||||||
|
import { JsonLd, newsJsonLd } from "@/lib/seo/json-ld";
|
||||||
|
import { formatPersianDate } from "@/lib/format-date";
|
||||||
|
import { normalizeRichHtml } from "@/lib/sanitize-html";
|
||||||
|
import type { NewsItem } from "@/lib/types";
|
||||||
|
|
||||||
|
export function NewsDetailTemplate({ item }: { item: NewsItem }) {
|
||||||
|
return (
|
||||||
|
<Section>
|
||||||
|
<JsonLd data={newsJsonLd(item)} />
|
||||||
|
<Container>
|
||||||
|
<Link href="/news" className="text-sm font-medium text-accent hover:underline">
|
||||||
|
اخبار
|
||||||
|
</Link>
|
||||||
|
<Heading as="h1" level={1} className="mt-4 max-w-4xl">
|
||||||
|
{item.title}
|
||||||
|
</Heading>
|
||||||
|
<p className="mt-3 text-sm text-muted-foreground">{formatPersianDate(item.publishedAt)}</p>
|
||||||
|
|
||||||
|
<NewsPhotoLayout
|
||||||
|
title={item.title}
|
||||||
|
banner={item.bannerImageUrl}
|
||||||
|
gallery={item.galleryImages}
|
||||||
|
>
|
||||||
|
<article>
|
||||||
|
<RichHtmlContent html={normalizeRichHtml(item.body)} className="text-base leading-8 text-foreground" />
|
||||||
|
</article>
|
||||||
|
</NewsPhotoLayout>
|
||||||
|
</Container>
|
||||||
|
</Section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { Container } from "@/components/atoms/Container";
|
||||||
|
import { Section } from "@/components/atoms/Section";
|
||||||
|
import { NewsCard } from "@/components/molecules/NewsCard";
|
||||||
|
import { PageHero } from "@/components/molecules/PageHero";
|
||||||
|
import type { NewsItem } from "@/lib/types";
|
||||||
|
|
||||||
|
export function NewsListTemplate({
|
||||||
|
items,
|
||||||
|
title,
|
||||||
|
intro,
|
||||||
|
emptyLabel,
|
||||||
|
}: {
|
||||||
|
items: NewsItem[];
|
||||||
|
title: string;
|
||||||
|
intro: string;
|
||||||
|
emptyLabel: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageHero eyebrow="مرکز آموزش های آزاد" title={title} intro={intro} />
|
||||||
|
<Section>
|
||||||
|
<Container>
|
||||||
|
{items.length === 0 ? (
|
||||||
|
<p className="text-base leading-8 text-muted-foreground">{emptyLabel}</p>
|
||||||
|
) : (
|
||||||
|
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||||
|
{items.map((item) => (
|
||||||
|
<li key={item.id}>
|
||||||
|
<NewsCard item={item} />
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</Container>
|
||||||
|
</Section>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,12 +6,14 @@ import { errorResponse } from "@/lib/api/response";
|
|||||||
*
|
*
|
||||||
* Matches public-site temporary hide: articles (insights), events, alumni,
|
* Matches public-site temporary hide: articles (insights), events, alumni,
|
||||||
* testimonials (نظر شرکت کنندگان).
|
* testimonials (نظر شرکت کنندگان).
|
||||||
|
* Programs are not a separate offering — any length of study is a course.
|
||||||
*/
|
*/
|
||||||
export const DISABLED_ADMIN_ENTITIES = new Set([
|
export const DISABLED_ADMIN_ENTITIES = new Set([
|
||||||
"articles",
|
"articles",
|
||||||
"events",
|
"events",
|
||||||
"alumni",
|
"alumni",
|
||||||
"testimonials",
|
"testimonials",
|
||||||
|
"programs",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export function isAdminEntityEnabled(key: string): boolean {
|
export function isAdminEntityEnabled(key: string): boolean {
|
||||||
|
|||||||
+65
-12
@@ -10,6 +10,7 @@ import {
|
|||||||
getAdminEventById,
|
getAdminEventById,
|
||||||
getAdminFacultyById,
|
getAdminFacultyById,
|
||||||
getAdminLegalBySlug,
|
getAdminLegalBySlug,
|
||||||
|
getAdminNewsById,
|
||||||
getAdminProgramById,
|
getAdminProgramById,
|
||||||
getAdminStatById,
|
getAdminStatById,
|
||||||
getAdminTestimonialById,
|
getAdminTestimonialById,
|
||||||
@@ -20,6 +21,7 @@ import {
|
|||||||
listAdminEvents,
|
listAdminEvents,
|
||||||
listAdminFaculty,
|
listAdminFaculty,
|
||||||
listAdminLegal,
|
listAdminLegal,
|
||||||
|
listAdminNews,
|
||||||
listAdminPrograms,
|
listAdminPrograms,
|
||||||
listAdminStats,
|
listAdminStats,
|
||||||
listAdminTestimonials,
|
listAdminTestimonials,
|
||||||
@@ -40,7 +42,9 @@ export type AdminFieldType =
|
|||||||
| "select"
|
| "select"
|
||||||
| "boolean"
|
| "boolean"
|
||||||
| "stringList"
|
| "stringList"
|
||||||
| "image";
|
| "image"
|
||||||
|
| "imageList"
|
||||||
|
| "richtext";
|
||||||
|
|
||||||
export interface AdminSelectOption {
|
export interface AdminSelectOption {
|
||||||
value: string;
|
value: string;
|
||||||
@@ -57,10 +61,13 @@ export interface AdminFieldSpec {
|
|||||||
defaultValue?: unknown;
|
defaultValue?: unknown;
|
||||||
/** spans the full form row instead of one column of a 2-col grid */
|
/** spans the full form row instead of one column of a 2-col grid */
|
||||||
full?: boolean;
|
full?: boolean;
|
||||||
|
/** textarea row count */
|
||||||
|
rows?: number;
|
||||||
/** upload subfolder under /uploads (image fields only) */
|
/** upload subfolder under /uploads (image fields only) */
|
||||||
uploadFolder?:
|
uploadFolder?:
|
||||||
| "courses"
|
| "courses"
|
||||||
| "articles"
|
| "articles"
|
||||||
|
| "news"
|
||||||
| "topics"
|
| "topics"
|
||||||
| "faculty"
|
| "faculty"
|
||||||
| "alumni"
|
| "alumni"
|
||||||
@@ -139,7 +146,7 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
},
|
},
|
||||||
{ name: "author", label: "نویسنده", type: "text", required: true },
|
{ name: "author", label: "نویسنده", type: "text", required: true },
|
||||||
{ name: "publishedAt", label: "تاریخ انتشار", type: "date", required: true },
|
{ name: "publishedAt", label: "تاریخ انتشار", type: "date", required: true },
|
||||||
{ name: "excerpt", label: "خلاصه", type: "textarea", required: true, full: true },
|
{ name: "excerpt", label: "خلاصه", type: "richtext", required: true, full: true },
|
||||||
{
|
{
|
||||||
name: "imageUrl",
|
name: "imageUrl",
|
||||||
label: "تصویر",
|
label: "تصویر",
|
||||||
@@ -150,7 +157,7 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
},
|
},
|
||||||
{ name: "href", label: "لینک کامل", type: "text", placeholder: "/insights/..." },
|
{ name: "href", label: "لینک کامل", type: "text", placeholder: "/insights/..." },
|
||||||
{ name: "featured", label: "مقاله ویژه", type: "boolean", options: yesNo, defaultValue: false },
|
{ name: "featured", label: "مقاله ویژه", type: "boolean", options: yesNo, defaultValue: false },
|
||||||
{ name: "body", label: "متن مقاله", type: "textarea", required: true, full: true },
|
{ name: "body", label: "متن مقاله", type: "richtext", required: true, full: true },
|
||||||
publishedField,
|
publishedField,
|
||||||
],
|
],
|
||||||
columns: [
|
columns: [
|
||||||
@@ -164,6 +171,52 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
get: getAdminArticleById,
|
get: getAdminArticleById,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
news: {
|
||||||
|
key: "news",
|
||||||
|
navLabel: "اخبار",
|
||||||
|
noun: "خبر",
|
||||||
|
apiPath: "/api/admin/news",
|
||||||
|
idColumn: "id",
|
||||||
|
searchCols: ["title", "body"],
|
||||||
|
searchHint: "عنوان یا متن",
|
||||||
|
hasPublished: true,
|
||||||
|
preview: (r) => `/news/${r.id}`,
|
||||||
|
fields: [
|
||||||
|
{ name: "title", label: "عنوان", type: "text", required: true, full: true },
|
||||||
|
{ name: "publishedAt", label: "تاریخ انتشار", type: "date", required: true },
|
||||||
|
{
|
||||||
|
name: "bannerImageUrl",
|
||||||
|
label: "تصویر بنر",
|
||||||
|
type: "image",
|
||||||
|
required: true,
|
||||||
|
uploadFolder: "news",
|
||||||
|
full: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "body",
|
||||||
|
label: "متن خبر",
|
||||||
|
type: "richtext",
|
||||||
|
required: true,
|
||||||
|
full: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "galleryImages",
|
||||||
|
label: "تصاویر اضافی",
|
||||||
|
type: "imageList",
|
||||||
|
uploadFolder: "news",
|
||||||
|
full: true,
|
||||||
|
},
|
||||||
|
publishedField,
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
{ name: "title", label: "عنوان" },
|
||||||
|
{ name: "publishedAt", label: "تاریخ", variant: "date" },
|
||||||
|
publishedCol,
|
||||||
|
],
|
||||||
|
list: listAdminNews,
|
||||||
|
get: getAdminNewsById,
|
||||||
|
},
|
||||||
|
|
||||||
programs: {
|
programs: {
|
||||||
key: "programs",
|
key: "programs",
|
||||||
navLabel: "برنامه ها",
|
navLabel: "برنامه ها",
|
||||||
@@ -192,9 +245,9 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
{ name: "tagline", label: "تگلاین", type: "text" },
|
{ name: "tagline", label: "تگلاین", type: "text" },
|
||||||
{ name: "audience", label: "مخاطبان", type: "text", required: true },
|
{ name: "audience", label: "مخاطبان", type: "text", required: true },
|
||||||
{ name: "href", label: "لینک", type: "text", placeholder: "/programs/..." },
|
{ name: "href", label: "لینک", type: "text", placeholder: "/programs/..." },
|
||||||
{ name: "blurb", label: "معرفی کوتاه", type: "textarea", required: true, full: true },
|
{ name: "blurb", label: "معرفی کوتاه", type: "richtext", required: true, full: true },
|
||||||
{ name: "highlights", label: "نکات برجسته", type: "stringList", full: true },
|
{ name: "highlights", label: "نکات برجسته", type: "stringList", full: true },
|
||||||
{ name: "body", label: "متن کامل", type: "textarea", required: true, full: true },
|
{ name: "body", label: "متن کامل", type: "richtext", required: true, full: true },
|
||||||
publishedField,
|
publishedField,
|
||||||
],
|
],
|
||||||
columns: [
|
columns: [
|
||||||
@@ -223,7 +276,7 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
{ name: "endDate", label: "تاریخ پایان (اختیاری)", type: "date" },
|
{ name: "endDate", label: "تاریخ پایان (اختیاری)", type: "date" },
|
||||||
{ name: "location", label: "محل برگزاری", type: "text", required: true },
|
{ name: "location", label: "محل برگزاری", type: "text", required: true },
|
||||||
{ name: "href", label: "لینک", type: "text", placeholder: "/events/..." },
|
{ name: "href", label: "لینک", type: "text", placeholder: "/events/..." },
|
||||||
{ name: "summary", label: "خلاصه", type: "textarea", required: true, full: true },
|
{ name: "summary", label: "خلاصه", type: "richtext", required: true, full: true },
|
||||||
publishedField,
|
publishedField,
|
||||||
],
|
],
|
||||||
columns: [
|
columns: [
|
||||||
@@ -258,9 +311,9 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
uploadFolder: "topics",
|
uploadFolder: "topics",
|
||||||
full: true,
|
full: true,
|
||||||
},
|
},
|
||||||
{ name: "description", label: "توضیح", type: "textarea", required: true, full: true },
|
{ name: "description", label: "توضیح", type: "richtext", required: true, full: true },
|
||||||
{ name: "highlights", label: "نکات برجسته", type: "stringList", full: true },
|
{ name: "highlights", label: "نکات برجسته", type: "stringList", full: true },
|
||||||
{ name: "body", label: "متن کامل", type: "textarea", required: true, full: true },
|
{ name: "body", label: "متن کامل", type: "richtext", required: true, full: true },
|
||||||
publishedField,
|
publishedField,
|
||||||
],
|
],
|
||||||
columns: [
|
columns: [
|
||||||
@@ -304,7 +357,7 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
placeholder: "https://mst.aut.ac.ir/...",
|
placeholder: "https://mst.aut.ac.ir/...",
|
||||||
full: true,
|
full: true,
|
||||||
},
|
},
|
||||||
{ name: "bio", label: "بیوگرافی", type: "textarea", required: true, full: true },
|
{ name: "bio", label: "بیوگرافی", type: "richtext", required: true, full: true },
|
||||||
publishedField,
|
publishedField,
|
||||||
],
|
],
|
||||||
columns: [
|
columns: [
|
||||||
@@ -338,7 +391,7 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
full: true,
|
full: true,
|
||||||
},
|
},
|
||||||
{ name: "href", label: "لینک", type: "text", placeholder: "/alumni/..." },
|
{ name: "href", label: "لینک", type: "text", placeholder: "/alumni/..." },
|
||||||
{ name: "excerpt", label: "خلاصه", type: "textarea", required: true, full: true },
|
{ name: "excerpt", label: "خلاصه", type: "richtext", required: true, full: true },
|
||||||
publishedField,
|
publishedField,
|
||||||
],
|
],
|
||||||
columns: [
|
columns: [
|
||||||
@@ -364,7 +417,7 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
{ name: "version", label: "نسخه", type: "text", required: true, placeholder: "مثلا autumn-2025" },
|
{ name: "version", label: "نسخه", type: "text", required: true, placeholder: "مثلا autumn-2025" },
|
||||||
{ name: "cta", label: "دکمه", type: "text", required: true },
|
{ name: "cta", label: "دکمه", type: "text", required: true },
|
||||||
{ name: "href", label: "لینک", type: "text", required: true, placeholder: "/register/..." },
|
{ name: "href", label: "لینک", type: "text", required: true, placeholder: "/register/..." },
|
||||||
{ name: "text", label: "متن بنر", type: "textarea", required: true, full: true },
|
{ name: "text", label: "متن بنر", type: "richtext", required: true, full: true },
|
||||||
publishedField,
|
publishedField,
|
||||||
],
|
],
|
||||||
columns: [
|
columns: [
|
||||||
@@ -434,7 +487,7 @@ export const ENTITIES: Record<string, AdminEntitySpec> = {
|
|||||||
searchHint: "نام یا متن",
|
searchHint: "نام یا متن",
|
||||||
hasPublished: true,
|
hasPublished: true,
|
||||||
fields: [
|
fields: [
|
||||||
{ name: "quote", label: "متن نظر", type: "textarea", required: true, full: true },
|
{ name: "quote", label: "متن نظر", type: "richtext", required: true, full: true },
|
||||||
{ name: "name", label: "نام", type: "text", required: true },
|
{ name: "name", label: "نام", type: "text", required: true },
|
||||||
{ name: "role", label: "سمت", type: "text", required: true },
|
{ name: "role", label: "سمت", type: "text", required: true },
|
||||||
{ name: "courseTitle", label: "عنوان دوره", type: "text", required: true },
|
{ name: "courseTitle", label: "عنوان دوره", type: "text", required: true },
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export function buildHomeNavWithCourseTags(
|
|||||||
children: buildCourseNavChildren(tags),
|
children: buildCourseNavChildren(tags),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Insert courses before «درباره ما» so order is: … → دوره ها → درباره ما
|
// Insert courses before «درباره ما» so order is: … → دوره ها → درباره ما → دانشکده
|
||||||
const insertAt = homeNav.findIndex((item) => item.href === "/about");
|
const insertAt = homeNav.findIndex((item) => item.href === "/about");
|
||||||
if (insertAt === -1) {
|
if (insertAt === -1) {
|
||||||
return [...homeNav, coursesItem];
|
return [...homeNav, coursesItem];
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
rowToFacultyMember,
|
rowToFacultyMember,
|
||||||
rowToIntersectionTopic,
|
rowToIntersectionTopic,
|
||||||
rowToLegalPage,
|
rowToLegalPage,
|
||||||
|
rowToNews,
|
||||||
rowToProgram,
|
rowToProgram,
|
||||||
rowToSiteStat,
|
rowToSiteStat,
|
||||||
rowToTestimonial,
|
rowToTestimonial,
|
||||||
@@ -38,6 +39,20 @@ export function getAdminArticleById(id: string) {
|
|||||||
return getContentRow("articles", "id", id, withPublished(rowToArticle ));
|
return getContentRow("articles", "id", id, withPublished(rowToArticle ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listAdminNews(opts?: AdminListOpts) {
|
||||||
|
return listContentRows(
|
||||||
|
"news_items",
|
||||||
|
["title", "body"],
|
||||||
|
withPublished(rowToNews),
|
||||||
|
opts,
|
||||||
|
"published_at DESC",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAdminNewsById(id: string) {
|
||||||
|
return getContentRow("news_items", "id", id, withPublished(rowToNews));
|
||||||
|
}
|
||||||
|
|
||||||
export function listAdminPrograms(opts?: AdminListOpts) {
|
export function listAdminPrograms(opts?: AdminListOpts) {
|
||||||
return listContentRows(
|
return listContentRows(
|
||||||
"programs",
|
"programs",
|
||||||
|
|||||||
@@ -15,6 +15,22 @@ const catalogOrderSql = `CASE WHEN ${isArchiveCourseSql} THEN 1 ELSE 0 END ASC,
|
|||||||
c.sort_order ASC,
|
c.sort_order ASC,
|
||||||
c.title ASC`;
|
c.title ASC`;
|
||||||
|
|
||||||
|
/** Published course URLs for the sitemap, including archived offerings. */
|
||||||
|
export async function getCoursesForSitemap(): Promise<
|
||||||
|
{ slug: string; updatedAt: Date }[]
|
||||||
|
> {
|
||||||
|
const res = await query<{ slug: string; updated_at: Date }>(
|
||||||
|
`SELECT c.slug, c.updated_at
|
||||||
|
FROM courses c
|
||||||
|
WHERE c.published = true AND c.slug <> ''
|
||||||
|
ORDER BY c.updated_at DESC`,
|
||||||
|
);
|
||||||
|
return res.rows.map((row) => ({
|
||||||
|
slug: row.slug,
|
||||||
|
updatedAt: row.updated_at,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
export async function getCourses(): Promise<Course[]> {
|
export async function getCourses(): Promise<Course[]> {
|
||||||
const res = await query<CourseRow>(
|
const res = await query<CourseRow>(
|
||||||
`${COURSE_WITH_TAXONOMY_SELECT}
|
`${COURSE_WITH_TAXONOMY_SELECT}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { query } from "@/lib/db";
|
||||||
|
import { rowToNews, type NewsRow } from "@/lib/db/mappers";
|
||||||
|
import { htmlToPlain } from "@/lib/html-text";
|
||||||
|
import type { NewsItem } from "@/lib/types";
|
||||||
|
|
||||||
|
/** Published news URLs for the sitemap. `updated_at` is the last content change. */
|
||||||
|
export async function getNewsForSitemap(): Promise<
|
||||||
|
{ id: string; updatedAt: Date }[]
|
||||||
|
> {
|
||||||
|
const res = await query<{ id: string; updated_at: Date }>(
|
||||||
|
`SELECT id, updated_at
|
||||||
|
FROM news_items
|
||||||
|
WHERE published = true
|
||||||
|
ORDER BY published_at DESC, created_at DESC`,
|
||||||
|
);
|
||||||
|
return res.rows.map((row) => ({
|
||||||
|
id: row.id,
|
||||||
|
updatedAt: row.updated_at,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getNews(): Promise<NewsItem[]> {
|
||||||
|
const res = await query<NewsRow>(
|
||||||
|
`SELECT * FROM news_items
|
||||||
|
WHERE published = true
|
||||||
|
ORDER BY published_at DESC, created_at DESC`,
|
||||||
|
);
|
||||||
|
return res.rows.map(rowToNews);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getNewsById(id: string): Promise<NewsItem | null> {
|
||||||
|
const res = await query<NewsRow>(
|
||||||
|
`SELECT * FROM news_items WHERE published = true AND id = $1 LIMIT 1`,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
|
return res.rows[0] ? rowToNews(res.rows[0]) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One-line preview for cards and meta descriptions. */
|
||||||
|
export function newsExcerpt(body: string, max = 180): string {
|
||||||
|
const flat = htmlToPlain(body);
|
||||||
|
if (flat.length <= max) return flat;
|
||||||
|
const slice = flat.slice(0, max);
|
||||||
|
const lastSpace = slice.lastIndexOf(" ");
|
||||||
|
const cut = lastSpace > 40 ? slice.slice(0, lastSpace) : slice;
|
||||||
|
return `${cut}…`;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import type {
|
|||||||
AlumniStory,
|
AlumniStory,
|
||||||
Article,
|
Article,
|
||||||
CampaignBanner,
|
CampaignBanner,
|
||||||
|
NewsItem,
|
||||||
Course,
|
Course,
|
||||||
EventItem,
|
EventItem,
|
||||||
FacultyMember,
|
FacultyMember,
|
||||||
@@ -44,6 +45,7 @@ export interface CourseRow {
|
|||||||
title: string;
|
title: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
duration_hours: number | null;
|
duration_hours: number | null;
|
||||||
|
start_date?: DateField | null;
|
||||||
format: string;
|
format: string;
|
||||||
price: string | number | null;
|
price: string | number | null;
|
||||||
registration_url: string;
|
registration_url: string;
|
||||||
@@ -383,6 +385,7 @@ export function rowToCourse(row: CourseRow): Course {
|
|||||||
tags: asTaxonomyRefs(row.tags),
|
tags: asTaxonomyRefs(row.tags),
|
||||||
instructors: asFacultyRefs(row.instructors),
|
instructors: asFacultyRefs(row.instructors),
|
||||||
durationHours: row.duration_hours,
|
durationHours: row.duration_hours,
|
||||||
|
startDate: row.start_date ? fmtDate(row.start_date) : null,
|
||||||
format: row.format as Course["format"],
|
format: row.format as Course["format"],
|
||||||
price: Number.isFinite(price) ? price : null,
|
price: Number.isFinite(price) ? price : null,
|
||||||
registrationUrl: row.registration_url,
|
registrationUrl: row.registration_url,
|
||||||
@@ -518,4 +521,25 @@ export function rowToTestimonial(row: TestimonialRow): Testimonial {
|
|||||||
role: row.role,
|
role: row.role,
|
||||||
courseTitle: row.course_title,
|
courseTitle: row.course_title,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NewsRow {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
banner_image_url: string;
|
||||||
|
body: string;
|
||||||
|
gallery_images: unknown;
|
||||||
|
published_at: DateField;
|
||||||
|
published: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rowToNews(row: NewsRow): NewsItem {
|
||||||
|
return {
|
||||||
|
id: row.id,
|
||||||
|
title: row.title,
|
||||||
|
bannerImageUrl: row.banner_image_url,
|
||||||
|
body: row.body,
|
||||||
|
galleryImages: asStringArray(row.gallery_images),
|
||||||
|
publishedAt: fmtDate(row.published_at),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { formatJalaliDate } from "@/lib/jalali";
|
||||||
|
|
||||||
|
/** Format a stored Gregorian `YYYY-MM-DD` as a Shamsi date, without a UTC day-shift. */
|
||||||
|
export function formatPersianDate(isoDate: string): string {
|
||||||
|
return formatJalaliDate(isoDate) ?? isoDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Persian card line for when a course starts being held. */
|
||||||
|
export function formatCourseScheduleLine(course: {
|
||||||
|
startDate?: string | null;
|
||||||
|
}): string | null {
|
||||||
|
return course.startDate ? formatPersianDate(course.startDate) : null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/** Visible text of stored HTML, without pulling in the sanitizer. */
|
||||||
|
export function htmlToPlain(value: string): string {
|
||||||
|
return value
|
||||||
|
.replace(/<br\s*\/?>/gi, " ")
|
||||||
|
.replace(/<\/(p|div|h2|h3|h4|li|blockquote)>/gi, " ")
|
||||||
|
.replace(/<[^>]+>/g, "")
|
||||||
|
.replace(/ /g, " ")
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/\s+/g, " ")
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import {
|
||||||
|
jalaaliMonthLength,
|
||||||
|
jalaaliToDateObject,
|
||||||
|
toGregorian,
|
||||||
|
toJalaali,
|
||||||
|
type JalaaliDate,
|
||||||
|
} from "jalaali-js";
|
||||||
|
|
||||||
|
export const JALALI_MONTHS = [
|
||||||
|
"فروردین",
|
||||||
|
"اردیبهشت",
|
||||||
|
"خرداد",
|
||||||
|
"تیر",
|
||||||
|
"مرداد",
|
||||||
|
"شهریور",
|
||||||
|
"مهر",
|
||||||
|
"آبان",
|
||||||
|
"آذر",
|
||||||
|
"دی",
|
||||||
|
"بهمن",
|
||||||
|
"اسفند",
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
/** Saturday-first, matching the Iranian week. */
|
||||||
|
export const JALALI_WEEKDAYS = ["ش", "ی", "د", "س", "چ", "پ", "ج"] as const;
|
||||||
|
|
||||||
|
const PERSIAN_DIGITS = "۰۱۲۳۴۵۶۷۸۹";
|
||||||
|
|
||||||
|
export function toPersianDigits(value: number | string): string {
|
||||||
|
return String(value).replace(/\d/g, (digit) => PERSIAN_DIGITS[Number(digit)] ?? digit);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pad(value: number): string {
|
||||||
|
return String(value).padStart(2, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Parse a stored `YYYY-MM-DD` (Gregorian) into a Jalaali date. */
|
||||||
|
export function isoToJalali(isoDate: string): JalaaliDate | null {
|
||||||
|
const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(isoDate);
|
||||||
|
if (!match) return null;
|
||||||
|
return toJalaali(Number(match[1]), Number(match[2]), Number(match[3]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Store a Jalaali day as Gregorian `YYYY-MM-DD` for the database. */
|
||||||
|
export function jalaliToIso(jy: number, jm: number, jd: number): string {
|
||||||
|
const gregorian = toGregorian(jy, jm, jd);
|
||||||
|
return `${gregorian.gy}-${pad(gregorian.gm)}-${pad(gregorian.gd)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatJalaliDate(isoDate: string): string | null {
|
||||||
|
const jalali = isoToJalali(isoDate);
|
||||||
|
if (!jalali) return null;
|
||||||
|
const month = JALALI_MONTHS[jalali.jm - 1];
|
||||||
|
if (!month) return null;
|
||||||
|
return `${toPersianDigits(jalali.jd)} ${month} ${toPersianDigits(jalali.jy)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function todayJalali(): JalaaliDate {
|
||||||
|
const now = new Date();
|
||||||
|
return toJalaali(now.getFullYear(), now.getMonth() + 1, now.getDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
export function daysInJalaliMonth(jy: number, jm: number): number {
|
||||||
|
return jalaaliMonthLength(jy, jm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Column of day 1 when the week starts on Saturday. `0` is Saturday. */
|
||||||
|
export function jalaliMonthLeadingBlanks(jy: number, jm: number): number {
|
||||||
|
return (jalaaliToDateObject(jy, jm, 1).getDay() + 1) % 7;
|
||||||
|
}
|
||||||
Loaded 100 of 106 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user