mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
dev day #65,5
This commit is contained in:
@@ -22,6 +22,8 @@ type MatchItem = {
|
||||
time: string; // HH:MM
|
||||
home: string;
|
||||
away: string;
|
||||
home_id?: string;
|
||||
away_id?: string;
|
||||
venue?: string;
|
||||
home_logo_url?: string;
|
||||
away_logo_url?: string;
|
||||
@@ -51,6 +53,7 @@ const CalendarPage: React.FC = () => {
|
||||
const [searchParams] = useSearchParams();
|
||||
const toast = useToast();
|
||||
const [clubName, setClubName] = useState<string>('');
|
||||
const [clubId, setClubId] = useState<string>('');
|
||||
const [clubType, setClubType] = useState<'football' | 'futsal'>('football');
|
||||
const [standings, setStandings] = useState<any[]>([]);
|
||||
|
||||
@@ -264,6 +267,8 @@ const CalendarPage: React.FC = () => {
|
||||
time,
|
||||
home: m.home,
|
||||
away: m.away,
|
||||
home_id: m.home_id,
|
||||
away_id: m.away_id,
|
||||
venue: m.venue,
|
||||
home_logo_url: getOverrideLogo(m.home, m.home_logo_url),
|
||||
away_logo_url: getOverrideLogo(m.away, m.away_logo_url),
|
||||
@@ -307,6 +312,8 @@ const CalendarPage: React.FC = () => {
|
||||
time,
|
||||
home: m.home,
|
||||
away: m.away,
|
||||
home_id: m.home_id,
|
||||
away_id: m.away_id,
|
||||
venue: m.venue,
|
||||
home_logo_url: getOverrideLogo(m.home, m.home_logo_url),
|
||||
away_logo_url: getOverrideLogo(m.away, m.away_logo_url),
|
||||
@@ -399,6 +406,7 @@ const CalendarPage: React.FC = () => {
|
||||
setCompLinks(compLinkMap);
|
||||
setStandings(standingsData);
|
||||
if (json?.name) setClubName(String(json.name));
|
||||
if (json?.club_internal_id) setClubId(String(json.club_internal_id));
|
||||
if (json?.club_type) setClubType(json.club_type);
|
||||
// Set active tab from query ?comp=<id>
|
||||
const compQ = searchParams.get('comp');
|
||||
@@ -521,8 +529,21 @@ const CalendarPage: React.FC = () => {
|
||||
|
||||
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; // unknown perspective
|
||||
if (s.h === s.a) return { label: 'Remíza', color: 'blue' };
|
||||
const ourGoals = ourIsHome ? s.h : s.a;
|
||||
|
||||
Reference in New Issue
Block a user