Skip to content

refactor(import): event-driven CSV validation + improved warning messages#769

Open
afadil wants to merge 3 commits intomainfrom
refactor/import-event-driven-validation
Open

refactor(import): event-driven CSV validation + improved warning messages#769
afadil wants to merge 3 commits intomainfrom
refactor/import-event-driven-validation

Conversation

@afadil
Copy link
Owner

@afadil afadil commented Mar 19, 2026

Summary

  • Event-driven initialization: draft creation and backend validation now fire in handleNext (mapping→review transition) instead of a useEffect inside ReviewStep. Eliminates the React Strict Mode double-invoke workaround (hasInitiatedRef).
  • validateDrafts moved to ImportProvider: single shared instance with one validationRunRef race-condition guard, used by both handleNext and handleSymbolResolution.
  • isValidating moved to context state: ReviewStep mounts with the spinner already showing (validation was started by the parent before the step animated in).
  • ReviewStep is now purely presentational: no useEffect, no local validation state, no useRef guards.
  • Pure helpers extracted to utils/draft-utils.ts (parseDateValue, mapActivityType, mapSymbol, validateDraft, createDraftActivities, etc.) so both the parent and future consumers can call them without importing from a step component.
  • Warning tooltip fix: keys prefixed with _ (internal keys like _quote_ccy_fallback) no longer appear as a label in the tooltip — only the message is shown.
  • Improved warning message: _quote_ccy_fallback now reads "SXLK price currency was inferred as USD from the exchange. Please confirm it is correct."

Test plan

  • Upload CSV → mapping step → click Next → review step shows spinner immediately → grid populates when backend returns
  • Resolve an unresolved symbol → grid re-validates without duplicate backend calls
  • Go back to mapping → click Next again → fresh validation fires (no stale state)
  • Dev mode (Strict Mode): only one check_activities_import call in logs per Next click
  • Warning tooltip for currency-inferred symbols shows symbol name, currency, and no _quote_ccy_fallback prefix

afadil added 2 commits March 19, 2026 14:13
- Mobile: replace text filter button with icon-only, placed next to period selector
- Desktop: reduce account selector height to h-9 to match period toggle
…ages

Move draft creation and backend validation out of ReviewStep's useEffect
and into handleNext (mapping→review transition), making initialization
event-driven and eliminating the Strict Mode double-invoke workaround.

- Extract pure helpers (parseDateValue, mapActivityType, mapSymbol,
  validateDraft, createDraftActivities, etc.) to utils/draft-utils.ts
- Move validateDrafts + isValidating into ImportProvider so both
  handleNext and handleSymbolResolution share one instance with one
  race-condition guard (validationRunRef)
- ReviewStep becomes purely presentational: no useEffect, no local
  validation state, reads isValidating from context
- Fix warning tooltip to suppress internal key prefixes (keys starting
  with '_' show message only)
- Improve _quote_ccy_fallback warning to include symbol and inferred
  currency: "SXLK price currency was inferred as USD from the exchange."
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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.

1 participant