flexion / ef-cms

An Electronic Filing / Case Management System.
23 stars 10 forks source link

Refactor file selection components #10486

Open Mwindo opened 2 months ago

Mwindo commented 2 months ago

Our file input components (StateDrivenFileInput.tsx, ScanBatchPreview.tsx, and PetitionQcBatchScanPreview.tsx) can be improved. For instance: StateDrivenFileInput has multiple things happening on click, hard-codes what sequences to run on file change (rather than being agnostic), has overlap with ScanBatchPreview.tsx that we might be able exploit, etc.

PetitionQcBatchScanPreview.tsx has code for accepting files, but as far as I can tell (and after discussion with Chris H.), it doesn't seem like this should ever be allowed. It might be a copy-paste or refactoring artifact.

Goals:

  1. StateDrivenFileInput and ScanBatchPreview are refactored so that they use the same file selector input if possible. (In other words, there is only one component with the accept='.pdf attribute.)
  2. PetitionQcBatchScanPreview is refactored so that it does not have unnecessary code. Maybe we can get rid of this component altogether and have a readonly mode for ScanBatchPreview.
  3. Unnecessary props are removed from the components.
  4. The input component(s) that results after the above refactor can take in whatever sequence/function/etc. we want for onFileChange so that the component can be reused more easily and is less coupled to our state management library.
  5. Pull the file validation logic into sequences/actions if deemed worth the effort.