This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// One document: its extracted lines, each with where it was read, and the reviewer's decisions.
|
||||
// Approve, edit and reject are procedure calls from the client component; nothing is exported
|
||||
// until a line is approved, and the export is the last control on the page.
|
||||
|
||||
import { PROFILE } from "@app/config"
|
||||
import { documentGet } from "@app/modules/documents"
|
||||
import { ExportButton, exportLabels, LineReview, reviewLabels } from "@app/modules/documents/ui"
|
||||
import { AppError } from "@conusai-kit/core"
|
||||
import { notFound } from "next/navigation"
|
||||
import type { ReactElement } from "react"
|
||||
import { pageContext } from "../../../../../../src/server/page"
|
||||
import { AppTransport } from "../../../../../../src/ui/transport"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export default async function DocumentPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ org: string; workspace: string; project: string; fileId: string }>
|
||||
}): Promise<ReactElement> {
|
||||
const { fileId, ...slugs } = await params
|
||||
if (PROFILE === "convex") notFound()
|
||||
const { caller, i18n } = await pageContext()
|
||||
const detail = await caller.call(documentGet, { ...slugs, fileId }).catch((error: unknown) => {
|
||||
// A document of another organization and one that does not exist are the same page.
|
||||
if (error instanceof AppError && error.status === 404) notFound()
|
||||
throw error
|
||||
})
|
||||
const t = (key: string, values?: Record<string, string | number>) => i18n.message(`documents.${key}`, values)
|
||||
const failed = i18n.message("app.failed")
|
||||
const { document, lines } = detail
|
||||
|
||||
return (
|
||||
<>
|
||||
<p>
|
||||
<a href={`/${slugs.org}/${slugs.workspace}/${slugs.project}/documents`}>
|
||||
{i18n.message("documents.review.back")}
|
||||
</a>
|
||||
</p>
|
||||
<h1>{i18n.message("documents.review.title", { filename: document.filename })}</h1>
|
||||
<p>
|
||||
{i18n.message("documents.list.status")}: {i18n.message(`documents.status.${document.status}`)}
|
||||
{document.failureCode ? ` ${i18n.message(`documents.failure.${document.failureCode}`)}` : ""}
|
||||
</p>
|
||||
<p>
|
||||
{i18n.message("documents.review.pendingCount", { count: document.pending })}.{" "}
|
||||
{i18n.message("documents.review.approvedCount", { count: document.approved })}.
|
||||
</p>
|
||||
{document.status === "queued" || document.status === "processing" ? (
|
||||
<p role="status">{i18n.message("documents.review.waiting")}</p>
|
||||
) : null}
|
||||
{document.skippedPages.length > 0 ? (
|
||||
<section aria-labelledby="skipped-pages">
|
||||
<h2 id="skipped-pages">{i18n.message("documents.review.skippedTitle")}</h2>
|
||||
<ul>
|
||||
{document.skippedPages.map((skipped) => (
|
||||
<li key={skipped.page}>
|
||||
{i18n.message("documents.review.skippedPage", {
|
||||
page: skipped.page,
|
||||
kind: i18n.message(`documents.review.pageClass.${skipped.pageClass}`),
|
||||
})}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
) : null}
|
||||
<AppTransport>
|
||||
<LineReview
|
||||
slugs={slugs}
|
||||
fileId={fileId}
|
||||
lines={lines}
|
||||
labels={reviewLabels(t, {
|
||||
failed,
|
||||
aiDisclosure: i18n.message("ui.aiDisclosure"),
|
||||
pageWord: i18n.message("ui.page"),
|
||||
})}
|
||||
locale={i18n.locale}
|
||||
/>
|
||||
<ExportButton slugs={slugs} fileId={fileId} approved={document.approved} labels={exportLabels(t, failed)} />
|
||||
</AppTransport>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// The project's documents: upload one, and see where each is in being read and reviewed. Every
|
||||
// read is a procedure through the same caller the API uses; the upload is a client form that
|
||||
// calls the files module's own procedure (spec §6.2: one API path).
|
||||
|
||||
import { PROFILE } from "@app/config"
|
||||
import { documentList, READABLE_CONTENT_TYPES } from "@app/modules/documents"
|
||||
import { DocumentList, listLabels, UploadForm, uploadLabels } from "@app/modules/documents/ui"
|
||||
import { downloadHref } from "@conusai-kit/ui/download"
|
||||
import { notFound } from "next/navigation"
|
||||
import type { ReactElement } from "react"
|
||||
import { pageContext } from "../../../../../src/server/page"
|
||||
import { AppTransport } from "../../../../../src/ui/transport"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export default async function DocumentsPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ org: string; workspace: string; project: string }>
|
||||
}): Promise<ReactElement> {
|
||||
const slugs = await params
|
||||
if (PROFILE === "convex") notFound()
|
||||
const { caller, i18n } = await pageContext()
|
||||
const { documents } = await caller.call(documentList, slugs)
|
||||
const t = (key: string, values?: Record<string, string | number>) => i18n.message(`documents.${key}`, values)
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>{i18n.message("documents.title")}</h1>
|
||||
<p>{i18n.message("documents.intro")}</p>
|
||||
<AppTransport>
|
||||
<UploadForm
|
||||
slugs={slugs}
|
||||
accept={READABLE_CONTENT_TYPES}
|
||||
labels={uploadLabels(t, i18n.message("app.failed"))}
|
||||
/>
|
||||
</AppTransport>
|
||||
<DocumentList
|
||||
documents={documents}
|
||||
hrefFor={(fileId) => `/${slugs.org}/${slugs.workspace}/${slugs.project}/documents/${fileId}`}
|
||||
downloadHrefFor={(fileId) => downloadHref("files.file.download", { ...slugs, fileId })}
|
||||
labels={listLabels(t)}
|
||||
formatDate={(iso) => i18n.date(new Date(iso))}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user