+ {localizedStrings['%interlinearizer_pt9ConvertPrompt_message%']} +
++ {label}: + {value} +
+ ); +} + +/** + * The modal shown while Paratext 9 interlinear data imports or syncs, and afterward: a running + * phase (not dismissable - the run is in flight), then either the report summary or a failure line. + * The caller owns the run itself and feeds the phase in. + * + * @param props.phase - What to show: the run in progress, its report, or its failure. + * @param props.mode - `import` titles the modal as an import and offers Close and Open on the + * report; `offer` titles it the same but the report carries a single Open, dismissal included - + * the user already chose to convert, so the report is information on the way in, not a fork; + * `sync` titles it as a sync and offers only Close (the project is already open). + * @param props.onOpen - Called when the user opens the imported project from the report; not + * offered in `sync` mode, where the project is already open. + * @param props.onClose - Called when the user dismisses the report or failure. + */ +export function Pt9ImportModal({ + phase, + mode, + onOpen, + onClose, +}: Readonly<{ + phase: Pt9ImportModalPhase; + mode: 'import' | 'offer' | 'sync'; + onOpen?: () => void; + onClose: () => void; +}>) { + const [localizedStrings, stringsLoading] = useLocalizedStrings(PT9_IMPORT_MODAL_STRING_KEYS); + + /* v8 ignore next */ if (stringsLoading) return undefined; + + const title = + mode === 'sync' + ? localizedStrings['%interlinearizer_pt9ImportModal_syncTitle%'] + : localizedStrings['%interlinearizer_pt9ImportModal_title%']; + + if (phase.kind === 'running') { + return ( ++ {mode === 'sync' + ? localizedStrings['%interlinearizer_pt9ImportModal_syncing%'] + : localizedStrings['%interlinearizer_pt9ImportModal_importing%']} +
++ {phase.reason === 'tooLarge' + ? localizedStrings['%interlinearizer_pt9ImportModal_tooLarge%'] + : localizedStrings['%interlinearizer_pt9ImportModal_failed%']} +
++ {formatReplacementString( + localizedStrings['%interlinearizer_pt9ImportModal_missingBooks%'], + { books: totals.missingBooks.join(', ') }, + )} +
+ )} +