mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
fix(documents): report picker and card results through the shared outcome line, and register the disconnect as a destructive control
This commit is contained in:
1 parent
d109d67889
commit
9e38ee3a99
4 files changed
+46
-14
No files matched your search
@@ -69,6 +69,9 @@ import { invalidateKeys, queryKeys } from "@/lib/query-keys";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { InboundDocumentKindValue } from "@/lib/validations/inbound-documents";
|
||||
|
||||
import { WrittenOutcomeLine } from "@/components/outcome/written-outcome-line";
|
||||
import type { WrittenOutcome } from "@/lib/outcome/written-outcome";
|
||||
|
||||
import { formatBytes } from "../vault-utils";
|
||||
import {
|
||||
errorCodeOf,
|
||||
@@ -306,7 +309,7 @@ export function DocumentSourcePicker({
|
||||
data-slot="document-source-selection"
|
||||
>
|
||||
{finished
|
||||
? t("documents.sourcePicker.summary", counts)
|
||||
? null
|
||||
: running
|
||||
? t("documents.sourcePicker.importing")
|
||||
: t("documents.sourcePicker.selectedCount", {
|
||||
@@ -469,6 +472,14 @@ export function DocumentSourcePicker({
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
{finished ? (
|
||||
<WrittenOutcomeLine
|
||||
outcome={runOutcome(counts)}
|
||||
message={t("documents.sourcePicker.summary", counts)}
|
||||
testId="document-source-summary"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{stopMessage ? (
|
||||
<p
|
||||
role="alert"
|
||||
@@ -597,6 +608,17 @@ export function DocumentSourcePicker({
|
||||
);
|
||||
}
|
||||
|
||||
/** How the run went, in the shared outcome vocabulary. */
|
||||
function runOutcome(counts: {
|
||||
imported: number;
|
||||
present: number;
|
||||
failed: number;
|
||||
}): WrittenOutcome {
|
||||
const held = counts.imported + counts.present;
|
||||
if (counts.failed === 0) return held > 0 ? "success" : "empty";
|
||||
return held > 0 ? "partial" : "failed";
|
||||
}
|
||||
|
||||
/** One row's progress or result, under its title. */
|
||||
function RunLine({ run }: { run: RowRun }) {
|
||||
const { t } = useTranslations();
|
||||
|
||||
Reference in new issue
Block a user