Skip to documentation
Design system / Sources & standards
Current repository source
submissionFacts.tsx
src/components/submissions/submissionFacts.tsx
This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.
import { Badge } from "@/components/ui/badge";
import type { ReactNode } from "react";
import { Card, CardAction, CardContent, CardFooter, CardHeader } from "@/components/ui/card";
import { Text } from "@/components/ui/text";
import { cn } from "@/lib/utils";
import type { SubmissionDetailData } from "./submission-detail-data";
type FactsData = Pick<SubmissionDetailData,
"brand" | "agency" | "country" | "zone" | "categoryName" | "submittedByName" |
"teamMembers" | "integrityStatementAccepted"
>;
type Props = {
submission: FactsData & { status?: SubmissionDetailData["status"] };
submissionLabel?: string;
variant?: "inline" | "card";
action?: ReactNode;
};
/** Submissions-owned, server-rendered molecule; the shared Card owns its surface. */
export function SubmissionFacts({ submission, submissionLabel = "Submission", variant = "inline", action }: Props) {
const compact = variant === "card";
const metadata: Array<[string, string | null | undefined]> = [
["Brand", submission.brand], ["Agency", submission.agency],
["Country", submission.country], ["Zone", submission.zone],
["Category", submission.categoryName ?? "Not assigned"],
["Submitted by", submission.submittedByName ?? "Unknown"],
];
if (compact && submission.teamMembers) metadata.push(["Team members", submission.teamMembers]);
const content = <>
<dl className={cn("grid", compact ? "grid-cols-2 gap-x-6 gap-y-2" : "gap-x-6 gap-y-5 sm:grid-cols-2")}>
{metadata.map(([label, value]) => (
<div key={label} className={cn("min-w-0", compact ? "space-y-0.5" : "space-y-1")}>
<dt className="text-eyebrow text-muted-foreground">{label}</dt>
<Text as="dd" variant="inherit" rhythm="tight" className="whitespace-pre-wrap break-words text-label">{value || "Not provided"}</Text>
</div>
))}
</dl>
{!compact && submission.teamMembers ? <div className="space-y-1"><h2 className="text-eyebrow text-muted-foreground">Team members</h2><p className="whitespace-pre-wrap break-words text-label leading-relaxed">{submission.teamMembers}</p></div> : null}
{submission.integrityStatementAccepted !== undefined ? <p className="text-supporting text-muted-foreground">Integrity statement: {submission.integrityStatementAccepted ? "Accepted" : "Not accepted"}</p> : null}
</>;
if (compact) return <Card role="region" aria-label={`${submissionLabel} information`} className="min-w-0 gap-3 py-4">
<CardHeader className="px-4">
<h2 className="text-label font-semibold">{submissionLabel} information</h2>
{submission.status ? <CardAction><Badge variant="secondary" className="capitalize">{submission.status}</Badge></CardAction> : null}
</CardHeader>
<CardContent className="space-y-2 px-4">{content}</CardContent>
{action ? <CardFooter className="mt-auto justify-end px-4 pt-4">{action}</CardFooter> : null}
</Card>;
return <section aria-label={`${submissionLabel} information`} className="space-y-5">{content}{action}</section>;
}
All sources and standards