add yankees score

This commit is contained in:
2026-05-31 01:30:14 -04:00
parent 31c93b0876
commit 86682f6c92
2 changed files with 38 additions and 4 deletions
+23 -4
View File
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { BillsScore, SabresScore } from "../../utils/types";
import { BillsScore, SabresScore, YankeesScore } from "../../utils/types";
interface TeamRowProps {
functionClick?: () => void;
@@ -48,8 +48,8 @@ function TeamRow({
</div>
<div className="p-2 text-2xl flex items-end flex-col justify-center">
<p>
{homeTeam.abbreviation} {homeTeam.score} - {awayTeam.abbreviation}{" "}
{awayTeam.score}
{awayTeam.abbreviation} {awayTeam.score} - {homeTeam.abbreviation}{" "}
{homeTeam.score}
</p>
<p className="text-sm">
{venue} - {new Date(date || Date.now()).toLocaleDateString()}
@@ -62,6 +62,7 @@ function TeamRow({
export default function ScoreModule() {
const [billsScore, setBillsScore] = useState<BillsScore | null>(null);
const [sabresScore, setSabresScore] = useState<SabresScore | null>(null);
const [yankeesScore, setYankeesScore] = useState<YankeesScore | null>(null);
const [warpath, setWarpath] = useState<boolean>(false);
useEffect(() => {
@@ -80,10 +81,20 @@ export default function ScoreModule() {
const data = await res.json();
setSabresScore(data);
} else {
console.error("Failed to fetch Sabresscore; " + res.statusText);
console.error("Failed to fetch Sabres score; " + res.statusText);
}
}
async function fetchYankeesScore() {
const res = await fetch("https://api.alexav.gg/v4/sports/scores/yankees");
if (res.ok) {
const data = await res.json();
setYankeesScore(data);
} else {
console.error("Failed to fetch Yankees score; " + res.statusText);
}
}
fetchYankeesScore();
fetchBillsScore();
fetchSabresScore();
}, []);
@@ -108,6 +119,14 @@ export default function ScoreModule() {
venue={billsScore.venue}
/>
)}
{yankeesScore?.homeTeam && yankeesScore.awayTeam && (
<TeamRow
homeTeam={yankeesScore.homeTeam}
awayTeam={yankeesScore.awayTeam}
venue={yankeesScore.venue}
date={yankeesScore.date}
/>
)}
{warpath && (
<audio
+15
View File
@@ -65,6 +65,14 @@ type SabresScore = {
awayTeam: NHLTeam;
homeTeam: NHLTeam;
};
type YankeesScore = {
season: number;
week: number;
date: string;
venue: string;
awayTeam: MLBTeam;
homeTeam: MLBTeam;
};
type NFLTeam = {
abbreviation: string;
score: number;
@@ -78,6 +86,12 @@ type NHLTeam = {
score: number;
logo: string;
};
type MLBTeam = {
name: string;
abbreviation: string;
logo: string;
score: number;
};
export type {
LastFMMusicObject,
@@ -89,4 +103,5 @@ export type {
NFLPlayer,
BillsScore,
SabresScore,
YankeesScore,
};