fix: guard vendor detail loading on instead of isPending to avoid stuck skeleton
This commit is contained in:
@@ -58,7 +58,7 @@ export default function LieferantDetail() {
|
||||
}, [isNew]);
|
||||
|
||||
// ── Query ──
|
||||
const { data: vendor, isPending, isLoading, isError } = useQuery({
|
||||
const { data: vendor, isError } = useQuery({
|
||||
queryKey: ['lieferant', vendorId],
|
||||
queryFn: () => bestellungApi.getVendor(vendorId),
|
||||
enabled: !isNew && !!vendorId,
|
||||
@@ -138,7 +138,17 @@ export default function LieferantDetail() {
|
||||
}
|
||||
|
||||
// ── Loading / Error ──
|
||||
if (!isNew && isPending) {
|
||||
if (!isNew && !vendor) {
|
||||
if (isError) {
|
||||
return (
|
||||
<DashboardLayout>
|
||||
<Box sx={{ p: 4, textAlign: 'center' }}>
|
||||
<Typography color="error">Lieferant nicht gefunden.</Typography>
|
||||
<Button sx={{ mt: 2 }} onClick={() => navigate('/bestellungen?tab=1')}>Zurück</Button>
|
||||
</Box>
|
||||
</DashboardLayout>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<DashboardLayout>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2, mb: 3 }}>
|
||||
@@ -154,17 +164,6 @@ export default function LieferantDetail() {
|
||||
);
|
||||
}
|
||||
|
||||
if (!isNew && !isPending && (isError || !vendor)) {
|
||||
return (
|
||||
<DashboardLayout>
|
||||
<Box sx={{ p: 4, textAlign: 'center' }}>
|
||||
<Typography color="error">Lieferant nicht gefunden.</Typography>
|
||||
<Button sx={{ mt: 2 }} onClick={() => navigate('/bestellungen?tab=1')}>Zurück</Button>
|
||||
</Box>
|
||||
</DashboardLayout>
|
||||
);
|
||||
}
|
||||
|
||||
const isSaving = createVendor.isPending || updateVendor.isPending;
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user