Add recovery for public data loading failures

This commit is contained in:
Shinuwa 2026-10-15 16:25:07 +02:00
parent 1171eee510
commit daa5eba8bd
14 changed files with 186 additions and 58 deletions

View file

@ -1,5 +1,5 @@
// Rôle : liste les jeux déclarés dans le contenu éditable.
export function GamesPage({ siteContent, games, gamesError }) {
// Rôle : liste les jeux déclarés et permet de reprendre le chargement de leur catalogue.
export function GamesPage({ siteContent, games, gamesError, gamesLoading, retryGames }) {
const content = siteContent.gamesPage;
return (
@ -12,6 +12,10 @@ export function GamesPage({ siteContent, games, gamesError }) {
</div>
</section>
<section className="game-list">
{gamesError && games.length > 0 && <div className="nds-inline-notice" data-variant="warning" role="alert">
<span>{gamesError}</span>
<button className="nds-button" data-size="sm" type="button" onClick={retryGames}>{content.retryLabel}</button>
</div>}
{games.length ? games.map((game) => (
<article className="card nds-card game-card" data-variant="interactive" key={game.id}>
<a
@ -37,9 +41,10 @@ export function GamesPage({ siteContent, games, gamesError }) {
</div>
</article>
)) : (
<div className="empty nds-empty-state">
<h2>{content.emptyTitle}</h2>
<p>{gamesError || content.emptyText}</p>
<div className="empty nds-empty-state" aria-busy={gamesLoading}>
<h2>{gamesLoading ? content.loadingTitle : content.emptyTitle}</h2>
<p>{gamesLoading ? content.loadingText : gamesError || content.emptyText}</p>
{gamesError && <button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={retryGames}>{content.retryLabel}</button>}
</div>
)}
</section>

View file

@ -57,8 +57,8 @@ function AniimoListing({ game, aniimo, filters, setFilters, content }) {
export function AniimoPage({ category, game, aniimo, filters, setFilters, siteContent, links, actions }) {
const content = siteContent.aniimo;
if (category === "lists") {
if (!aniimo.loaded) return <section className="empty nds-empty-state" aria-busy="true"><h1>{content.loading}</h1></section>;
if (aniimo.error) return <section className="empty nds-empty-state" role="alert"><h1>{content.error}</h1><p>{aniimo.error}</p></section>;
if (aniimo.loading || !aniimo.loaded) return <section className="empty nds-empty-state" aria-busy="true"><h1>{content.loading}</h1></section>;
if (aniimo.error) return <section className="empty nds-empty-state" role="alert"><h1>{content.error}</h1><p>{aniimo.error}</p><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={aniimo.retry}>{siteContent.gamesPage.retryLabel}</button></section>;
return <AniimoLists game={game} aniimo={aniimo} linkedToolboxId={links?.[game.id] || ""} actions={actions} />;
}
if (category !== "aniimos") return <>
@ -68,7 +68,7 @@ export function AniimoPage({ category, game, aniimo, filters, setFilters, siteCo
<a className="feature game-home-card" href="#/games/aniimo/lists"><span className="game-home-card-icon" aria-hidden="true"><span className="module-icon-svg module-icon-checklist" /></span><strong>Listes</strong><span>Données copiables au format checklist pour préparer vos suivis.</span></a>
</section>
</>;
if (!aniimo.loaded) return <section className="empty nds-empty-state" aria-busy="true"><h1>{content.loading}</h1></section>;
if (aniimo.error) return <section className="empty nds-empty-state" role="alert"><h1>{content.error}</h1><p>{aniimo.error}</p></section>;
if (aniimo.loading || !aniimo.loaded) return <section className="empty nds-empty-state" aria-busy="true"><h1>{content.loading}</h1></section>;
if (aniimo.error) return <section className="empty nds-empty-state" role="alert"><h1>{content.error}</h1><p>{aniimo.error}</p><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={aniimo.retry}>{siteContent.gamesPage.retryLabel}</button></section>;
return <AniimoListing game={game} aniimo={aniimo} filters={filters} setFilters={setFilters} content={content} />;
}

View file

@ -2,11 +2,11 @@
import { Diablo4Listing } from "./Diablo4Listing.jsx";
import { Diablo4Overview } from "./Diablo4Overview.jsx";
export function Diablo4Page({ category, game, diablo4, filters, setFilters }) {
export function Diablo4Page({ category, game, diablo4, filters, setFilters, siteContent }) {
const activeCategory = category === "affixes" ? category : "";
const heroStyle = game?.images?.heroBg ? { "--game-hero-image": `url("${game.images.heroBg}")` } : undefined;
if (!diablo4.loaded) {
if (diablo4.loading || !diablo4.loaded) {
return (
<>
<section className="game-hero" style={heroStyle}>
@ -26,9 +26,10 @@ export function Diablo4Page({ category, game, diablo4, filters, setFilters }) {
if (diablo4.error) {
return (
<section className="empty nds-empty-state">
<section className="empty nds-empty-state" role="alert">
<h1>Impossible de charger Diablo IV</h1>
<p>{diablo4.error}</p>
<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={diablo4.retry}>{siteContent.gamesPage.retryLabel}</button>
</section>
);
}

View file

@ -3,11 +3,11 @@ import { MhwildsListing } from "./MhwildsListing.jsx";
import { MhwildsLists } from "./MhwildsLists.jsx";
import { MhwildsOverview } from "./MhwildsOverview.jsx";
export function MhwildsPage({ category, game, mhwilds, filters, setFilters, t, links, actions }) {
export function MhwildsPage({ category, game, mhwilds, filters, setFilters, t, links, actions, siteContent }) {
const activeCategory = category === "monsters" || category === "endemic" || category === "lists" ? category : "";
const heroStyle = game?.images?.heroBg ? { "--game-hero-image": `url("${game.images.heroBg}")` } : undefined;
if (!mhwilds.loaded) {
if (mhwilds.loading || !mhwilds.loaded) {
return (
<>
<section className="game-hero" style={heroStyle}>
@ -27,9 +27,10 @@ export function MhwildsPage({ category, game, mhwilds, filters, setFilters, t, l
if (mhwilds.error) {
return (
<section className="empty nds-empty-state">
<section className="empty nds-empty-state" role="alert">
<h1>Impossible de charger MH Wilds</h1>
<p>{mhwilds.error}</p>
<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={mhwilds.retry}>{siteContent.gamesPage.retryLabel}</button>
</section>
);
}