Csv parser UI fixes#189
Conversation
…into csv-parser-uifixes
Modified upload_save_point to share the same pipeline as 'import' from the edit page on successful CSV upload.
Ensures ref reads/writes and state updates happen in effect cleanup/execution rather than during render, complying with React's hooks rules.
|
Good consolidation overall — folding the three-step flow into a single component removes real duplication and the naming ( High — parse errors are silently swallowed (regression) High — checklist gaps Medium — wrong MIME type when reconstructing JSON files const file = new File([content], name, { type: "text/csv" });Raw JSON arrays ( const type = name.endsWith(".json") ? "application/json" : "text/csv";
const file = new File([content], name, { type });Medium — if (headersKey !== prevHeadersKeyRef.current) {
prevHeadersKeyRef.current = headersKey;
if (selectedOverride !== null) setSelectedOverride(null); // setState in render
...
}The comment says this avoids a "setState-in-effect lint error," but calling Low — spinner in setIsUploading(true);
openImportModal(selectedFile);
setIsUploading(false); // batched with the line above — spinner never showsReact 18 batches these into one render. Either drop the Low — |
|
The 2026-06-13 commit addresses all five points from my earlier review — good turnaround. One thing still needs to happen before this can merge: Please run The |
playwright.config.ts:1:39 - error TS2307: Cannot find module '@playwright/test' or its corresponding type declarations. 1 import { defineConfig, devices } from "@playwright/test"; tests/e2e/optimize-flow.spec.ts:1:41 - error TS2307: Cannot find module '@playwright/test' or its corresponding type declarations. 1 import { test, expect, type Page } from "@playwright/test"; tests/e2e/optimize-flow.spec.ts:37:60 - error TS7031: Binding element 'page' implicitly has an 'any' type. 37 test("optimize flow routes 2 stops to 1 vehicle", async ({ page }) => { tests/e2e/optimize-flow.spec.ts:40:62 - error TS7006: Parameter 'route' implicitly has an 'any' type. 40 await page.route(/nominatim.openstreetmap.org/search/, (route) => Found 4 errors in 2 files. Errors Files |
|
The above error doesn't pop up anymore: typecheck runs as intended. |
|
Don't merge yet: I need to address a UI issue I just found in the upload-route page. I will probably finish that tonight or tomorrow. Thanks Mark! |
…iveryoptimizer into csv-parser-uifixes
|
Ready to merge now if no issues are present, thanks! |
|
Thanks — all prior points are addressed and typecheck is clean. One new blocker before merge: High — large CSVs can silently fail to import (regression) Two optional cleanups (non-blocking):
|
…rrors to the user, and share CSV import state
|
The Medium — parse error dismissal closes the overlay (UX regression) if (parseError) {
return <ErrorOverlay message={parseError} onClose={handleClose} />;
}
if (parseError) {
return <ErrorOverlay message={parseError} onClose={closeImportModal} />;
}Low — two dead-code paths in
|
|
Good consolidation overall — deleting Bugs
Minor
|
Resets the column-mapper step to 1 whenever the overlay closes, syncs selectedFile/fileSizeError to initialFile prop changes via useEffect, adds a dismiss button to the oversized-file error so users aren't stuck, and removes PR-context HIGH/MEDIUM/LOW fix: comments.
Summary
.csvor raw.jsonaddress file, map file columns to delivery fields in a column mapper (step 1), review and select which rows to import in a scrollable table (step 2), and have confirmed entries autofill the address list.jsonfiles bypass the modal entirely and restore full vehicle and address state as beforeMotivation
Changes
CSVUploadOverlay.tsx
edit/page.tsx
upload-save-point/page.tsx
Validation
Frontend
npm --prefix app/ui run lintnpm --prefix app/ui run format:checknpm --prefix app/ui run typechecknpm --prefix app/ui run testnpm --prefix app/ui run buildnpm --prefix app/mobile run lintnpm --prefix app/mobile run typecheckManual checks performed:
.csvfrom the edit page Import button → column mapper opened with all columns and 3-row preview populated correctly.csvfrom upload-save-point → navigated to/edit, column mapper opened automatically with file pre-loaded, no intermediate file-pick screen shownrecipientAddress, clicked Next, deselected two rows, confirmed → only selected rows appeared in the address listrecipientAddresswas mapped.jsonfrom upload-save-point → modal skipped, full vehicle and address state restoredtimeBufferanddeliveryQuantityimport as numbers matching theirAddressCardtypessavePointFilein sessionStorage so a page refresh retriesBackend
cmake --preset dev.github/scripts/check-backend-static.sh build/devcmake --build --preset dev --parallelctest --preset dev --output-on-failure --no-tests=error -LE 'e2e|docker'docker compose -f deploy/compose/docker-compose.arm64.yml --env-file deploy/env/http-server.arm64.env configRisk
pendingCSVFilesessionStorage key — new key written by upload-save-point and read on edit page mount. Stale data from a failed navigation will be consumed on the next visit to/editand open the column mapper unexpectedly. Key is removed immediately after reading so this only affects a single stale sessionCSVImportModalremoved — any code path still importingCSVImportModalfromapp/edit/components/address/CSVImportModalwill fail to compile. Confirm no other files reference it before mergingonFileSelectprop removed fromCSVUploadOverlay— the old prop signature (onFileSelect: (file: File) => void) is replaced byimportAddresses: (addresses: AddressCard[]) => void. Any external callers ofCSVUploadOverlaythat have not been updated will produce a TypeScript errorRollout and Recovery
Rollout — Standard frontend deploy. No schema changes, no API changes, no new environment variables. The feature is entirely client-side and scoped to the upload and edit flows.
Recovery — To roll back, revert
CSVUploadOverlay.tsxto its previous single-step version and restore theCSVImportModalimport inedit/page.tsx. The rest of the edit page (vehicle section, address list, pagination, optimize flow) is unaffected. Upload-save-point can independently revert to its previous version without impacting the edit page.High-Signal PR Checklist