diff --git a/frontend/src/components/Alerts/RobotBlockedAlert.tsx b/frontend/src/components/Alerts/BlockedRobotAlert.tsx similarity index 100% rename from frontend/src/components/Alerts/RobotBlockedAlert.tsx rename to frontend/src/components/Alerts/BlockedRobotAlert.tsx diff --git a/frontend/src/components/Contexts/AlertContext.tsx b/frontend/src/components/Contexts/AlertContext.tsx index 71d3ca9ac..df40dba41 100644 --- a/frontend/src/components/Contexts/AlertContext.tsx +++ b/frontend/src/components/Contexts/AlertContext.tsx @@ -15,6 +15,7 @@ export enum AlertType { MissionFail, RequestFail, SafeZoneFail, + BlockedRobot, } const alertTypeEnumMap: { [key: string]: AlertType } = { diff --git a/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusSection.tsx b/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusSection.tsx index dcf0c099f..6ff4a4218 100644 --- a/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusSection.tsx +++ b/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusSection.tsx @@ -2,7 +2,9 @@ import { Typography } from '@equinor/eds-core-react' import { Robot } from 'models/Robot' import { useEffect } from 'react' import styled from 'styled-components' +import { BlockedRobotAlertContent } from 'components/Alerts/BlockedRobotAlert' import { RobotStatusCard, RobotStatusCardPlaceholder } from './RobotStatusCard' +import { AlertType, useAlertContext } from 'components/Contexts/AlertContext' import { useInstallationContext } from 'components/Contexts/InstallationContext' import { useLanguageContext } from 'components/Contexts/LanguageContext' import { useSafeZoneContext } from 'components/Contexts/SafeZoneContext' @@ -18,13 +20,16 @@ const RobotView = styled.div` grid-column: 1/ -1; gap: 1rem; ` +const isRobotBlocked = (robot: Robot): boolean => { + return robot.status === 'Blocked' +} export const RobotStatusSection = () => { const { TranslateText } = useLanguageContext() const { installationCode } = useInstallationContext() const { enabledRobots } = useRobotContext() const { switchSafeZoneStatus } = useSafeZoneContext() - + const { setAlert } = useAlertContext() const relevantRobots = enabledRobots .filter( (robot) => @@ -35,7 +40,11 @@ export const RobotStatusSection = () => { useEffect(() => { const missionQueueFozenStatus = relevantRobots.some((robot: Robot) => robot.missionQueueFrozen) switchSafeZoneStatus(missionQueueFozenStatus) - }, [enabledRobots, installationCode, switchSafeZoneStatus, relevantRobots]) + const blockedRobots = relevantRobots.filter(isRobotBlocked) + if (blockedRobots.length > 0) { + setAlert(AlertType.BlockedRobot, ) + } + }, [enabledRobots, installationCode, switchSafeZoneStatus, relevantRobots, setAlert]) const robotDisplay = relevantRobots.map((robot) => )