Skip to content

Refactor duplicated FieldInfo component into shared module #46

@eberrigan

Description

@eberrigan

Problem

The FieldInfo component is duplicated in three different files instead of being imported from a shared location:

  1. app/src/renderer/FieldInfo.tsx (standalone file)
  2. app/src/renderer/Accessions.tsx (line 23)
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions