Skip to content

Conversation

@alexcerezo
Copy link
Member

image

@alexcerezo alexcerezo merged commit 224f0b9 into ghspain:main Aug 25, 2025
@svg153 svg153 linked an issue Aug 25, 2025 that may be closed by this pull request
svg153 pushed a commit that referenced this pull request Oct 27, 2025
svg153 added a commit that referenced this pull request Oct 27, 2025
- Fix image paths: change absolute (/images...) to relative (images...)
  This ensures images load correctly when app is deployed to subdirectories

- Add PUBLIC_URL validation and path handling in both RiverSection and OrganizerList
  Prevents errors if PUBLIC_URL is undefined or empty string

- Add ARIA roles for accessibility
  role='status' for loading state
  role='alert' for error state
  Improves screen reader experience

Addresses Copilot review comments #1, #2, #3, #4
svg153 added a commit that referenced this pull request Oct 27, 2025
* PR-2: Add organizers data and components (organizers.json, type, OrganizerList, OrganizerSummary, RiverSection, River styles)

* refactor: improve organizers components and remove unused code

- Remove unused OrganizerSummary component
- Refactor OrganizerList: improve variable naming and remove unused React import
- Refactor RiverSection: consolidate state management into single state object
- Add comprehensive JSDoc comments to Organizer type definition
- Clean up CSS: remove misleading comments about removed unused styles
- Improve error handling with more descriptive error messages
- Better code organization and readability

* fix: address code review comments - improve robustness and accessibility

- Fix image paths: change absolute (/images...) to relative (images...)
  This ensures images load correctly when app is deployed to subdirectories

- Add PUBLIC_URL validation and path handling in both RiverSection and OrganizerList
  Prevents errors if PUBLIC_URL is undefined or empty string

- Add ARIA roles for accessibility
  role='status' for loading state
  role='alert' for error state
  Improves screen reader experience

Addresses Copilot review comments #1, #2, #3, #4

* refactor: extract data loading logic into utility functions

- Extract buildDataUrl() function for URL construction
  Isolates PUBLIC_URL handling logic and makes it reusable

- Extract fetchOrganizers() function for API call
  Separates fetch logic from React component state management
  Improves testability and reusability

- Simplify loadOrganizers() in useEffect
  Now focused solely on state management
  More readable and maintainable

Benefits:
  • Single Responsibility Principle
  • Better code organization
  • Easier to test
  • Reusable functions for future features
  • Clearer component intent

* refactor: separate concerns into services and hooks layers

Create clean architecture:

Services layer (src/services/):
  • organizers.ts - Pure functions for API calls and URL building
    - buildOrganizerDataUrl(): Constructs URL with PUBLIC_URL handling
    - fetchOrganizerData(): Fetches organizers from API
  • index.ts - Public API exports

Hooks layer (src/hooks/):
  • useOrganizers.ts - Custom hook for state management
    - useOrganizers(): Handles loading, error, and data states
    - Encapsulates all side effects
  • index.ts - Public API exports

Components layer (simplified):
  • RiverSection.tsx - Now purely presentational
    - Uses useOrganizers hook
    - No business logic
    - Only renders UI

Benefits:
  • Separation of concerns (services, hooks, components)
  • Easy to test (pure functions in services)
  • Reusable (hooks can be used in other components)
  • Better file organization
  • Clear data flow
  • Single Responsibility Principle

* fix: improve accessibility with better alt text and aria-live

- Update img alt text in OrganizerList
  From: alt={organizer.name}
  To: alt={`Profile photo of ${organizer.name}`}
  Reason: More descriptive alt text for screen readers

- Add aria-live='polite' to loading status
  <div role="status" aria-live="polite">Cargando…</div>
  Reason: Announces loading state to assistive technologies

Addresses Copilot review comments on accessibility improvements

* refactor: eliminate code duplication and improve UX

Remove duplicated code:
- Extract PUBLIC_URL handling to src/utils/publicUrl.ts
- Create getBasePath() utility function
- Use in both services and components

Move getImageUrl() to services:
- Extract getOrganizerImageUrl() to src/services/organizers.ts
- Better separation of concerns
- Easier to test and reuse

Improve user experience:
- Better error message in RiverSection
- Add validation for empty organizers array
- Show friendly fallback message

Benefits:
- DRY principle: No duplicated logic
- Better maintainability: Single source of truth
- Improved UX: Friendly error messages
- Better edge case handling

* fix: add missing React import in RiverSection

- React.FC type requires importing React
- Add: import React from 'react'
- Addresses Copilot review comment

* Fix: import React namespace for React.FC in RiverSection
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.

Propuesta de nueva web usando estilos de GitHub

1 participant