Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 6 additions & 34 deletions src/app/events/[event_key]/EventKeyClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,26 @@
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";

Check warning on line 22 in src/app/events/[event_key]/EventKeyClient.tsx

View workflow job for this annotation

GitHub Actions / build

'WebcastUrl' is defined but never used

Check warning on line 22 in src/app/events/[event_key]/EventKeyClient.tsx

View workflow job for this annotation

GitHub Actions / build

'EventWebcastType' is defined but never used

Check warning on line 22 in src/app/events/[event_key]/EventKeyClient.tsx

View workflow job for this annotation

GitHub Actions / build

'WebcastUrl' is defined but never used

Check warning on line 22 in src/app/events/[event_key]/EventKeyClient.tsx

View workflow job for this annotation

GitHub Actions / build

'EventWebcastType' is defined but never used
import EventOverview from "./EventOverviewTab";
import EventMatchesTab from "./EventMatchesTab";
import EventTeamsTab from "./EventTeamsTab";
import EventRankingsTab from "./EventRankingsTab";
import EventAwardsTab from "./EventAwardsTab";
import { EventInfoProps } from "@/components/events/event/EventInfo";

Check warning on line 28 in src/app/events/[event_key]/EventKeyClient.tsx

View workflow job for this annotation

GitHub Actions / build

'EventInfoProps' is defined but never used

Check warning on line 28 in src/app/events/[event_key]/EventKeyClient.tsx

View workflow job for this annotation

GitHub Actions / build

'EventInfoProps' is defined but never used
import { getTeamSummary } from "@/lib/api/teams";

Check warning on line 29 in src/app/events/[event_key]/EventKeyClient.tsx

View workflow job for this annotation

GitHub Actions / build

'getTeamSummary' is defined but never used

Check warning on line 29 in src/app/events/[event_key]/EventKeyClient.tsx

View workflow job for this annotation

GitHub Actions / build

'getTeamSummary' is defined but never used


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 <EventOverview event={event} />
Expand All @@ -81,7 +53,7 @@
return <EventRankingsTab rankings={rankings ? rankings : []} loading={false}/>;

case EventTab.Awards:
return <EventAwardsTab />;
return <EventAwardsTab awards={awards ? awards : []} loading={false} />;

case EventTab.Scout:
// This one doesn't need TBA data at all — it just hands the
Expand Down Expand Up @@ -119,11 +91,11 @@
}
}

export default function EventKeyClient({ eventKey, tab, event, teams, rankings}: EventKeyProps) {
export default function EventKeyClient({ eventKey, tab, event, teams, rankings, awards}: EventKeyProps) {
return (
<main className="mx-auto flex w-full max-w-7xl flex-col gap-6 overflow-x-hidden px-4 py-6 sm:px-6">
<EventHeader eventKey={eventKey} activeTab={tab} event={event} />
<EventTabContent eventKey={eventKey} tab={tab} event={event} teams={teams} rankings={rankings} />
<EventTabContent eventKey={eventKey} tab={tab} event={event} teams={teams} rankings={rankings} awards={awards} />
</main>
);
}
6 changes: 4 additions & 2 deletions src/app/events/[event_key]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -65,6 +66,7 @@ export default async function EventPage({
eventKey={event_key}
event={event}
tab={validTab}
awards={awards}
teams={teams}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/event/awards/AwardRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function AwardRow({ award }: AwardRowProps) {
</p>

<p className="mt-0.5 text-xs text-slate-400">
{award.recipientName ?? award.awardee ?? "Recipient TBD"}
{award.recipientName ?? award.awardee ?? award.recipientTeamKey?.replace("frc", "") ?? "Unknown recipient"}
</p>
</div>
</div>
Expand Down
39 changes: 37 additions & 2 deletions src/lib/api/events.ts
Original file line number Diff line number Diff line change
@@ -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";

/**
Expand Down Expand Up @@ -263,7 +263,42 @@ export async function getEventRankings(event_key: string): Promise<EventRankingR
return null;
}

return null;
}


export async function getEventAwards(event_key: string): Promise<EventAward[] | null> {
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;
}
}
Loading