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
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:
@@ -54,6 +54,9 @@ export interface CategorySchema {
|
|||||||
parts: Part[];
|
parts: Part[];
|
||||||
schemaPics: SchemaPic[];
|
schemaPics: SchemaPic[];
|
||||||
hotspots: Hotspot[];
|
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) {
|
export function useCategoryParts(vehicleId: string, categoryId: string) {
|
||||||
|
|||||||
@@ -238,19 +238,44 @@ function VehicleCategoryPage() {
|
|||||||
<CategoryColumns categories={data.children} vehicleId={id} />
|
<CategoryColumns categories={data.children} vehicleId={id} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* Leaf category — show schema viewer */}
|
{/* Leaf category — schema viewer, or a retry prompt when the source
|
||||||
{data && !hasChildren && (
|
catalog fetch failed (vs a genuinely empty category). */}
|
||||||
<Suspense fallback={<SchemaViewerFallback />}>
|
{data &&
|
||||||
<SchemaViewer
|
!hasChildren &&
|
||||||
schemaPic={data.schemaPics?.[0] ?? null}
|
(data.loadError ? (
|
||||||
hotspots={data.hotspots ?? []}
|
<div
|
||||||
parts={data.parts ?? []}
|
role="alert"
|
||||||
isLoading={isLoading}
|
className="flex flex-col items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/5 p-5 text-sm"
|
||||||
vehicleId={id}
|
>
|
||||||
categoryId={categoryId}
|
<div>
|
||||||
/>
|
<p className="font-medium text-destructive">Katalog şu an yüklenemedi</p>
|
||||||
</Suspense>
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user