feat: Notes manager — Заметки редактора в app.zeropost.ru

- app/notes/page.js: страница управления заметками (создать/редактировать/
  удалить/закрепить/скрыть). Список с превью, inline-форма.
- app/api/notes/route.js: GET+POST прокси к engine /api/notes
- app/api/notes/[id]/route.js: PATCH+DELETE прокси
- lib/engine.js: listNotes, createNote, updateNote, deleteNote
- Header.js: ссылка «Заметки» в навигации (MessageCircle иконка)
This commit is contained in:
Ник (Claude)
2026-06-09 11:44:33 +03:00
parent d413f5f018
commit 3e04df32c5
5 changed files with 233 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
import { NextResponse } from 'next/server';
import { requireAdmin } from '@/lib/session';
import { engine } from '@/lib/engine';
export async function PATCH(req, { params }) {
const admin = await requireAdmin();
if (!admin) return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
try {
const { id } = await params;
const body = await req.json();
const note = await engine.updateNote(id, body);
return NextResponse.json(note);
} catch (err) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}
export async function DELETE(req, { params }) {
const admin = await requireAdmin();
if (!admin) return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
try {
const { id } = await params;
await engine.deleteNote(id);
return NextResponse.json({ ok: true });
} catch (err) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}