diff --git a/bridge/package.json b/bridge/package.json index c40874e..effa216 100644 --- a/bridge/package.json +++ b/bridge/package.json @@ -9,8 +9,8 @@ "build": "tsc", "start": "node dist/server.js", "typecheck": "tsc --noEmit", - "test": "npm run build && node --test dist/services/ranking.test.js dist/services/aggregator-mapper.test.js dist/services/fpa-stream-match.test.js", - "test:coverage": "npm run build && node --experimental-test-coverage --test dist/services/ranking.test.js dist/services/aggregator-mapper.test.js dist/services/fpa-stream-match.test.js" + "test": "npm run build && node --test dist/services/ranking.test.js dist/services/aggregator-mapper.test.js dist/services/andeboltv.test.js", + "test:coverage": "npm run build && node --experimental-test-coverage --test dist/services/ranking.test.js dist/services/aggregator-mapper.test.js dist/services/andeboltv.test.js" }, "dependencies": { "@fastify/cors": "^9.0.1", diff --git a/bridge/src/routes/homepage.ts b/bridge/src/routes/homepage.ts index e53f3ae..5215fc0 100644 --- a/bridge/src/routes/homepage.ts +++ b/bridge/src/routes/homepage.ts @@ -3,11 +3,7 @@ import { get_domain_config } from '../config/domain.js'; import { resolve_site_host } from '../lib/request-host.js'; import { WpClient } from '../services/wp-client.js'; import { swr_fetch } from '../services/cache.js'; -import type { ArticleListItem, FpaAgendaGame, HomepageData } from '../types.js'; -import type { AndebolTvStreamEvent } from '../services/andeboltv.js'; -import { fetch_andeboltv_stream_events } from '../services/andeboltv.js'; -import { fetch_fpa_agenda } from '../services/fpa-agenda.js'; -import { enrich_fpa_agenda_with_streams } from '../services/fpa-stream-match.js'; +import type { ArticleListItem, HomepageData } from '../types.js'; // Number of articles per section const HERO_COUNT = 3; @@ -67,7 +63,7 @@ function take_unique_ids(pool: ArticleListItem[], limit: number): ArticleListIte return out; } -const empty_homepage = (): Omit => ({ +const empty_homepage = (): HomepageData => ({ hero: [], trending: [], featured: [], @@ -81,7 +77,7 @@ export async function homepage_routes(app: FastifyInstance): Promise { const config = get_domain_config(host); const client = new WpClient(config.wp_endpoint); - const base = await swr_fetch>( + const base = await swr_fetch( `${host}:homepage`, async () => { try { @@ -137,30 +133,7 @@ export async function homepage_routes(app: FastifyInstance): Promise { }, ); - const fpa_agenda: FpaAgendaGame[] | null = config.fpa_agenda_enabled - ? await swr_fetch(`${host}:fpa:agenda`, async () => { - try { - const [games, streams] = await Promise.all([ - fetch_fpa_agenda(), - swr_fetch(`${host}:andeboltv:streams`, async () => { - try { - return await fetch_andeboltv_stream_events(); - } catch (err) { - app.log.warn({ err, host }, 'AndebolTV stream fetch failed'); - return []; - } - }), - ]); - return enrich_fpa_agenda_with_streams(games, streams); - } catch (err) { - app.log.warn({ err, host }, 'FPA agenda fetch failed'); - return []; - } - }) - : null; - - const data: HomepageData = { ...base, fpa_agenda }; - return reply.send(data); + return reply.send(base); }); // GET /trending — convenience endpoint diff --git a/bridge/src/services/andeboltv.test.ts b/bridge/src/services/andeboltv.test.ts new file mode 100644 index 0000000..6695178 --- /dev/null +++ b/bridge/src/services/andeboltv.test.ts @@ -0,0 +1,21 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { pixellot_ms_to_lisbon_date } from './andeboltv.js'; + +test('pixellot_ms_to_lisbon_date formats in Europe/Lisbon', () => { + // 2026-07-17 12:00 UTC → same calendar day in Lisbon (summer) + const ms = Date.UTC(2026, 6, 17, 12, 0, 0); + assert.equal(pixellot_ms_to_lisbon_date(ms), '2026-07-17'); +}); + +test('AndebolTV portal URLs must use event_id not reference_id (BIT-26487)', () => { + const reference_id = '6a4b765f3a96ca9f5ea73ea3'; + const event_id = '6a4b765f90f0fd82fea4e75a'; + const portal = 'https://andeboltv.fpa.pt'; + + const wrong = `${portal}/events/${encodeURIComponent(reference_id)}`; + const correct = `${portal}/events/${encodeURIComponent(event_id)}`; + + assert.notEqual(wrong, correct); + assert.equal(correct, 'https://andeboltv.fpa.pt/events/6a4b765f90f0fd82fea4e75a'); +}); diff --git a/bridge/src/services/fpa-agenda.ts b/bridge/src/services/fpa-agenda.ts deleted file mode 100644 index f6a2c7f..0000000 --- a/bridge/src/services/fpa-agenda.ts +++ /dev/null @@ -1,136 +0,0 @@ -import type { FpaAgendaGame } from '../types.js'; - -/** Public FPA JSON feed used by portal.fpa.pt for national competition fixtures. */ -const FPA_AGENDA_URL = - process.env['FPA_AGENDA_URL'] ?? 'https://ws.fpa.pt/index.php/getAgendaJogosFAP/'; - -const FPA_CLUBE_URL_BASE = - process.env['FPA_CLUBE_URL_BASE'] ?? 'https://ws.fpa.pt/index.php/getClube/'; - -const FETCH_TIMEOUT_MS = parseInt(process.env['FPA_FETCH_TIMEOUT_MS'] ?? '20000', 10); -const MAX_GAMES = Math.min(parseInt(process.env['FPA_AGENDA_MAX'] ?? '48', 10), 200); - -interface ParsedFpaGame extends FpaAgendaGame { - home_club_id: string; - away_club_id: string; -} - -function as_trimmed_string(value: unknown): string { - if (value === null || value === undefined) { - return ''; - } - return String(value).trim(); -} - -function parse_goals(value: unknown): number | null { - if (value === null || value === undefined || value === '') { - return null; - } - const n = Number(value); - return Number.isFinite(n) ? n : null; -} - -function sort_key(date: string, time: string): string { - return `${date} ${time}`.padEnd(20, '0'); -} - -async function fetch_club_logo_url(club_id: string): Promise { - const res = await fetch(`${FPA_CLUBE_URL_BASE}${encodeURIComponent(club_id)}`, { - headers: { Accept: 'application/json' }, - signal: AbortSignal.timeout(FETCH_TIMEOUT_MS), - }); - - if (!res.ok) { - return null; - } - - const raw: unknown = await res.json(); - if (!Array.isArray(raw) || raw.length === 0 || raw[0] === null || typeof raw[0] !== 'object') { - return null; - } - - const emblem = as_trimmed_string((raw[0] as Record)['URL_EMBLEMA_CASA']); - return emblem || null; -} - -async function resolve_club_logos(club_ids: Iterable): Promise> { - const unique = [...new Set([...club_ids].filter(Boolean))]; - const logos = new Map(); - - await Promise.all( - unique.map(async (club_id) => { - try { - logos.set(club_id, await fetch_club_logo_url(club_id)); - } catch { - logos.set(club_id, null); - } - }), - ); - - return logos; -} - -/** - * Fetch and normalise FPA agenda JSON. Caller should wrap in cache (e.g. swr_fetch). - * Throws on network/HTTP errors or invalid payload shape. - */ -export async function fetch_fpa_agenda(): Promise { - const res = await fetch(FPA_AGENDA_URL, { - headers: { Accept: 'application/json' }, - signal: AbortSignal.timeout(FETCH_TIMEOUT_MS), - }); - - if (!res.ok) { - throw new Error(`FPA agenda HTTP ${res.status}`); - } - - const raw: unknown = await res.json(); - if (!Array.isArray(raw)) { - throw new Error('FPA agenda: expected JSON array'); - } - - const games: ParsedFpaGame[] = []; - - for (const row of raw) { - if (row === null || typeof row !== 'object') { - continue; - } - const o = row as Record; - const match_id = as_trimmed_string(o['ID_PROVA_JOGO']); - const date = as_trimmed_string(o['JOG_DATA']); - const time = as_trimmed_string(o['JOG_HORA']); - if (!match_id || !date) { - continue; - } - - games.push({ - match_id, - date, - time: time || '—', - home_team: as_trimmed_string(o['EQUIPA_CASA']) || '—', - away_team: as_trimmed_string(o['EQUIPA_FORA']) || '—', - home_goals: parse_goals(o['GOLOS_CASA']), - away_goals: parse_goals(o['GOLOS_FORA']), - venue: as_trimmed_string(o['LOCAL']) || '—', - competition: as_trimmed_string(o['PROVA']) || '—', - phase: as_trimmed_string(o['FASE']) || '', - home_logo_url: null, - away_logo_url: null, - home_club_id: as_trimmed_string(o['CLUBE_CASA_ID']), - away_club_id: as_trimmed_string(o['CLUBE_FORA_ID']), - }); - } - - games.sort((a, b) => sort_key(a.date, a.time).localeCompare(sort_key(b.date, b.time))); - const limited = games.slice(0, MAX_GAMES); - - const logos = await resolve_club_logos( - limited.flatMap((g) => [g.home_club_id, g.away_club_id]), - ); - - return limited.map(({ home_club_id, away_club_id, ...game }) => ({ - ...game, - home_logo_url: home_club_id ? logos.get(home_club_id) ?? null : null, - away_logo_url: away_club_id ? logos.get(away_club_id) ?? null : null, - })); -} diff --git a/bridge/src/services/fpa-stream-match.test.ts b/bridge/src/services/fpa-stream-match.test.ts deleted file mode 100644 index f6304cc..0000000 --- a/bridge/src/services/fpa-stream-match.test.ts +++ /dev/null @@ -1,88 +0,0 @@ -import test from 'node:test'; -import assert from 'node:assert/strict'; -import { - enrich_fpa_agenda_with_streams, - find_stream_for_game, - teams_match_pair, - teams_overlap, -} from './fpa-stream-match.js'; -import type { AndebolTvStreamEvent } from './andeboltv.js'; -import type { FpaAgendaGame } from '../types.js'; - -test('teams_overlap matches national team shorthand', () => { - assert.equal(teams_overlap('PORTUGAL', 'Portugal M18'), true); - assert.equal(teams_overlap('ALEMANHA', 'Germany M18'), true); -}); - -test('teams_match_pair accepts swapped home/away', () => { - assert.equal(teams_match_pair('Benfica', 'Porto', 'FC Porto', 'SL Benfica'), true); -}); - -test('find_stream_for_game matches by date and team names', () => { - const game: FpaAgendaGame = { - match_id: '1', - date: '2026-07-17', - time: '19:00', - home_team: 'PORTUGAL', - away_team: 'ALEMANHA', - home_goals: null, - away_goals: null, - venue: 'Maia', - competition: 'Seleções', - phase: 'Sub-18', - home_logo_url: null, - away_logo_url: null, - }; - - const streams: AndebolTvStreamEvent[] = [ - { - reference_id: 'abc', - event_id: 'abc', - home_team: 'Portugal M18', - away_team: 'Germany M18', - date: '2026-07-17', - status: 'upcoming', - stream_url: 'https://andeboltv.fpa.pt/events/abc', - }, - ]; - - const match = find_stream_for_game(game, streams); - assert.ok(match); - assert.equal(match?.stream_url, 'https://andeboltv.fpa.pt/events/abc'); -}); - -test('enrich_fpa_agenda_with_streams adds stream fields', () => { - const games: FpaAgendaGame[] = [ - { - match_id: '1', - date: '2026-07-17', - time: '19:00', - home_team: 'PORTUGAL', - away_team: 'ALEMANHA', - home_goals: null, - away_goals: null, - venue: 'Maia', - competition: 'Seleções', - phase: '', - home_logo_url: null, - away_logo_url: null, - }, - ]; - - const streams: AndebolTvStreamEvent[] = [ - { - reference_id: 'live1', - event_id: 'live1', - home_team: 'Portugal M18', - away_team: 'Germany M18', - date: '2026-07-17', - status: 'live', - stream_url: 'https://andeboltv.fpa.pt/events/live1', - }, - ]; - - const enriched = enrich_fpa_agenda_with_streams(games, streams); - assert.equal(enriched[0]?.is_live, true); - assert.equal(enriched[0]?.stream_status, 'live'); - assert.equal(enriched[0]?.stream_url, 'https://andeboltv.fpa.pt/events/live1'); -}); diff --git a/bridge/src/services/fpa-stream-match.ts b/bridge/src/services/fpa-stream-match.ts deleted file mode 100644 index 73aa370..0000000 --- a/bridge/src/services/fpa-stream-match.ts +++ /dev/null @@ -1,130 +0,0 @@ -import type { AndebolTvStreamEvent } from './andeboltv.js'; -import type { FpaAgendaGame } from '../types.js'; - -/** PT (FPA feed) ↔ EN (AndebolTV/Pixellot) aliases for national/club name matching. */ -const TEAM_ALIAS_GROUPS: string[][] = [ - ['portugal', 'por'], - ['alemanha', 'germany', 'ger', 'deutschland'], - ['franca', 'france', 'fra'], - ['espanha', 'spain', 'esp'], - ['italia', 'italy', 'ita'], - ['holanda', 'netherlands', 'ned', 'hol'], - ['suecia', 'sweden', 'swe'], - ['noruega', 'norway', 'nor'], - ['dinamarca', 'denmark', 'den'], - ['islandia', 'iceland', 'isl'], - ['polonia', 'poland', 'pol'], - ['croacia', 'croatia', 'cro'], - ['servia', 'serbia', 'srb'], - ['eslovenia', 'slovenia', 'svn'], - ['hungria', 'hungary', 'hun'], - ['romenia', 'romania', 'rou'], - ['grecia', 'greece', 'gre'], - ['angola'], - ['brasil', 'brazil', 'bra'], -]; - -function normalize_team_token(value: string): string { - return value - .normalize('NFD') - .replace(/\p{M}/gu, '') - .toLowerCase() - .replace(/\b(fc|sc|ad|cp|gd|cd|aa|hb|sl)\b/g, ' ') - .replace(/[^a-z0-9]+/g, ' ') - .trim(); -} - -function team_tokens(name: string): string[] { - const normalized = normalize_team_token(name); - if (!normalized) { - return []; - } - const tokens = normalized.split(/\s+/).filter((t) => t.length >= 2); - return tokens.length > 0 ? tokens : [normalized]; -} - -function canonical_team_keys(name: string): Set { - const keys = new Set(); - const compact = normalize_team_token(name).replace(/\s+/g, ''); - if (compact) { - keys.add(compact); - } - for (const token of team_tokens(name)) { - keys.add(token); - for (const group of TEAM_ALIAS_GROUPS) { - if (group.some((alias) => token.includes(alias) || alias.includes(token))) { - for (const alias of group) { - keys.add(alias); - } - } - } - } - return keys; -} - -/** True when team names refer to the same side (fuzzy PT/EN + token overlap). */ -export function teams_overlap(a: string, b: string): boolean { - const keys_a = canonical_team_keys(a); - const keys_b = canonical_team_keys(b); - if (keys_a.size === 0 || keys_b.size === 0) { - return false; - } - for (const key of keys_a) { - if (keys_b.has(key)) { - return true; - } - for (const other of keys_b) { - if (key.length >= 4 && (other.includes(key) || key.includes(other))) { - return true; - } - } - } - return false; -} - -export function teams_match_pair( - home_a: string, - away_a: string, - home_b: string, - away_b: string, -): boolean { - const direct = teams_overlap(home_a, home_b) && teams_overlap(away_a, away_b); - const swapped = teams_overlap(home_a, away_b) && teams_overlap(away_a, home_b); - return direct || swapped; -} - -export function find_stream_for_game( - game: FpaAgendaGame, - streams: AndebolTvStreamEvent[], -): AndebolTvStreamEvent | null { - const candidates = streams.filter((s) => s.date === game.date); - for (const stream of candidates) { - if (teams_match_pair(game.home_team, game.away_team, stream.home_team, stream.away_team)) { - return stream; - } - } - return null; -} - -export function enrich_fpa_agenda_with_streams( - games: FpaAgendaGame[], - streams: AndebolTvStreamEvent[], -): FpaAgendaGame[] { - if (streams.length === 0) { - return games; - } - - return games.map((game) => { - const stream = find_stream_for_game(game, streams); - if (!stream) { - return game; - } - - return { - ...game, - stream_url: stream.stream_url, - stream_status: stream.status, - is_live: stream.status === 'live', - }; - }); -} diff --git a/bridge/src/types.ts b/bridge/src/types.ts index 2b14101..7d2e0d2 100644 --- a/bridge/src/types.ts +++ b/bridge/src/types.ts @@ -15,31 +15,6 @@ export interface DomainConfig { ads_enabled: boolean; analytics_id: string | null; auth_links?: boolean; - /** When true, homepage includes `fpa_agenda` from ws.fpa.pt (cached server-side). */ - fpa_agenda_enabled?: boolean; -} - -/** Normalised row from FPA `getAgendaJogosFAP` JSON. */ -export interface FpaAgendaGame { - match_id: string; - date: string; - time: string; - home_team: string; - away_team: string; - home_goals: number | null; - away_goals: number | null; - venue: string; - competition: string; - phase: string; - /** Club emblem from FPA `getClube` (si.fpa.pt); null when unavailable. */ - home_logo_url: string | null; - away_logo_url: string | null; - /** AndebolTV stream page when matched from andeboltv.fpa.pt (Pixellot). */ - stream_url?: string | null; - /** `live` or `upcoming` from AndebolTV; omitted when no stream. */ - stream_status?: 'live' | 'upcoming' | null; - /** Convenience flag when `stream_status === 'live'`. */ - is_live?: boolean; } export interface CategoryConfig { @@ -105,8 +80,6 @@ export interface HomepageData { featured: ArticleListItem[]; latest: ArticleListItem[]; by_category: Record; - /** Present when `fpa_agenda_enabled`; otherwise null. */ - fpa_agenda: FpaAgendaGame[] | null; } // Raw WordPress REST API types (minimal subset we use) diff --git a/config/domains/andebol.net.json b/config/domains/andebol.net.json index f7dbbdf..48c6551 100644 --- a/config/domains/andebol.net.json +++ b/config/domains/andebol.net.json @@ -25,6 +25,5 @@ "timezone": "Europe/Lisbon", "ads_enabled": false, "analytics_id": null, - "auth_links": true, - "fpa_agenda_enabled": true + "auth_links": true } diff --git a/frontend/src/lib/bridge.ts b/frontend/src/lib/bridge.ts index 8fda420..d30636f 100644 --- a/frontend/src/lib/bridge.ts +++ b/frontend/src/lib/bridge.ts @@ -195,7 +195,6 @@ export class MockBridgeClient extends BridgeClient { basketball: this.mockArticles(4), formula1: this.mockArticles(4), }, - fpa_agenda: null, }; } diff --git a/frontend/src/lib/ui-i18n.test.ts b/frontend/src/lib/ui-i18n.test.ts index 77936c3..24892d5 100644 --- a/frontend/src/lib/ui-i18n.test.ts +++ b/frontend/src/lib/ui-i18n.test.ts @@ -43,11 +43,3 @@ test('getUiStrings en search_results_count', () => { const s = getUiStrings('en'); assert.equal(s.search_results_count(3), '3 results'); }); - -test('getUiStrings pt fpa strings omit feed origin references', () => { - const s = getUiStrings('pt-PT'); - assert.equal(s.fpa_agenda_lead, 'Agenda de competições nacionais.'); - assert.equal(s.fpa_source_credit, ''); - assert.equal(s.fpa_agenda_lead.includes('feed'), false); - assert.equal(s.fpa_agenda_lead.includes('ws.fpa'), false); -}); diff --git a/frontend/src/lib/ui-i18n.ts b/frontend/src/lib/ui-i18n.ts index 33eb0cd..cc10c59 100644 --- a/frontend/src/lib/ui-i18n.ts +++ b/frontend/src/lib/ui-i18n.ts @@ -46,21 +46,6 @@ export type UiStrings = { search_results_count: (n: number) => string; explore_sections: string; discover_lead: string; - fpa_agenda_title: string; - fpa_agenda_lead: string; - fpa_col_when: string; - fpa_col_match: string; - fpa_col_score: string; - fpa_col_venue: string; - fpa_col_competition: string; - fpa_agenda_empty: string; - fpa_source_credit: string; - fpa_status_finished: string; - fpa_status_upcoming: string; - fpa_status_live: string; - fpa_watch_live: string; - fpa_watch_stream: string; - fpa_games_on_date: (count: number) => string; /** News archive page title */ news_archive_title: string; /** "All" filter label for category tabs */ @@ -141,21 +126,6 @@ const en: UiStrings = { search_results_count: n => `${n} results`, explore_sections: 'Explore', discover_lead: 'Browse by topic or find an article by keyword.', - fpa_agenda_title: 'Upcoming matches', - fpa_agenda_lead: 'National competition fixtures.', - fpa_col_when: 'When', - fpa_col_match: 'Match', - fpa_col_score: 'Score', - fpa_col_venue: 'Venue', - fpa_col_competition: 'Competition', - fpa_agenda_empty: 'Fixture list is temporarily unavailable.', - fpa_source_credit: '', - fpa_status_finished: 'FT', - fpa_status_upcoming: 'Upcoming', - fpa_status_live: 'Live', - fpa_watch_live: 'Watch live', - fpa_watch_stream: 'Watch on AndebolTV', - fpa_games_on_date: count => (count === 1 ? '1 match' : `${count} matches`), news_archive_title: 'News', news_all_filter: 'All', news_archive_desc: 'Latest news and stories across all sections.', @@ -221,21 +191,6 @@ const pt: UiStrings = { search_results_count: n => (n === 1 ? '1 resultado' : `${n} resultados`), explore_sections: 'Explorar', discover_lead: 'Navegue por tema ou encontre um artigo por palavra-chave.', - fpa_agenda_title: 'Próximos jogos', - fpa_agenda_lead: 'Agenda de competições nacionais.', - fpa_col_when: 'Quando', - fpa_col_match: 'Jogo', - fpa_col_score: 'Resultado', - fpa_col_venue: 'Local', - fpa_col_competition: 'Competição', - fpa_agenda_empty: 'A agenda não está disponível de momento.', - fpa_source_credit: '', - fpa_status_finished: 'Fim', - fpa_status_upcoming: 'Por jogar', - fpa_status_live: 'Em direto', - fpa_watch_live: 'Ver em direto', - fpa_watch_stream: 'Ver na AndebolTV', - fpa_games_on_date: count => (count === 1 ? '1 jogo' : `${count} jogos`), news_archive_title: 'Notícias', news_all_filter: 'Todas', news_archive_desc: 'Últimas notícias e histórias de todas as secções.', diff --git a/frontend/src/pages/index.astro b/frontend/src/pages/index.astro index cd42eb3..efdf235 100644 --- a/frontend/src/pages/index.astro +++ b/frontend/src/pages/index.astro @@ -2,7 +2,6 @@ import Base from '../layouts/Base.astro'; import LatestGrid from '../components/home/LatestGrid.astro'; import DiscoverSection from '../themes/institutional/DiscoverSection.astro'; -import FpaAgendaSection from '../themes/institutional/FpaAgendaSection.astro'; import { getDomainConfig } from '../lib/domain.js'; import { getThemeComponents } from '../lib/theme.js'; import { getUiStrings } from '../lib/ui-i18n.js'; @@ -64,10 +63,6 @@ const website_schema = { - {config.fpa_agenda_enabled && homepage.fpa_agenda != null && ( - - )} - {config.ads_enabled && (
{ui.ad_slot_text}
diff --git a/frontend/src/themes/institutional/FpaAgendaSection.astro b/frontend/src/themes/institutional/FpaAgendaSection.astro deleted file mode 100644 index d60b95e..0000000 --- a/frontend/src/themes/institutional/FpaAgendaSection.astro +++ /dev/null @@ -1,616 +0,0 @@ ---- -import type { FpaAgendaGame } from '../../types/index.js'; -import { getUiStrings } from '../../lib/ui-i18n.js'; - -interface Props { - games: FpaAgendaGame[]; - locale: string; -} - -const { games, locale } = Astro.props; -const ui = getUiStrings(locale); - -function team_initials(name: string): string { - const parts = name.trim().split(/\s+/).filter(Boolean); - if (parts.length === 0) return '?'; - if (parts.length === 1) return parts[0]!.slice(0, 2).toUpperCase(); - return (parts[0]![0]! + parts[parts.length - 1]![0]!).toUpperCase(); -} - -function is_finished(game: FpaAgendaGame): boolean { - return game.home_goals !== null && game.away_goals !== null; -} - -function format_score(game: FpaAgendaGame): string | null { - if (!is_finished(game)) return null; - return `${game.home_goals} – ${game.away_goals}`; -} - -const by_date = new Map(); -for (const game of games) { - const list = by_date.get(game.date) ?? []; - list.push(game); - by_date.set(game.date, list); -} -const date_groups = [...by_date.entries()]; ---- -
-
-
-
-
-

{ui.fpa_col_competition}

-

{ui.fpa_agenda_title}

-

{ui.fpa_agenda_lead}

-
- {games.length > 0 && ( - - )} -
-
-
- -
- {games.length === 0 ? ( -

{ui.fpa_agenda_empty}

- ) : ( -
- {date_groups.map(([date, day_games]) => ( -
-
- - {ui.fpa_games_on_date(day_games.length)} -
- -
    - {day_games.map((g) => { - const finished = is_finished(g); - const score = format_score(g); - const has_stream = Boolean(g.stream_url); - const is_live = Boolean(g.is_live); - const status_label = finished - ? ui.fpa_status_finished - : is_live - ? ui.fpa_status_live - : ui.fpa_status_upcoming; - return ( -
  • -
    -
    - {g.competition} - {g.phase && {g.phase}} - - {status_label} - -
    - -
    -
    - - {g.home_team} -
    - -
    - {score ? ( - - {score} - - ) : ( - - {g.time} - - )} -
    - -
    - - {g.away_team} -
    -
    - - -
    -
  • - ); - })} -
-
- ))} -
- )} - - {games.length > 0 && ui.fpa_source_credit ? ( -

{ui.fpa_source_credit}

- ) : null} -
-
- - diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index c30ae33..528f7d4 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -30,31 +30,6 @@ export interface DomainConfig { analytics_id: string | null; /** When true, show login/register in chrome and expose /entrar + /registar → WordPress. */ auth_links?: boolean; - /** Homepage includes FPA fixture feed (bridge proxies ws.fpa.pt). */ - fpa_agenda_enabled?: boolean; -} - -/** Normalised FPA agenda row (bridge → homepage JSON). */ -export interface FpaAgendaGame { - match_id: string; - date: string; - time: string; - home_team: string; - away_team: string; - home_goals: number | null; - away_goals: number | null; - venue: string; - competition: string; - phase: string; - /** Club emblem from FPA `getClube` (si.fpa.pt); null when unavailable. */ - home_logo_url?: string | null; - away_logo_url?: string | null; - /** AndebolTV stream page when matched from andeboltv.fpa.pt (Pixellot). */ - stream_url?: string | null; - /** `live` or `upcoming` from AndebolTV; omitted when no stream. */ - stream_status?: 'live' | 'upcoming' | null; - /** Convenience flag when `stream_status === 'live'`. */ - is_live?: boolean; } export interface Article { @@ -125,6 +100,4 @@ export interface HomepageData { featured: ArticleListItem[]; latest: ArticleListItem[]; by_category: Record; - /** Omitted by older bridge versions; treat as null if missing. */ - fpa_agenda?: FpaAgendaGame[] | null; }