Skip to content

Commit 4126c9f

Browse files
committed
fix: carrega imagens das equipes dinamicamente
1 parent 8c3e514 commit 4126c9f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/services/dataService.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Papa from 'papaparse';
22
import { Team, Round, Match } from '../types';
33

4+
const teamLogos = import.meta.glob('../assets/team-logos/*.{png,jpg,jpeg,svg}', { eager: true });
5+
46
const TEAMS_URL = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vR4qBk403Kau0N0B8KlYHnHV4MSYYonQR6mwZqa7bqhU72xDOc9huu1lSYZLTq4gOu-B-08IASUXQDg/pub?gid=0&single=true&output=csv';
57
const MATCHES_URL = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vR4qBk403Kau0N0B8KlYHnHV4MSYYonQR6mwZqa7bqhU72xDOc9huu1lSYZLTq4gOu-B-08IASUXQDg/pub?gid=1943059921&single=true&output=csv';
68

@@ -60,10 +62,21 @@ export const fetchTournamentData = async () => {
6062
}
6163
}
6264

65+
let logoUrl = row.Logo;
66+
if (logoUrl && !logoUrl.startsWith('http')) {
67+
const cleanName = logoUrl.split('/').pop();
68+
for (const path in teamLogos) {
69+
if (path.includes(cleanName!)) {
70+
logoUrl = (teamLogos[path] as any).default;
71+
break;
72+
}
73+
}
74+
}
75+
6376
return {
6477
name: row.Nome,
6578
acronym: row.Sigla,
66-
logoUrl: row.Logo,
79+
logoUrl: logoUrl,
6780
victories: parseInt(row.Vitorias) || 0,
6881
loses: parseInt(row.Derrotas) || 0,
6982
gamesPlayed: (parseInt(row.Vitorias) || 0) + (parseInt(row.Derrotas) || 0),

0 commit comments

Comments
 (0)