Apply the public site UI checklist.

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

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

No files matched your search

+11 -2
View File
@@ -8,6 +8,7 @@ import { revalidateSite } from "@/lib/api/revalidate";
import { getAdminCourseById } from "@/lib/data/admin/courses";
import {
setCourseCategories,
setCourseFaculty,
setCourseTags,
} from "@/lib/data/admin/taxonomy";
@@ -68,7 +69,7 @@ export async function PATCH(
return errorResponse(parsed.error.issues[0]?.message ?? "داده نادرست", 400);
}
const { categoryIds, tagIds, ...rest } = parsed.data;
const { categoryIds, tagIds, facultyIds, ...rest } = parsed.data;
const sets: string[] = [];
const values: unknown[] = [];
for (const [key, column] of Object.entries(COURSE_COLUMNS)) {
@@ -83,7 +84,12 @@ export async function PATCH(
}
}
if (sets.length === 0 && categoryIds === undefined && tagIds === undefined) {
if (
sets.length === 0 &&
categoryIds === undefined &&
tagIds === undefined &&
facultyIds === undefined
) {
return errorResponse("حداقل یک فیلد برای ویرایش لازم است", 400);
}
@@ -106,6 +112,9 @@ export async function PATCH(
if (tagIds !== undefined) {
await setCourseTags(id, tagIds);
}
if (facultyIds !== undefined) {
await setCourseFaculty(id, facultyIds);
}
const course = await getAdminCourseById(id);
revalidateSite();
+2
View File
@@ -12,6 +12,7 @@ import {
} from "@/lib/data/admin/courses";
import {
setCourseCategories,
setCourseFaculty,
setCourseTags,
} from "@/lib/data/admin/taxonomy";
@@ -83,6 +84,7 @@ export async function POST(request: NextRequest) {
);
await setCourseCategories(id, d.categoryIds ?? []);
await setCourseTags(id, d.tagIds ?? []);
await setCourseFaculty(id, d.facultyIds ?? []);
const course = await getAdminCourseById(id);
revalidateSite();
return NextResponse.json({ ok: true, data: course }, { status: 201 });
+1
View File
@@ -21,6 +21,7 @@ const FACULTY_COLUMNS: Record<string, string> = {
department: "department",
linkedinUrl: "linkedin_url",
scholarUrl: "scholar_url",
profileUrl: "profile_url",
published: "published",
};
+2 -2
View File
@@ -33,12 +33,12 @@ export async function POST(request: NextRequest) {
[
"id", "name", "title", "focus", "bio", "image_url",
"email", "office", "phone", "department", "linkedin_url", "scholar_url",
"published",
"profile_url", "published",
],
[
id, d.name, d.title, d.focus, d.bio, d.imageUrl,
d.email || null, d.office || null, d.phone || null, d.department || null,
d.linkedinUrl || null, d.scholarUrl || null,
d.linkedinUrl || null, d.scholarUrl || null, d.profileUrl || null,
d.published,
],
);
+33
View File
@@ -0,0 +1,33 @@
import { NextResponse } from "next/server";
import { requireAdmin } from "@/lib/auth/admin";
import { errorResponse } from "@/lib/api/response";
import { syncFacultyFromMstNetwork } from "@/lib/faculty/sync-mst-network";
import { facultyNetworkUrl } from "@/lib/site-config";
export const dynamic = "force-dynamic";
export const maxDuration = 60;
/**
* POST /api/admin/faculty/sync
* Pull the live «شبکه اساتید» page (same URL as header nav) and upsert rows.
*/
export async function POST() {
const session = await requireAdmin();
if (!session) return errorResponse("عدم دسترسی — ورود لازم است", 401);
try {
const result = await syncFacultyFromMstNetwork();
return NextResponse.json({
ok: true,
data: {
...result,
url: facultyNetworkUrl,
},
});
} catch (err) {
const message =
err instanceof Error ? err.message : "همگام‌سازی اساتید ناموفق بود";
console.error("faculty sync error:", err);
return errorResponse(message, 502);
}
}
+7
View File
@@ -29,6 +29,13 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ ok: true, user: { id: user.id, email: user.email, name: user.name, role: user.role } });
} catch (error) {
console.error("admin login error:", error);
const message = error instanceof Error ? error.message : String(error);
if (/timeout|ECONNREFUSED|ECONNRESET|Connection terminated/i.test(message)) {
return NextResponse.json(
{ error: "اتصال به پایگاه‌داده برقرار نشد. چند ثانیه بعد دوباره تلاش کنید." },
{ status: 503 },
);
}
return NextResponse.json({ error: "خطای سرور" }, { status: 500 });
}
}