rework internal order system
This commit is contained in:
@@ -336,10 +336,11 @@ function DetailModal({ requestId, onClose, showAdminActions, showEditButton, can
|
||||
const [linkDialog, setLinkDialog] = useState(false);
|
||||
const [selectedBestellung, setSelectedBestellung] = useState<Bestellung | null>(null);
|
||||
|
||||
const { data: detail, isLoading } = useQuery<AusruestungAnfrageDetailResponse>({
|
||||
const { data: detail, isLoading, isError } = useQuery<AusruestungAnfrageDetailResponse>({
|
||||
queryKey: ['ausruestungsanfrage', 'request', requestId],
|
||||
queryFn: () => ausruestungsanfrageApi.getRequest(requestId!),
|
||||
enabled: requestId != null,
|
||||
retry: 1,
|
||||
});
|
||||
|
||||
const { data: catalogItems = [] } = useQuery({
|
||||
@@ -451,6 +452,8 @@ function DetailModal({ requestId, onClose, showAdminActions, showEditButton, can
|
||||
<DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2, pt: '20px !important' }}>
|
||||
{isLoading ? (
|
||||
<Typography color="text.secondary">Lade Details...</Typography>
|
||||
) : isError ? (
|
||||
<Typography color="error">Fehler beim Laden der Anfrage.</Typography>
|
||||
) : !detail ? (
|
||||
<Typography color="text.secondary">Anfrage nicht gefunden.</Typography>
|
||||
) : editing ? (
|
||||
@@ -945,8 +948,12 @@ function MeineAnfragenTab() {
|
||||
if (itemEigenschaftenRef.current[artikelId]) return;
|
||||
try {
|
||||
const eigs = await ausruestungsanfrageApi.getArtikelEigenschaften(artikelId);
|
||||
setItemEigenschaften(prev => ({ ...prev, [artikelId]: eigs }));
|
||||
} catch { /* ignore */ }
|
||||
if (eigs && eigs.length > 0) {
|
||||
setItemEigenschaften(prev => ({ ...prev, [artikelId]: eigs }));
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Failed to load eigenschaften for artikel', artikelId, err);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleCreateSubmit = () => {
|
||||
@@ -1212,21 +1219,19 @@ function AlleAnfragenTab() {
|
||||
|
||||
const canEditAny = hasPermission('ausruestungsanfrage:edit');
|
||||
|
||||
const { data: requests = [], isLoading } = useQuery({
|
||||
queryKey: ['ausruestungsanfrage', 'requests', statusFilter],
|
||||
const { data: requests = [], isLoading: requestsLoading, isError: requestsError } = useQuery({
|
||||
queryKey: ['ausruestungsanfrage', 'allRequests', statusFilter],
|
||||
queryFn: () => ausruestungsanfrageApi.getRequests(statusFilter ? { status: statusFilter } : undefined),
|
||||
});
|
||||
|
||||
const { data: overview } = useQuery<AusruestungOverview>({
|
||||
queryKey: ['ausruestungsanfrage', 'overview'],
|
||||
queryKey: ['ausruestungsanfrage', 'overview-cards'],
|
||||
queryFn: () => ausruestungsanfrageApi.getOverview(),
|
||||
});
|
||||
|
||||
if (isLoading) return <Typography color="text.secondary">Lade Anfragen...</Typography>;
|
||||
|
||||
return (
|
||||
<Box>
|
||||
{/* Summary cards */}
|
||||
{/* Summary cards — always visible */}
|
||||
<Grid container spacing={2} sx={{ mb: 3 }}>
|
||||
<Grid item xs={6} sm={3}>
|
||||
<Paper variant="outlined" sx={{ p: 2, textAlign: 'center' }}>
|
||||
@@ -1268,7 +1273,11 @@ function AlleAnfragenTab() {
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
{requests.length === 0 ? (
|
||||
{requestsLoading ? (
|
||||
<Typography color="text.secondary">Lade Anfragen...</Typography>
|
||||
) : requestsError ? (
|
||||
<Typography color="error">Fehler beim Laden der Anfragen.</Typography>
|
||||
) : requests.length === 0 ? (
|
||||
<Typography color="text.secondary">Keine Anfragen vorhanden.</Typography>
|
||||
) : (
|
||||
<TableContainer component={Paper} variant="outlined">
|
||||
@@ -1299,7 +1308,6 @@ function AlleAnfragenTab() {
|
||||
</TableContainer>
|
||||
)}
|
||||
|
||||
{/* Detail Modal with admin actions */}
|
||||
<DetailModal
|
||||
requestId={detailId}
|
||||
onClose={() => setDetailId(null)}
|
||||
|
||||
Reference in New Issue
Block a user