fix permissions
This commit is contained in:
86
frontend/src/components/dashboard/IssueOverviewWidget.tsx
Normal file
86
frontend/src/components/dashboard/IssueOverviewWidget.tsx
Normal file
@@ -0,0 +1,86 @@
|
||||
import { Card, CardContent, Typography, Box, Chip, Skeleton } from '@mui/material';
|
||||
import { BugReport } from '@mui/icons-material';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { issuesApi } from '../../services/issues';
|
||||
|
||||
const STATUS_CHIPS = [
|
||||
{ key: 'offen' as const, label: 'Offen', color: 'info' as const },
|
||||
{ key: 'in_bearbeitung' as const, label: 'In Bearbeitung', color: 'warning' as const },
|
||||
{ key: 'erledigt' as const, label: 'Erledigt', color: 'success' as const },
|
||||
{ key: 'abgelehnt' as const, label: 'Abgelehnt', color: 'error' as const },
|
||||
];
|
||||
|
||||
function IssueOverviewWidget() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { data, isLoading, isError } = useQuery({
|
||||
queryKey: ['issues-widget-summary'],
|
||||
queryFn: issuesApi.getWidgetSummary,
|
||||
refetchInterval: 5 * 60 * 1000,
|
||||
retry: 1,
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Typography variant="h6" gutterBottom>Issues</Typography>
|
||||
<Skeleton variant="rectangular" height={40} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
return (
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Typography variant="h6" gutterBottom>Issues</Typography>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
Issues konnten nicht geladen werden.
|
||||
</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
const visibleChips = STATUS_CHIPS.filter((s) => data && data[s.key] > 0);
|
||||
|
||||
if (visibleChips.length === 0) {
|
||||
return (
|
||||
<Card sx={{ cursor: 'pointer' }} onClick={() => navigate('/issues')}>
|
||||
<CardContent>
|
||||
<Typography variant="h6" gutterBottom>Issues</Typography>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, color: 'text.secondary' }}>
|
||||
<BugReport fontSize="small" />
|
||||
<Typography variant="body2">Keine offenen Issues</Typography>
|
||||
</Box>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card sx={{ cursor: 'pointer' }} onClick={() => navigate('/issues')}>
|
||||
<CardContent>
|
||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1.5 }}>
|
||||
<Typography variant="h6">Issues</Typography>
|
||||
<BugReport fontSize="small" color="action" />
|
||||
</Box>
|
||||
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1 }}>
|
||||
{visibleChips.map((s) => (
|
||||
<Chip
|
||||
key={s.key}
|
||||
label={`${data![s.key]} ${s.label}`}
|
||||
color={s.color}
|
||||
size="small"
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export default IssueOverviewWidget;
|
||||
@@ -21,3 +21,4 @@ export { default as WidgetGroup } from './WidgetGroup';
|
||||
export { default as BestellungenWidget } from './BestellungenWidget';
|
||||
export { default as AusruestungsanfrageWidget } from './AusruestungsanfrageWidget';
|
||||
export { default as IssueQuickAddWidget } from './IssueQuickAddWidget';
|
||||
export { default as IssueOverviewWidget } from './IssueOverviewWidget';
|
||||
|
||||
Reference in New Issue
Block a user