diff --git a/src/app/events/[event_key]/EventKeyClient.tsx b/src/app/events/[event_key]/EventKeyClient.tsx index 091c547..5cd07aa 100644 --- a/src/app/events/[event_key]/EventKeyClient.tsx +++ b/src/app/events/[event_key]/EventKeyClient.tsx @@ -19,7 +19,7 @@ import Link from "next/link"; import { ArrowRight, ClipboardList } from "lucide-react"; import EventHeader from "@/components/events/event/EventHeader"; -import { EventFull, EventRankingRow, EventTab, EventTeamSummary, EventWebcastType, WebcastUrl} from "@/types/events"; +import { EventAward, EventFull, EventRankingRow, EventTab, EventTeamSummary, EventWebcastType, WebcastUrl} from "@/types/events"; import EventOverview from "./EventOverviewTab"; import EventMatchesTab from "./EventMatchesTab"; import EventTeamsTab from "./EventTeamsTab"; @@ -29,44 +29,16 @@ import { EventInfoProps } from "@/components/events/event/EventInfo"; import { getTeamSummary } from "@/lib/api/teams"; -export const mockInformation: EventInfoProps = { - location: "São Paulo", - venue: "SESI Vila Leopoldina", - date: "Mar 12–15", - country: "Brazil", - week: "Week 2", -}; - -export const mockWebcasts: WebcastUrl[] = [ - { - type: EventWebcastType.YouTube, - channel: "Official FIRST Broadcast", - date: "Mar 12", - url: "https://youtube.com", - }, - { - type: EventWebcastType.YouTube, - channel: "Official FIRST Broadcast", - date: "Mar 13", - url: "https://youtube.com", - }, - { - type: EventWebcastType.Twitch, - channel: "FIRSTinspires", - date: "Mar 14", - url: "https://twitch.tv/firstinspires", - }, -]; - interface EventKeyProps { eventKey: string; tab: EventTab; event: EventFull; teams: EventTeamSummary[] | null; rankings: EventRankingRow[] | null; + awards: EventAward[] | null; } -async function EventTabContent({ eventKey, tab, event, teams, rankings }: EventKeyProps) { +async function EventTabContent({ eventKey, tab, event, teams, rankings, awards }: EventKeyProps) { switch (tab) { case EventTab.Overview: return @@ -81,7 +53,7 @@ async function EventTabContent({ eventKey, tab, event, teams, rankings }: EventK return ; case EventTab.Awards: - return ; + return ; case EventTab.Scout: // This one doesn't need TBA data at all — it just hands the @@ -119,11 +91,11 @@ async function EventTabContent({ eventKey, tab, event, teams, rankings }: EventK } } -export default function EventKeyClient({ eventKey, tab, event, teams, rankings}: EventKeyProps) { +export default function EventKeyClient({ eventKey, tab, event, teams, rankings, awards}: EventKeyProps) { return (
- +
); } diff --git a/src/app/events/[event_key]/page.tsx b/src/app/events/[event_key]/page.tsx index 87c8cc7..1b1945a 100644 --- a/src/app/events/[event_key]/page.tsx +++ b/src/app/events/[event_key]/page.tsx @@ -19,7 +19,7 @@ import { notFound } from "next/navigation"; import EventKeyClient from "./EventKeyClient"; import { EventTab } from "@/types/events"; -import { getEventFull, getEventRankings } from "@/lib/api/events"; +import { getEventAwards, getEventFull, getEventRankings } from "@/lib/api/events"; import { getTeamSummary } from "@/lib/api/teams"; interface EventPageProps { @@ -43,10 +43,11 @@ export default async function EventPage({ // every load wait for two full sequential round-trips instead of one. // (The bigger cost is inside `getTeamSummary` itself, which is // off-limits here — see the suggestions shared alongside this change.) - const [event, teams, rankings] = await Promise.all([ + const [event, teams, rankings, awards] = await Promise.all([ getEventFull(event_key), getTeamSummary(event_key), getEventRankings(event_key), + getEventAwards(event_key), ]); if (!event) { @@ -65,6 +66,7 @@ export default async function EventPage({ eventKey={event_key} event={event} tab={validTab} + awards={awards} teams={teams} /> ); diff --git a/src/components/events/event/awards/AwardRow.tsx b/src/components/events/event/awards/AwardRow.tsx index 5cf3b67..9d4d31c 100644 --- a/src/components/events/event/awards/AwardRow.tsx +++ b/src/components/events/event/awards/AwardRow.tsx @@ -24,7 +24,7 @@ export default function AwardRow({ award }: AwardRowProps) {

- {award.recipientName ?? award.awardee ?? "Recipient TBD"} + {award.recipientName ?? award.awardee ?? award.recipientTeamKey?.replace("frc", "") ?? "Unknown recipient"}

diff --git a/src/lib/api/events.ts b/src/lib/api/events.ts index 80cc944..3acbb2f 100644 --- a/src/lib/api/events.ts +++ b/src/lib/api/events.ts @@ -1,6 +1,6 @@ import * as tba from "@/lib/api/tba"; import { DashboardDataEvent } from "@/types/dashboard"; -import { EventFull, EventListItem, EventOption, EventRankingRow, EventWebcastType, WebcastUrl, } from "@/types/events"; +import { EventAward, EventFull, EventListItem, EventOption, EventRankingRow, EventWebcastType, WebcastUrl, } from "@/types/events"; import { TBAEvent } from "@/types/tba/event"; /** @@ -263,7 +263,42 @@ export async function getEventRankings(event_key: string): Promise { + try { + const awards = await tba.getEventAwards(event_key); + + if (!awards || !awards.length) { + return null; + } + + const EventAwards: EventAward[] = []; + + + for (const award of awards) { + const awardees = award.recipient_list + ?.map(recipient => recipient.awardee) + .filter(Boolean) + .join(" - "); + + const recipientTeamKeys = award.recipient_list + ?.map(recipient => recipient.team_key) + .filter(Boolean) + .join(" - "); + + EventAwards.push({ + id: award.award_type.toString(), + name: award.name, + recipientTeamKey: recipientTeamKeys?.replaceAll("frc", "") || null, + awardee: awardees || null, + }); + } + + return EventAwards; + } + catch { + return null; + } +}