// The project's documents, one row each, with where they are in the pipeline and how many lines wait // for a person. A server component: it holds no state, and every string is passed in. import type { ReactElement } from "react" import type { DocumentView } from "../contract/index.js" export interface DocumentListLabels { readonly caption: string readonly empty: string readonly file: string readonly status: string readonly pages: string readonly pending: string readonly approved: string readonly uploaded: string readonly actions: string /** `Download {filename}`: a same-origin, project-scoped file stream. */ readonly download: string /** `Review {filename}`: the link's accessible name, so a list of links is not a list of "Review". */ readonly review: string /** The status and failure texts, by code. */ readonly statuses: Readonly> readonly failures: Readonly, string>> } export function DocumentList({ documents, hrefFor, downloadHrefFor, labels, formatDate, }: { documents: readonly DocumentView[] hrefFor: (fileId: string) => string downloadHrefFor: (fileId: string) => string labels: DocumentListLabels formatDate: (iso: string) => string }): ReactElement { if (documents.length === 0) { return

{labels.empty}

} return ( {documents.map((document) => ( ))}
{labels.caption}
{labels.file} {labels.status} {labels.pages} {labels.pending} {labels.approved} {labels.uploaded} {labels.actions}
{document.filename} {labels.statuses[document.status]} {document.failureCode ? ` ${labels.failures[document.failureCode]}` : ""} {document.pageCount ?? ""} {document.pending} {document.approved} {formatDate(document.uploadedAt)} {labels.download.replace("{filename}", document.filename)}
) }