fix(import): persist source files in IndexedDB so attach survives a reload

The source document was only kept in memory on the background task, so a page reload during the (now always-LLM ~25s) parse lost it and the booking saved without its file. Store the uploaded files in IndexedDB keyed by job id; the review loads them from there when the in-memory copy is gone, and a 1h TTL prunes abandoned imports.
This commit is contained in:
Maurice
2026-06-26 16:27:06 +02:00
committed by Maurice
parent 27fbc241e8
commit 6a70f4fc41
3 changed files with 62 additions and 5 deletions
@@ -4,6 +4,7 @@ import { Upload, X } from 'lucide-react'
import { useTranslation } from '../../i18n'
import { reservationsApi, healthApi } from '../../api/client'
import { useBackgroundTasksStore } from '../../store/backgroundTasksStore'
import { saveImportFiles } from '../../db/offlineDb'
interface BookingImportModalProps {
isOpen: boolean
@@ -96,7 +97,9 @@ export default function BookingImportModal({ isOpen, onClose, tripId }: BookingI
try {
const mode = aiParsing ? 'fallback-on-empty' : 'no-ai'
const { jobId } = await reservationsApi.importBookingAsync(tripId, files, mode)
// Keep the uploaded files so the review can attach each source document to its booking.
// Keep the uploaded files so the review can attach each source document to its booking
// in memory for the immediate path, and in IndexedDB so it survives a reload mid-parse.
await saveImportFiles(jobId, files)
addTask({ id: jobId, tripId: String(tripId), label: files.map((f) => f.name).join(', '), total: files.length, files })
handleClose()
} catch (err: any) {