Files
immich-redaktions-plugin/src/app/admin/redaktionen/[id]/page.tsx
T

39 lines
1.2 KiB
TypeScript

import { and, eq, isNull } from "drizzle-orm";
import { notFound } from "next/navigation";
import { db } from "@/db/client";
import { albumGrants, editorialAccounts } from "@/db/schema";
import { EditorialDetailContent } from "@/modules/editorials/admin-detail";
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 <EditorialDetailContent editorial={editorial} hasActiveGrant={Boolean(grant)} />;
}