permission changes
This commit is contained in:
@@ -17,6 +17,9 @@ import PersonalWarningsBanner from '../components/dashboard/PersonalWarningsBann
|
|||||||
|
|
||||||
function Dashboard() {
|
function Dashboard() {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
|
const canViewAtemschutz = user?.groups?.some(g =>
|
||||||
|
['dashboard_admin', 'dashboard_kommando', 'dashboard_atemschutz', 'dashboard_moderator'].includes(g)
|
||||||
|
) ?? false;
|
||||||
const [dataLoading, setDataLoading] = useState(true);
|
const [dataLoading, setDataLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -83,6 +86,7 @@ function Dashboard() {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{/* Atemschutz Status Card */}
|
{/* Atemschutz Status Card */}
|
||||||
|
{canViewAtemschutz && (
|
||||||
<Box>
|
<Box>
|
||||||
<Fade in={!dataLoading} timeout={600} style={{ transitionDelay: '400ms' }}>
|
<Fade in={!dataLoading} timeout={600} style={{ transitionDelay: '400ms' }}>
|
||||||
<Box>
|
<Box>
|
||||||
@@ -90,6 +94,7 @@ function Dashboard() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Fade>
|
</Fade>
|
||||||
</Box>
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Upcoming Events Widget */}
|
{/* Upcoming Events Widget */}
|
||||||
<Box>
|
<Box>
|
||||||
|
|||||||
@@ -1135,6 +1135,7 @@ export default function Kalender() {
|
|||||||
user?.groups?.some((g) => WRITE_GROUPS_EVENTS.includes(g)) ?? false;
|
user?.groups?.some((g) => WRITE_GROUPS_EVENTS.includes(g)) ?? false;
|
||||||
const canWriteBookings =
|
const canWriteBookings =
|
||||||
user?.groups?.some((g) => WRITE_GROUPS_BOOKINGS.includes(g)) ?? false;
|
user?.groups?.some((g) => WRITE_GROUPS_BOOKINGS.includes(g)) ?? false;
|
||||||
|
const canCreateBookings = !!user;
|
||||||
|
|
||||||
// ── Tab ─────────────────────────────────────────────────────────────────────
|
// ── Tab ─────────────────────────────────────────────────────────────────────
|
||||||
const [activeTab, setActiveTab] = useState(0);
|
const [activeTab, setActiveTab] = useState(0);
|
||||||
@@ -1386,7 +1387,7 @@ export default function Kalender() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCellClick = (vehicleId: string, day: Date) => {
|
const handleCellClick = (vehicleId: string, day: Date) => {
|
||||||
if (!canWriteBookings) return;
|
if (!canCreateBookings) return;
|
||||||
setEditingBooking(null);
|
setEditingBooking(null);
|
||||||
setBookingForm({
|
setBookingForm({
|
||||||
...EMPTY_BOOKING_FORM,
|
...EMPTY_BOOKING_FORM,
|
||||||
@@ -1866,7 +1867,7 @@ export default function Kalender() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{canWriteBookings && (
|
{canCreateBookings && (
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
startIcon={<Add />}
|
startIcon={<Add />}
|
||||||
@@ -1952,9 +1953,9 @@ export default function Kalender() {
|
|||||||
}
|
}
|
||||||
sx={{
|
sx={{
|
||||||
bgcolor: isFree ? 'success.50' : undefined,
|
bgcolor: isFree ? 'success.50' : undefined,
|
||||||
cursor: isFree && canWriteBookings ? 'pointer' : 'default',
|
cursor: isFree && canCreateBookings ? 'pointer' : 'default',
|
||||||
'&:hover':
|
'&:hover':
|
||||||
isFree && canWriteBookings
|
isFree && canCreateBookings
|
||||||
? { bgcolor: 'success.100' }
|
? { bgcolor: 'success.100' }
|
||||||
: {},
|
: {},
|
||||||
p: 0.5,
|
p: 0.5,
|
||||||
@@ -2043,7 +2044,7 @@ export default function Kalender() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* FAB */}
|
{/* FAB */}
|
||||||
{canWriteBookings && (
|
{canCreateBookings && (
|
||||||
<Fab
|
<Fab
|
||||||
color="primary"
|
color="primary"
|
||||||
sx={{ position: 'fixed', bottom: 32, right: 32 }}
|
sx={{ position: 'fixed', bottom: 32, right: 32 }}
|
||||||
|
|||||||
Reference in New Issue
Block a user