diff --git a/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx b/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx index 6202ca8d31..dd42f3d1b7 100644 --- a/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx +++ b/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx @@ -15,8 +15,10 @@ import cx from 'classnames'; import { useNotifications } from 'hooks/useNotifications'; import { defaultTo } from 'lodash-es'; import { CalendarClock, PenLine, Trash2 } from 'lucide-react'; +import { useAppContext } from 'providers/App/App'; import { ReactNode, useEffect } from 'react'; import { UseQueryResult } from 'react-query'; +import { USER_ROLES } from 'types/roles'; import { formatDateTime, @@ -84,6 +86,8 @@ function HeaderComponent({ handleEdit: () => void; handleDelete: () => void; }): JSX.Element { + const { user } = useAppContext(); + const isCrudEnabled = user?.role !== USER_ROLES.VIEWER; return ( @@ -91,25 +95,27 @@ function HeaderComponent({ {duration} -
- { - e.preventDefault(); - e.stopPropagation(); - handleEdit(); - }} - /> - { - e.preventDefault(); - e.stopPropagation(); - handleDelete(); - }} - /> -
+ {isCrudEnabled && ( +
+ { + e.preventDefault(); + e.stopPropagation(); + handleEdit(); + }} + /> + { + e.preventDefault(); + e.stopPropagation(); + handleDelete(); + }} + /> +
+ )}
); }