mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 11:12:56 +00:00
de day #74
This commit is contained in:
@@ -13,6 +13,7 @@ import { sortCategoriesWithOrder } from '../utils/categorySort';
|
||||
import ClubModal from '../components/home/ClubModal';
|
||||
import { assetUrl } from '../utils/url';
|
||||
import { API_URL } from '../services/api';
|
||||
import { TeamLogo } from '../components/common/TeamLogo';
|
||||
|
||||
// Weekday headers (Czech, starting Monday)
|
||||
const WEEKDAYS_SHORT: string[] = ['Po', 'Út', 'St', 'Čt', 'Pá', 'So', 'Ne'];
|
||||
@@ -226,9 +227,16 @@ const CalendarPage: React.FC = () => {
|
||||
} catch {}
|
||||
}
|
||||
const byName: Record<string, string> = (overrides?.by_name || {}) as any;
|
||||
const byId: Record<string, { name?: string; logo_url?: string }> = (overrides?.by_id || {}) as any;
|
||||
const byNameNormalized: Record<string, string> = Object.keys(byName || {}).reduce((acc: Record<string, string>, k: string) => { acc[normalize(k)] = byName[k]; return acc; }, {});
|
||||
const byNameStrippedPairs: Array<{ keyNorm: string; url: string }> = Object.keys(byName || {}).map((k: string) => ({ keyNorm: stripPrefixes(k), url: byName[k] }));
|
||||
const getOverrideLogo = (teamName?: string, original?: string) => {
|
||||
const getOverrideLogo = (teamName?: string, original?: string, teamId?: string) => {
|
||||
// Prefer admin override by ID
|
||||
if (teamId && byId?.[teamId]?.logo_url) {
|
||||
const v = byId[teamId]!.logo_url as string;
|
||||
if (typeof v === 'string' && v.startsWith('/')) return resolveBackendUrl(v);
|
||||
return v;
|
||||
}
|
||||
if (!teamName) return original;
|
||||
const exact = (byName || {})[teamName];
|
||||
const normName = normalize(teamName);
|
||||
@@ -260,17 +268,19 @@ const CalendarPage: React.FC = () => {
|
||||
const isoDate = (day && month && year) ? `${year}-${month.padStart(2,'0')}-${day.padStart(2,'0')}` : new Date().toISOString().slice(0,10);
|
||||
const time = (t || '00:00').slice(0,5);
|
||||
const score = (m.score || m.result || (typeof m.goals_home === 'number' && typeof m.goals_away === 'number' ? `${m.goals_home}:${m.goals_away}` : '') || '').toString();
|
||||
const homeName = (byId?.[m.home_id]?.name && String(byId[m.home_id].name).trim()) ? String(byId[m.home_id].name) : m.home;
|
||||
const awayName = (byId?.[m.away_id]?.name && String(byId[m.away_id].name).trim()) ? String(byId[m.away_id].name) : m.away;
|
||||
return {
|
||||
id: m.match_id || `${cIdx}-${idx}`,
|
||||
date: isoDate,
|
||||
time,
|
||||
home: m.home,
|
||||
away: m.away,
|
||||
home: homeName,
|
||||
away: awayName,
|
||||
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),
|
||||
home_logo_url: getOverrideLogo(homeName, m.home_logo_url, m.home_id),
|
||||
away_logo_url: getOverrideLogo(awayName, m.away_logo_url, m.away_id),
|
||||
report_url: m.report_url,
|
||||
facr_link: m.facr_link,
|
||||
score: score && /\d+\s*:\s*\d+/.test(score) ? score.replace(/\s+/g,'') : undefined,
|
||||
@@ -309,13 +319,13 @@ const CalendarPage: React.FC = () => {
|
||||
id: m.match_id || `${cIdx}-${idx}`,
|
||||
date: isoDate,
|
||||
time,
|
||||
home: m.home,
|
||||
away: m.away,
|
||||
home: (byId?.[m.home_id]?.name && String(byId[m.home_id].name).trim()) ? String(byId[m.home_id].name) : m.home,
|
||||
away: (byId?.[m.away_id]?.name && String(byId[m.away_id].name).trim()) ? String(byId[m.away_id].name) : 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),
|
||||
home_logo_url: getOverrideLogo(m.home, m.home_logo_url, m.home_id),
|
||||
away_logo_url: getOverrideLogo(m.away, m.away_logo_url, m.away_id),
|
||||
report_url: m.report_url,
|
||||
score: score && /\d+\s*:\s*\d+/.test(score) ? score.replace(/\s+/g,'') : undefined,
|
||||
} as MatchItem;
|
||||
@@ -381,7 +391,7 @@ const CalendarPage: React.FC = () => {
|
||||
})();
|
||||
return {
|
||||
position: Number(r.rank || idx + 1),
|
||||
team_name: teamName,
|
||||
team_name: (teamId && byId?.[teamId]?.name && String(byId[teamId].name).trim()) ? String(byId[teamId].name) : teamName,
|
||||
team_id: teamId,
|
||||
points: Number(r.points || r.pts || 0),
|
||||
played: Number(r.played || r.matches || 0),
|
||||
@@ -390,7 +400,7 @@ const CalendarPage: React.FC = () => {
|
||||
losses: Number(r.losses || r.loss || 0),
|
||||
goals_for: Number(r.goals_for ?? r.gf ?? r.goalsFor ?? r.scored ?? r.goals ?? 0),
|
||||
goals_against: Number(r.goals_against ?? r.ga ?? r.goalsAgainst ?? r.conceded ?? 0),
|
||||
logo_url: r.team_logo_url || undefined,
|
||||
logo_url: (teamId && byId?.[teamId]?.logo_url) ? String(byId[teamId].logo_url) : (r.team_logo_url || undefined),
|
||||
};
|
||||
}),
|
||||
}));
|
||||
@@ -660,10 +670,26 @@ const CalendarPage: React.FC = () => {
|
||||
<Badge colorScheme="purple">{m.__compName || c.name}</Badge>
|
||||
</Flex>
|
||||
<Flex align="center" gap={2} justify="center">
|
||||
{m.home_logo_url && <Image src={m.home_logo_url} alt={m.home} boxSize="18px" borderRadius="full" objectFit="cover" />}
|
||||
<TeamLogo
|
||||
teamId={m.home_id}
|
||||
teamName={m.home}
|
||||
facrLogo={m.home_logo_url}
|
||||
size="custom"
|
||||
boxSize="18px"
|
||||
alt={m.home}
|
||||
borderRadius="full"
|
||||
/>
|
||||
<Text fontSize="sm">{m.home}</Text>
|
||||
<Badge colorScheme={getSentiment(m)?.color || 'gray'}>{m.score || 'vs'}</Badge>
|
||||
{m.away_logo_url && <Image src={m.away_logo_url} alt={m.away} boxSize="18px" borderRadius="full" objectFit="cover" />}
|
||||
<TeamLogo
|
||||
teamId={m.away_id}
|
||||
teamName={m.away}
|
||||
facrLogo={m.away_logo_url}
|
||||
size="custom"
|
||||
boxSize="18px"
|
||||
alt={m.away}
|
||||
borderRadius="full"
|
||||
/>
|
||||
<Text fontSize="sm">{m.away}</Text>
|
||||
</Flex>
|
||||
{href && <Link href={href} isExternal onClick={(e)=> e.stopPropagation()} display="none"/>}
|
||||
|
||||
Reference in New Issue
Block a user