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
10 changes: 9 additions & 1 deletion lib/lovatAPI/getScouterSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ type ScouterScheduleScouterEntry = {
allianceColor: AllianceColor;
};

export async function getScouterSchedule(): Promise<ScouterSchedule> {
export async function getScouterSchedule(): Promise<
ScouterSchedule | undefined
> {
const tournamentKey = useTournamentStore.getState().value!.key;
const response = await get("/v1/manager/scouterschedules/" + tournamentKey);

if (!response.ok) {
const json = await response.json();

if (json["error"] === "Matches are not available for this tournamnet") {
return;
}

throw new Error("Error fetching scouter schedule");
}

Expand Down
8 changes: 3 additions & 5 deletions lib/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ export function createGenericServiceStore<T>(
);
}

export const useScouterScheduleStore =
createGenericServiceStore<ScouterSchedule>(
getScouterSchedule,
"scouterScheduleStore",
);
export const useScouterScheduleStore = createGenericServiceStore<
ScouterSchedule | undefined
>(getScouterSchedule, "scouterScheduleStore");

export const useTeamScoutersStore = createGenericServiceStore<Scouter[]>(
getTeamScouters,
Expand Down