feat(web): show retry prompt when a category fails to load from source
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled

When getCategoryWithParts reports loadError (the PL24 catalog fetch failed
rather than the category being genuinely empty), the leaf view now renders a
"Katalog şu an yüklenemedi — tekrar dene" alert with a retry button instead of
the misleading "Bu kategori için parça bulunamadı" empty state. Genuine empty
leaves are unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-25 04:36:46 +03:00
parent ab5ed62f52
commit df85ebad83
2 changed files with 41 additions and 13 deletions

View File

@@ -54,6 +54,9 @@ export interface CategorySchema {
parts: Part[];
schemaPics: SchemaPic[];
hotspots: Hotspot[];
/** True when a source (e.g. PL24) fetch failed and the empty lists are a
* load error rather than a genuinely empty category — UI should offer retry. */
loadError?: boolean;
}
export function useCategoryParts(vehicleId: string, categoryId: string) {

View File

@@ -238,19 +238,44 @@ function VehicleCategoryPage() {
<CategoryColumns categories={data.children} vehicleId={id} />
))}
{/* Leaf category — show schema viewer */}
{data && !hasChildren && (
<Suspense fallback={<SchemaViewerFallback />}>
<SchemaViewer
schemaPic={data.schemaPics?.[0] ?? null}
hotspots={data.hotspots ?? []}
parts={data.parts ?? []}
isLoading={isLoading}
vehicleId={id}
categoryId={categoryId}
/>
</Suspense>
)}
{/* Leaf category — schema viewer, or a retry prompt when the source
catalog fetch failed (vs a genuinely empty category). */}
{data &&
!hasChildren &&
(data.loadError ? (
<div
role="alert"
className="flex flex-col items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/5 p-5 text-sm"
>
<div>
<p className="font-medium text-destructive">Katalog şu an yüklenemedi</p>
<p className="mt-1 text-muted-foreground">
Bu kategori tedarikçi katalogundan alınamadı. Lütfen birazdan tekrar deneyin.
</p>
</div>
<Button
type="button"
size="sm"
variant="outline"
onClick={() => refetch()}
disabled={isFetching}
data-faro-user-action-name="category-loaderror-retry"
>
{isFetching ? "Yükleniyor…" : "Tekrar dene"}
</Button>
</div>
) : (
<Suspense fallback={<SchemaViewerFallback />}>
<SchemaViewer
schemaPic={data.schemaPics?.[0] ?? null}
hotspots={data.hotspots ?? []}
parts={data.parts ?? []}
isLoading={isLoading}
vehicleId={id}
categoryId={categoryId}
/>
</Suspense>
))}
</div>
);
}