feat: add cross-album search, auto-rules, album UI redesign, editorial archiving and pdf download
This commit is contained in:
1 parent
9c0d43b1ec
commit
375e5b8b7d
23 files changed
+1153
-43
No files matched your search
@@ -0,0 +1,72 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { headers } from "next/headers";
|
||||
import { requireAdmin } from "@/modules/auth/principal";
|
||||
import { autoRuleService } from "@/modules/albums/auto-rules";
|
||||
import { db } from "@/db/client";
|
||||
import { editorialAccounts } from "@/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { applyAutoRulesAction, createAutoRuleAction, deleteAutoRuleAction } from "./actions";
|
||||
|
||||
type AutoRulesPageProps = Readonly<{
|
||||
params: Promise<{ id: string }>;
|
||||
}>;
|
||||
|
||||
export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
|
||||
await requireAdmin(new Headers(await headers()));
|
||||
const { id } = await params;
|
||||
|
||||
const [editorial] = await db
|
||||
.select()
|
||||
.from(editorialAccounts)
|
||||
.where(eq(editorialAccounts.id, id));
|
||||
|
||||
if (!editorial) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const rules = await autoRuleService.listRules(id);
|
||||
|
||||
return (
|
||||
<section className="content-section" aria-labelledby="auto-rules-title">
|
||||
<p className="eyebrow">Redaktion · Auto-Zuweisungsregeln</p>
|
||||
<h1 id="auto-rules-title">Auto-Regeln für {editorial.name}</h1>
|
||||
<p>
|
||||
Alben, deren Name eines der folgenden Schlüsselwörter enthält, werden automatisch zugewiesen.
|
||||
</p>
|
||||
<p>
|
||||
<Link href={`/admin/redaktionen/${editorial.id}/alben`}>Zurück zu Albumrechte</Link>
|
||||
</p>
|
||||
|
||||
<form action={createAutoRuleAction.bind(null, editorial.id)}>
|
||||
<label>
|
||||
<span>Neues Schlüsselwort</span>
|
||||
<input name="keyword" type="text" required placeholder="z.B. FC Bayern" />
|
||||
</label>
|
||||
<button type="submit">Regel hinzufügen</button>
|
||||
</form>
|
||||
|
||||
<form action={applyAutoRulesAction.bind(null, editorial.id)}>
|
||||
<button type="submit">Regeln jetzt anwenden</button>
|
||||
</form>
|
||||
|
||||
{rules.length === 0 ? (
|
||||
<p>Noch keine Auto-Regeln angelegt.</p>
|
||||
) : (
|
||||
<ul className="auto-rules-list">
|
||||
{rules.map((rule) => (
|
||||
<li key={rule.id} className="auto-rule-item">
|
||||
<span className="auto-rule-keyword">{rule.keyword}</span>
|
||||
<span className="auto-rule-date">
|
||||
{rule.createdAt.toLocaleDateString('de-DE')}
|
||||
</span>
|
||||
<form action={deleteAutoRuleAction.bind(null, editorial.id, rule.id)}>
|
||||
<button type="submit" className="auto-rule-delete">Entfernen</button>
|
||||
</form>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user