43 lines
1.4 KiB
TypeScript
43 lines
1.4 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,
|
|
flatrateActive: editorialAccounts.flatrateActive,
|
|
flatratePriceCents: editorialAccounts.flatratePriceCents,
|
|
flatrateAssetLimit: editorialAccounts.flatrateAssetLimit,
|
|
archivedAt: editorialAccounts.archivedAt,
|
|
})
|
|
.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)} />;
|
|
}
|