feat(home): import messages open with a full-restoration or partial-recovery headline; BDR-040 recorded

This commit is contained in:
bchanot committed 2026-10-11 16:31:37 +02:00
1 parent de2bd0437e
commit 62b8a43e09
7 files changed
+106 -23

No files matched your search

+39 -3
View File
@@ -18,11 +18,11 @@ import { useT } from '@/i18n/useT'
type Translate = ReturnType<typeof useT>
/**
* The lines of the one alert shown after a successful import (STEP6 §16):
* a lossy v2 migration, the archive kept, the snapshot dropped with its
* The detail lines of the import alert (STEP6 §16), in a fixed order: a
* lossy v2 migration, the archive kept, the snapshot dropped with its
* reason, the rebase onto the current sheet. Empty when nothing applies.
*/
function importMessages(
function importDetailLines(
outcome: ArchiveReadOutcome,
rebase: RebaseOutcome,
t: Translate,
@@ -48,6 +48,42 @@ function importMessages(
return lines
}
/**
* Degraded recovery: something the practitioner must check. A rejected
* snapshot, a migration or a rebase that lost items. A rebase that resolved
* everything is a complete restoration on a different sheet.
*/
function isDegradedImport(
outcome: ArchiveReadOutcome,
rebase: RebaseOutcome,
): boolean {
const lost = outcome.unresolvedFindings + outcome.unresolvedZones
const rebaseLost = rebase.unresolvedZones + rebase.unresolvedFindings
return (
outcome.snapshotRejected !== undefined ||
(outcome.migrated && lost > 0) ||
(rebase.rebased && rebaseLost > 0)
)
}
/**
* The one alert shown after a successful import: a headline that says
* whether the restoration is complete or partial, then the detail lines.
* Empty (no alert) when there is nothing to say: a bare v3 on the same sheet.
*/
function importMessages(
outcome: ArchiveReadOutcome,
rebase: RebaseOutcome,
t: Translate,
): string[] {
const details = importDetailLines(outcome, rebase, t)
if (details.length === 0) return []
const headline = isDegradedImport(outcome, rebase)
? t('home.import.degraded')
: t('home.import.complete')
return [headline, ...details]
}
/** The error line under the import button, by ImportError kind. */
function importErrorMessage(err: unknown, t: Translate): string {
if (!(err instanceof ImportError)) return t('home.import.error_generic')
+3
View File
@@ -30,6 +30,9 @@ export const en: Dict = {
'This PDF was not generated by Faunosteo (no data detected).',
'home.import.error_incompatible_version':
'This PDF uses format v{version}, which this version of the application cannot read (accepted formats: v2 and v3).',
'home.import.complete': 'Full restoration.',
'home.import.degraded':
'Partial recovery: check the items flagged below.',
'home.import.migrated':
'Report imported from an older format. Findings not found in the current sheet: {count} (kept with their labels).',
'home.import.archive_ok':
+3
View File
@@ -32,6 +32,9 @@ export const fr: Dict = {
"Ce PDF n'a pas été généré par Faunosteo (pas de données détectées).",
'home.import.error_incompatible_version':
"Ce PDF est au format v{version}, que cette version de l'application ne sait pas lire (formats acceptés : v2 et v3).",
'home.import.complete': 'Restauration complète.',
'home.import.degraded':
'Récupération partielle : vérifiez les éléments signalés.',
'home.import.migrated':
'Bilan importé depuis un ancien format. Constats non retrouvés dans la fiche actuelle : {count} (conservés avec leurs libellés).',
'home.import.archive_ok':