Display a message when there are no results

This commit is contained in:
Timothy Armes
2024-09-27 10:53:15 +02:00
parent 93e3e1242a
commit f8cd2612b5
8 changed files with 92 additions and 11 deletions
+5
View File
@@ -124,6 +124,10 @@ export const fetchTournamentResults = action(
},
);
if (rawResults.status >= 500) {
throw new Error("ERR_TOURNAMENT_RESULTS_NOT_AVAILABLE");
}
const results = await rawResults.json();
if ("detail" in results && results.detail === "Not found") {
@@ -131,6 +135,7 @@ export const fetchTournamentResults = action(
}
const parsedResults = dbSchema.parse(results);
return outputSchema.parse(
parsedResults.map<z.infer<typeof outputSchema>[number]>((player) => ({
id: player.id,
+5 -1
View File
@@ -1,3 +1,7 @@
import { createSafeActionClient } from "next-safe-action";
export const action = createSafeActionClient();
export const action = createSafeActionClient({
handleReturnedServerError(error) {
return error.message;
},
});