Problem
The FieldInfo component is duplicated in three different files instead of being imported from a shared location:
app/src/renderer/FieldInfo.tsx (standalone file)
app/src/renderer/Accessions.tsx (line 23)
app/src/renderer/CaptureScan.tsx (line 833)
Current State
- The component displays an info icon with a hover tooltip
- Identical implementation copy-pasted in multiple locations
- Changes to one instance don't affect the others
- Violates DRY (Don't Repeat Yourself) principle
Impact
- Maintenance burden: Bug fixes or improvements must be made in three places
- Inconsistency risk: Components may drift apart over time
- Testing complexity: Need to test multiple copies of the same component
- Code bloat: Unnecessary duplication increases bundle size
Proposed Solution
Step 1: Use the existing FieldInfo.tsx as the single source
// app/src/renderer/FieldInfo.tsx
export function FieldInfo({ info }: { info: string }) {
// Current implementation
}
Step 2: Remove duplicates and import instead
// app/src/renderer/Accessions.tsx
import { FieldInfo } from './FieldInfo';
// Remove the duplicate function definition at line 23
// app/src/renderer/CaptureScan.tsx
import { FieldInfo } from './FieldInfo';
// Remove the duplicate function definition at line 833
Step 3: Verify all usages work correctly
The component is used in the following locations:
- Accessions.tsx: 4 usages (lines 397, 421, 564 commented)
- CaptureScan.tsx: 8 usages (lines 384, 400, 437, 464, 491, 546, 585, 593, 647)
Benefits
- Single source of truth for the component
- Easier to maintain and test
- Reduced code duplication
- Consistent behavior across the application
Testing
- Existing test in
FieldInfo.test.tsx already covers the component
- After refactoring, all usages will be tested through the single implementation
Priority
Medium - This is a code quality issue that should be addressed but isn't blocking functionality
Problem
The
FieldInfocomponent is duplicated in three different files instead of being imported from a shared location:app/src/renderer/FieldInfo.tsx(standalone file)app/src/renderer/Accessions.tsx(line 23)app/src/renderer/CaptureScan.tsx(line 833)Current State
Impact
Proposed Solution
Step 1: Use the existing FieldInfo.tsx as the single source
Step 2: Remove duplicates and import instead
Step 3: Verify all usages work correctly
The component is used in the following locations:
Benefits
Testing
FieldInfo.test.tsxalready covers the componentPriority
Medium - This is a code quality issue that should be addressed but isn't blocking functionality