// AK-P4a Interim-UI (AD-28) — Files upload preview screen composed from ~/ui. // Presentational: the chunked upload pipeline + queue state live in the route and are // injected as `items` + `onFiles`. The dashed dropzone is a custom interactive target // (no i18n-able ~/ui dropzone exists — the ~/ui FileUpload component bakes in English // copy), everything else (Button, Progress, Alert) is composed from ~/ui. import { useRef } from "react"; import { useTranslation } from "react-i18next"; import { FeatherUpload } from "@subframe/core"; import type { FileUploadVM } from "@hivegrid/view-models"; import { Alert } from "~/ui/components/Alert"; import { Button } from "~/ui/components/Button"; import { Progress } from "~/ui/components/Progress"; export type FileUploadDisplayItem = { clientId: string; filename: string; sizeBytes: number; status: "queued" | "uploading" | "processing" | "done" | "error"; progressPercent: number; errorKey: string | null; }; export type FileUploadActions = { onFiles: (files: FileList | null) => void; }; export type FileUploadPageProps = { vm: FileUploadVM; items: readonly FileUploadDisplayItem[]; actions: FileUploadActions; }; function progressState(status: FileUploadDisplayItem["status"]): "uploading" | "success" | "error" { if (status === "done") return "success"; if (status === "error") return "error"; return "uploading"; } export function FileUploadPage({ vm, items, actions }: FileUploadPageProps) { const { t } = useTranslation(); const inputRef = useRef(null); if (vm.status !== "ready" || !vm.data) { return
; } const { dropzoneHeadlineKey, dropzoneBodyKey, heicNoticeKey } = vm.data; function statusText(item: FileUploadDisplayItem): string { if (item.status === "error") return t(item.errorKey ?? "files.error.uploadIncomplete"); if (item.status === "done") return t("files.upload.status.done"); if (item.status === "processing") return t("files.upload.status.processing"); if (item.status === "queued") return t("files.upload.status.queued"); return `${item.progressPercent}%`; } return (
{t("files.upload.title")}
{/* Dropzone (custom interactive target; i18n copy from the VM) */} actions.onFiles(event.target.files)} data-ui-id="ui.files.upload.input" />
    {items.length === 0 ? (
  • {t("files.upload.queue.empty")}
  • ) : ( items.map((item) => (
  • {item.filename} {statusText(item)}
  • )) )}
); }