Skip to content

Commit

Permalink
Updated changelog. Renamed F1 Command
Browse files Browse the repository at this point in the history
  • Loading branch information
daniyalmaster693 authored and pernielsentikaer committed Feb 14, 2025
1 parent 8f6a3e7 commit 8327b2d
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 2 deletions.
9 changes: 9 additions & 0 deletions extensions/sportssync/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Sportssync Changelog

## [Added a bunch of new feedback] - {PR_MERGE_DATE}

- Added a new league: Champions League
- Fixed an issue causing the record in nhl standings command to show up as undefined
- Added pts as a stat in the nhl standings command
- Fixed an issue causing an error when links are not available
- Updated the F1 Scores and Schedule command title: F1 Results and Schedule
- Added proper support for 4 Nations for the NHL Scores and Schedule Command

## [Initial Version] - 2025-02-13

Initial Sportssync extension along the following features:
Expand Down
4 changes: 2 additions & 2 deletions extensions/sportssync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
"mode": "view"
},
{
"name": "f1-races-and-schedule",
"title": "F1 Scores and Schedule",
"name": "f1-results-and-schedule",
"title": "F1 Results and Schedule",
"description": "View race results and upcoming races across F1",
"mode": "view"
},
Expand Down
117 changes: 117 additions & 0 deletions extensions/sportssync/src/f1-results-and-schedule.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { Detail, List, Color, Action, ActionPanel, Icon } from "@raycast/api";
import { useFetch } from "@raycast/utils";

interface Athlete {
shortName: string;
}

interface Competitor {
athlete: Athlete;
}

interface Status {
type: {
state: string;
completed?: boolean;
};
period?: number;
displayClock?: string;
}

interface Competition {
competitors: Competitor[];
status: Status;
}

interface Race {
id: string;
shortName: string;
name: string;
date: string;
status: Status;
competitions: Competition[];
links: { href: string }[];
}

interface Response {
events: Race[];
day: { date: string };
leagues: { logos: { href: string }[] }[];
}
export default function command() {
const { isLoading, data } = useFetch<Response>("https://site.api.espn.com/apis/site/v2/sports/racing/f1/scoreboard");

if (isLoading) {
return <Detail isLoading={true} />;
}

if (!data) {
return <Detail markdown="No data found." />;
}

const races = data?.events || [];
const raceItems: JSX.Element[] = [];

races.forEach((race, index) => {
const gameTime = new Date(race.date).toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
});

let accessoryTitle = gameTime;
let accessoryColor = Color.SecondaryText;
let accessoryToolTip;
let accessoryIcon;

if (race.status.type.state === "in") {
accessoryTitle = `${race.competitions[4].competitors[0].athlete.shortName} L${race.competitions[4].status.period} ${race.status.displayClock}`;
accessoryColor = Color.Green;
accessoryIcon = { source: Icon.Stars, tintColor: "Green" };
accessoryToolTip = "Current Leader & Lap";
}

if (race.status.type.state === "post") {
accessoryTitle = `${race.competitions[4].competitors[0].athlete.shortName}`;
accessoryColor = Color.SecondaryText;
accessoryIcon = { source: Icon.Trophy, tintColor: "gold" };
accessoryToolTip = "Winner";
}

if (race.status.type.state === "post" && race.status.type.completed === false) {
accessoryTitle = `Postponed`;
accessoryColor = Color.Orange;
}

raceItems.push(
<List.Item
key={index}
title={`${race.shortName}`}
icon={{ source: data.leagues[0].logos[0].href }}
accessories={[
{
text: { value: `${accessoryTitle}`, color: accessoryColor },
tooltip: accessoryToolTip,
icon: accessoryIcon,
},
]}
actions={
<ActionPanel>
<Action.OpenInBrowser title="View Race Details on ESPN" url={`${race.links[0].href}`} />
<Action.OpenInBrowser title="View Circuit Details on ESPN" url={`${race.links[2].href}`} />
</ActionPanel>
}
/>,
);
});

return (
<List searchBarPlaceholder="Search for an upcoming race" isLoading={isLoading}>
<List.Section
title={`${data.day.date}`}
subtitle={`${raceItems.length} Race${raceItems.length !== 1 ? "s" : ""}`}
>
{raceItems}
</List.Section>
</List>
);
}

0 comments on commit 8327b2d

Please sign in to comment.