mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-03 18:22:57 +00:00
3.2 KiB
3.2 KiB
Logo API Implementation Summary
Overview
Updated the HomePage to prioritize logoapi.sportcreative.eu for all team logos with FACR as fallback.
Changes Made
1. HomePage.tsx - State Management
- Added
clubIdstate to store the club's UUID - Extract
club_idfrom settings and store it
2. Logo URL Generation Strategy
Priority Order:
- LogoAPI (if team_id available):
http://logoapi.sportcreative.eu/logos/{team_id}?format=svg - Local Overrides (from team logo overrides table)
- FACR Original (fallback when logoapi doesn't have the logo)
3. Updated Functions
displayClubLogo (memoized)
// Now generates logoapi URL for main club logo
if (clubId) {
return `http://logoapi.sportcreative.eu/logos/${clubId}?format=svg`;
}
getOverrideLogo(teamName?, teamId?, original?)
- Takes team ID as second parameter
- Returns logoapi URL if team_id is available
- Falls back to local overrides or FACR URL
getFallbackLogo(teamName?, original?)
- Helper function to get fallback logo
- Checks local overrides first
- Returns FACR original as final fallback
4. Data Structure Updates
Matches Data
- Now extracts
home_idandaway_idfrom FACR API - Passes team IDs to
getOverrideLogo() - Logo URLs now point to logoapi with fallback chain
Tables/Standings Data
- Extracts
team_idfrom FACR table data - Stores both
team_nameandteam_id - Logo URLs use logoapi when team_id is available
5. Logo Usage Points
All logo <img> tags throughout the homepage now use:
- Club logo header: Uses
displayClubLogo(logoapi) - Match cards: Uses
home_logo_url/away_logo_urlwith logoapi - Tables/Standings: Uses
logo_urlwith logoapi - Next match section: All team logos use logoapi pattern
How It Works
Example Flow:
- User visits homepage
- Settings load →
club_idextracted (7eacd9f0-bfa0-4928-a9b6-936140168f58) - Club logo displays:
http://logoapi.sportcreative.eu/logos/7eacd9f0-bfa0-4928-a9b6-936140168f58?format=svg - Browser requests logo from logoapi
- If logoapi has it → ✓ Displays
- If logoapi doesn't have it → Browser's native error handling would need fallback
Browser Behavior
- When logoapi returns 404, the browser shows broken image
- Note: For full fallback support,
onErrorhandlers should be added to<img>tags - This would require storing fallback URL alongside primary URL
Testing Checklist
- Club logo displays in header (logoapi)
- Match team logos display (logoapi with team IDs)
- Table team logos display (logoapi with team IDs)
- Logos fallback to FACR when logoapi doesn't have them
- Local overrides still work correctly
- All layouts (unified, magazine, pro, edge) work correctly
Future Enhancements
Add onError handlers to images for automatic fallback:
<img
src={logoapi_url}
onError={(e) => {
e.currentTarget.src = facr_fallback_url;
}}
/>
Files Modified
frontend/src/pages/HomePage.tsx
Related Systems
- Logo API:
utils/sportLogosAPI.ts - Team Logo Overrides: Admin matches/teams pages
- FACR Integration: Fetches team IDs automatically