dev day #65,5

This commit is contained in:
Tomas Dvorak
2025-10-20 10:40:55 +02:00
parent 9ccca365b3
commit 68e69e00cc
41 changed files with 981 additions and 1376 deletions
+20 -3
View File
@@ -15,6 +15,8 @@ type MatchItem = {
time: string;
home: string;
away: string;
home_id?: string;
away_id?: string;
home_logo_url?: string;
away_logo_url?: string;
score?: string | null;
@@ -23,7 +25,7 @@ type MatchItem = {
venue?: string;
competition?: string;
competitionName?: string;
};
}
const MatchesPage: React.FC = () => {
const [clubName, setClubName] = useState<string>('');
@@ -115,8 +117,21 @@ const MatchesPage: React.FC = () => {
const getSentiment = (m: MatchItem): { label: 'Výhra'|'Remíza'|'Prohra'; colorScheme: 'green'|'blue'|'red' } | null => {
const s = parseScore(m.score);
if (!s) return null;
const ourIsHome = isClubTeam(m.home);
const ourIsAway = isClubTeam(m.away);
// First try ID-based matching (most reliable)
let ourIsHome = false;
let ourIsAway = false;
if (clubId && m.home_id && m.away_id) {
ourIsHome = m.home_id === clubId;
ourIsAway = m.away_id === clubId;
}
// Fallback to name matching if IDs not available or no match
if (!ourIsHome && !ourIsAway) {
ourIsHome = isClubTeam(m.home);
ourIsAway = isClubTeam(m.away);
}
if (!ourIsHome && !ourIsAway) return null;
if (s.h === s.a) return { label: 'Remíza', colorScheme: 'blue' };
const ourGoals = ourIsHome ? s.h : s.a;
@@ -343,6 +358,8 @@ const MatchesPage: React.FC = () => {
time,
home: m.home,
away: m.away,
home_id: m.home_id,
away_id: m.away_id,
home_logo_url: getOverrideLogo(m.home, m.home_id, m.home_logo_url),
away_logo_url: getOverrideLogo(m.away, m.away_id, m.away_logo_url),
score: actualScore,