mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
Display a message when there are no results
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { createSafeActionClient } from "next-safe-action";
|
||||
|
||||
export const action = createSafeActionClient();
|
||||
export const action = createSafeActionClient({
|
||||
handleReturnedServerError(error) {
|
||||
return error.message;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user