feat: admin panel with SQLite, auth, and calendar-style schedule editor
Complete admin panel for content management: - SQLite database with better-sqlite3, seed script from content.ts - Simple password auth with HMAC-signed cookies (Edge + Node compatible) - 9 section editors: meta, hero, about, team, classes, schedule, pricing, FAQ, contact - Team CRUD with image upload and drag reorder - Schedule editor with Google Calendar-style visual timeline (colored blocks, overlap detection, click-to-add) - All public components refactored to accept data props from DB (with fallback to static content) - Middleware protecting /admin/* and /api/admin/* routes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
94
src/app/admin/classes/page.tsx
Normal file
94
src/app/admin/classes/page.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
"use client";
|
||||
|
||||
import { SectionEditor } from "../_components/SectionEditor";
|
||||
import { InputField, TextareaField } from "../_components/FormField";
|
||||
import { ArrayEditor } from "../_components/ArrayEditor";
|
||||
|
||||
const ICON_OPTIONS = [
|
||||
"sparkles", "flame", "wind", "zap", "star", "monitor",
|
||||
"heart", "music", "dumbbell", "trophy",
|
||||
];
|
||||
|
||||
interface ClassesData {
|
||||
title: string;
|
||||
items: {
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
detailedDescription?: string;
|
||||
images?: string[];
|
||||
}[];
|
||||
}
|
||||
|
||||
export default function ClassesEditorPage() {
|
||||
return (
|
||||
<SectionEditor<ClassesData> sectionKey="classes" title="Направления">
|
||||
{(data, update) => (
|
||||
<>
|
||||
<InputField
|
||||
label="Заголовок секции"
|
||||
value={data.title}
|
||||
onChange={(v) => update({ ...data, title: v })}
|
||||
/>
|
||||
|
||||
<ArrayEditor
|
||||
label="Направления"
|
||||
items={data.items}
|
||||
onChange={(items) => update({ ...data, items })}
|
||||
renderItem={(item, _i, updateItem) => (
|
||||
<div className="space-y-3">
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<InputField
|
||||
label="Название"
|
||||
value={item.name}
|
||||
onChange={(v) => updateItem({ ...item, name: v })}
|
||||
/>
|
||||
<div>
|
||||
<label className="block text-sm text-neutral-400 mb-1.5">
|
||||
Иконка
|
||||
</label>
|
||||
<select
|
||||
value={item.icon}
|
||||
onChange={(e) =>
|
||||
updateItem({ ...item, icon: e.target.value })
|
||||
}
|
||||
className="w-full rounded-lg border border-white/10 bg-neutral-800 px-4 py-2.5 text-white outline-none focus:border-gold transition-colors"
|
||||
>
|
||||
{ICON_OPTIONS.map((icon) => (
|
||||
<option key={icon} value={icon}>
|
||||
{icon}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<TextareaField
|
||||
label="Краткое описание"
|
||||
value={item.description}
|
||||
onChange={(v) => updateItem({ ...item, description: v })}
|
||||
rows={2}
|
||||
/>
|
||||
<TextareaField
|
||||
label="Подробное описание"
|
||||
value={item.detailedDescription || ""}
|
||||
onChange={(v) =>
|
||||
updateItem({ ...item, detailedDescription: v })
|
||||
}
|
||||
rows={4}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
createItem={() => ({
|
||||
name: "",
|
||||
description: "",
|
||||
icon: "sparkles",
|
||||
detailedDescription: "",
|
||||
images: [],
|
||||
})}
|
||||
addLabel="Добавить направление"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</SectionEditor>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user