Skip to content

fix(csv-import): prevent duplicate onImport calls in CSV wizards - #965

Open
Micheal1605 wants to merge 1 commit into
RevoraOrg:masterfrom
Micheal1605:fix/issue-912-fix-csv-import-revenue-calendar-and-blacklist
Open

Micheal1605 wants to merge 1 commit into
RevoraOrg:masterfrom
Micheal1605:fix/issue-912-fix-csv-import-revenue-calendar-and-blacklist

Conversation

@Micheal1605

Copy link
Copy Markdown

Overview

This PR fixes a duplicate-import bug in the Revenue Calendar and Blacklist CSV import wizards. Both components bound the same handleConfirm callback to the Preview step's "Import" button and the Confirm step's "Confirm Import" button, so onImport fired once on Preview and again on Confirm — committing every row twice. The fix splits the callback into a side-effect-free goToConfirm (Preview) and a guarded commitImport (Confirm), so onImport runs exactly once per completed wizard run.

Related Issue

Changes

🐛 CSV Import Wizard Fix

  • [MODIFY] src/components/RevenueCalendarCsvImport.tsx

    • Split handleConfirm into goToConfirm (Preview button — advances to Confirm, no side effects) and commitImport (Confirm button — calls onImport(cleanRows)).
    • Added an isCommitting/committed guard so double-clicks or Enter-repeat cannot invoke onImport more than once; the Confirm button is disabled while committing.
    • After commit, render a terminal "Imported N rows" state instead of re-rendering the actionable Confirm step.
  • [MODIFY] src/components/BlacklistCsvImport.tsx

    • Same split and guard applied to the equivalent handleConfirm flow, with the Preview Import button wired to goToConfirm and the Confirm step wired to commitImport.
  • [MODIFY] src/components/RevenueCalendarCsvImport.test.tsx

    • Regression tests: Preview→Import does not call onImport; Confirm calls it once; double-click on Confirm still calls it once.
  • [MODIFY] src/components/BlacklistCsvImport.test.tsx

    • Same regression coverage for the blacklist wizard.

Verification Results

npm test -- src/components/RevenueCalendarCsvImport.test.tsx
npm test -- src/components/BlacklistCsvImport.test.tsx
✅ Preview→Import does not call onImport
✅ Confirm calls onImport exactly once
✅ Double-click on Confirm still calls onImport once
✅ Terminal "Imported N rows" state rendered after commit
Acceptance Criteria Status
onImport is called exactly once per completed wizard run in both components ✅ Split goToConfirm / commitImport with commit guard
Tests: Preview→Import does not call onImport; Confirm calls it once; double-click still calls it once ✅ Added to both component test files
A regression test that fails on current master and passes after the fix ✅ Duplicate-call regression covered in both suites
No behaviour change outside the stated scope; CI stays green ✅ Changes limited to the two wizards and their tests

Closes #912

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@Micheal1605 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(csv-import): Revenue calendar and blacklist CSV wizards call onImport twice, duplicating every imported row

1 participant