feat: add editorial approval and account guards
This commit is contained in:
1 parent
a8d4e54ffb
commit
3584b4a7a7
9 files changed
+878
-1
No files matched your search
@@ -0,0 +1,74 @@
|
||||
import { and, eq, isNull } from "drizzle-orm";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { db } from "@/db/client";
|
||||
import { albumGrants, editorialAccounts } from "@/db/schema";
|
||||
|
||||
export default async function EditorialDetailPage({
|
||||
params,
|
||||
}: Readonly<{ params: Promise<{ id: string }> }>) {
|
||||
const { id } = await params;
|
||||
const [editorial] = await db
|
||||
.select({
|
||||
id: editorialAccounts.id,
|
||||
name: editorialAccounts.name,
|
||||
contactName: editorialAccounts.contactName,
|
||||
loginEmail: editorialAccounts.loginEmail,
|
||||
status: editorialAccounts.status,
|
||||
emailVerifiedAt: editorialAccounts.emailVerifiedAt,
|
||||
currentPriceCents: editorialAccounts.currentPriceCents,
|
||||
})
|
||||
.from(editorialAccounts)
|
||||
.where(eq(editorialAccounts.id, id))
|
||||
.limit(1);
|
||||
if (!editorial) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const [grant] = await db
|
||||
.select({ id: albumGrants.id })
|
||||
.from(albumGrants)
|
||||
.where(
|
||||
and(eq(albumGrants.editorialAccountId, editorial.id), isNull(albumGrants.revokedAt)),
|
||||
)
|
||||
.limit(1);
|
||||
|
||||
return (
|
||||
<section className="content-section" aria-labelledby="editorial-title">
|
||||
<p className="eyebrow">Redaktion</p>
|
||||
<h1 id="editorial-title">{editorial.name}</h1>
|
||||
<dl>
|
||||
<dt>Ansprechperson</dt>
|
||||
<dd>{editorial.contactName}</dd>
|
||||
<dt>Anmelde-E-Mail</dt>
|
||||
<dd>{editorial.loginEmail}</dd>
|
||||
<dt>Status</dt>
|
||||
<dd>{editorial.status}</dd>
|
||||
<dt>E-Mail bestätigt</dt>
|
||||
<dd>{editorial.emailVerifiedAt ? "Ja" : "Nein"}</dd>
|
||||
<dt>Individueller Nettopreis</dt>
|
||||
<dd>
|
||||
{editorial.currentPriceCents === null
|
||||
? "Noch nicht festgelegt"
|
||||
: formatCents(editorial.currentPriceCents)}
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<section aria-labelledby="approval-title">
|
||||
<h2 id="approval-title">Freigabe</h2>
|
||||
<button type="button" disabled aria-describedby="approval-help">
|
||||
Redaktion freigeben
|
||||
</button>
|
||||
<p id="approval-help">
|
||||
{grant
|
||||
? "Die Freigabe bleibt bis zur Verwaltungsoberfläche für Albumrechte deaktiviert."
|
||||
: "Eine Freigabe ist erst möglich, wenn mindestens ein aktives Albumrecht zugewiesen wurde. Die Verwaltung der Albumrechte folgt im nächsten Schritt."}
|
||||
</p>
|
||||
</section>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function formatCents(cents: number): string {
|
||||
return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(cents / 100);
|
||||
}
|
||||
Reference in new issue
Block a user