diff --git a/frontend/src/api/ApiCaller.tsx b/frontend/src/api/ApiCaller.tsx index 81958fa70..81c74966e 100644 --- a/frontend/src/api/ApiCaller.tsx +++ b/frontend/src/api/ApiCaller.tsx @@ -26,7 +26,7 @@ export class BackendAPICaller { /** API is not ready until access token has been set for the first time */ private static async ApiReady() { - while (this.accessToken === null || this.accessToken === '') { + while (!this.accessToken || this.accessToken === '') { await timeout(500) } } diff --git a/frontend/src/components/Contexts/MissionFilterContext.tsx b/frontend/src/components/Contexts/MissionFilterContext.tsx index 5bfd31bf4..2092acf83 100644 --- a/frontend/src/components/Contexts/MissionFilterContext.tsx +++ b/frontend/src/components/Contexts/MissionFilterContext.tsx @@ -243,11 +243,11 @@ export const MissionFilterProvider: FC = ({ children }) => { return !value || value.length === 0 }, dateTimeStringToInt: (dateTimeString: string | undefined) => { - if (dateTimeString === '' || dateTimeString === undefined) return undefined + if (dateTimeString === '' || !dateTimeString) return undefined return new Date(dateTimeString).getTime() / 1000 }, dateTimeIntToString: (dateTimeNumber: number | undefined) => { - if (dateTimeNumber === 0 || dateTimeNumber === undefined) return undefined + if (dateTimeNumber === 0 || !dateTimeNumber) return undefined const t = new Date(dateTimeNumber * 1000) const z = new Date(t.getTimezoneOffset() * 60 * 1000) const tLocal = new Date(t.getTime() - z.getTime()) @@ -257,7 +257,7 @@ export const MissionFilterProvider: FC = ({ children }) => { return iso.slice(0, -3) // Removes :00 at the end }, dateTimeIntToPrettyString: (dateTimeNumber: number | undefined) => { - if (dateTimeNumber === 0 || dateTimeNumber === undefined) return undefined + if (dateTimeNumber === 0 || !dateTimeNumber) return undefined const t = new Date(dateTimeNumber * 1000) const z = new Date(t.getTimezoneOffset() * 60 * 1000) const tLocal = new Date(t.getTime() - z.getTime()) diff --git a/frontend/src/components/Pages/FrontPage/MissionOverview/FailedMissionAlertView.tsx b/frontend/src/components/Pages/FrontPage/MissionOverview/FailedMissionAlertView.tsx index 33ce5f58a..91b1d5822 100644 --- a/frontend/src/components/Pages/FrontPage/MissionOverview/FailedMissionAlertView.tsx +++ b/frontend/src/components/Pages/FrontPage/MissionOverview/FailedMissionAlertView.tsx @@ -89,7 +89,7 @@ export function FailedMissionAlertView({ refreshInterval }: RefreshProps) { const sessionValue = sessionStorage.getItem(DismissalTimeSessionKeyName) var lastTime: Date - if (sessionValue === null || sessionValue === '') { + if (!sessionValue || sessionValue === '') { lastTime = addMinutes(Date.now(), -DefaultTimeInterval) } else { lastTime = JSON.parse(sessionValue) diff --git a/frontend/src/components/Pages/FrontPage/MissionOverview/MissionQueueView.tsx b/frontend/src/components/Pages/FrontPage/MissionOverview/MissionQueueView.tsx index 229bba996..c59f05069 100644 --- a/frontend/src/components/Pages/FrontPage/MissionOverview/MissionQueueView.tsx +++ b/frontend/src/components/Pages/FrontPage/MissionOverview/MissionQueueView.tsx @@ -74,12 +74,12 @@ export function MissionQueueView({ refreshInterval }: RefreshProps) { setSelectedEchoMissions(echoMissionsToSchedule) } const onSelectedRobot = (selectedRobot: Robot) => { - if (robotOptions === undefined) return + if (!robotOptions) return setSelectedRobot(selectedRobot) } const onScheduleButtonPress = () => { - if (selectedRobot === undefined) return + if (!selectedRobot) return selectedEchoMissions.forEach((mission: EchoMissionDefinition) => { BackendAPICaller.postMission(mission.echoMissionId, selectedRobot.id, installationCode) @@ -108,7 +108,7 @@ export function MissionQueueView({ refreshInterval }: RefreshProps) { }, [refreshInterval]) useEffect(() => { - if (selectedRobot === undefined || selectedEchoMissions.length === 0) { + if (!selectedRobot || selectedEchoMissions.length === 0) { setScheduleButtonDisabled(true) } else { setScheduleButtonDisabled(false) diff --git a/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusView.tsx b/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusView.tsx index b99002f5b..568ff974f 100644 --- a/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusView.tsx +++ b/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusView.tsx @@ -61,7 +61,7 @@ export function RobotStatusSection({ refreshInterval }: RefreshProps) { return ( robot.currentInstallation.toLocaleLowerCase() === installationCode.toLocaleLowerCase() || (typeof robot.currentInstallation === 'string' && robot.currentInstallation.includes('default')) || - robot.currentInstallation === undefined + !robot.currentInstallation ) }) diff --git a/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx b/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx index b801057e3..819ebe910 100644 --- a/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx +++ b/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx @@ -83,13 +83,13 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { let timer: ReturnType const onSelectedRobot = (selectedRobot: Robot) => { - if (robotOptions === undefined) return + if (!robotOptions) return setSelectedRobot(selectedRobot) } const onScheduleButtonPress = () => { - if (selectedRobot === undefined) return + if (!selectedRobot) return props.missions.forEach((mission) => BackendAPICaller.scheduleMissionDefinition(mission.id, selectedRobot.id)) @@ -104,7 +104,7 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { } const onScheduleOnlyButtonPress = () => { - if (selectedRobot === undefined) return + if (!selectedRobot) return props.unscheduledMissions.forEach((mission) => BackendAPICaller.scheduleMissionDefinition(mission.id, selectedRobot.id) diff --git a/frontend/src/components/Pages/MissionDefinitionPage/MissionDefinitionPage.tsx b/frontend/src/components/Pages/MissionDefinitionPage/MissionDefinitionPage.tsx index 8d4c9be46..b520c5417 100644 --- a/frontend/src/components/Pages/MissionDefinitionPage/MissionDefinitionPage.tsx +++ b/frontend/src/components/Pages/MissionDefinitionPage/MissionDefinitionPage.tsx @@ -183,9 +183,9 @@ function MissionDefinitionEditButtons({ missionDefinition, updateMissionDefiniti const inspectionFrequency = getDayAndHoursFromInspectionFrequency(form.inspectionFrequency) const inspectionFrequencyDays = - inspectionFrequency[0] === null || inspectionFrequency[0] === 0 ? '' : String(inspectionFrequency[0]) + !inspectionFrequency[0] || inspectionFrequency[0] === 0 ? '' : String(inspectionFrequency[0]) const inspectionFrequencyHours = - inspectionFrequency[1] === null || inspectionFrequency[1] === 0 ? '' : String(inspectionFrequency[1]) + !inspectionFrequency[1] || inspectionFrequency[1] === 0 ? '' : String(inspectionFrequency[1]) return ( <> diff --git a/frontend/src/components/Pages/MissionPage/StatusReason.tsx b/frontend/src/components/Pages/MissionPage/StatusReason.tsx index 4ec1e54fc..3ffe361a1 100644 --- a/frontend/src/components/Pages/MissionPage/StatusReason.tsx +++ b/frontend/src/components/Pages/MissionPage/StatusReason.tsx @@ -14,7 +14,7 @@ interface MissionProps { } export function StatusReason({ mission }: MissionProps) { - if (mission.statusReason === null) return <> + if (!mission.statusReason) return <> var warningLevel: 'default' | 'info' | 'warning' | 'danger' = 'info' switch (mission.status) { diff --git a/frontend/src/config.ts b/frontend/src/config.ts index 1944e9aca..8bca2bef1 100644 --- a/frontend/src/config.ts +++ b/frontend/src/config.ts @@ -9,7 +9,7 @@ function GetEnvVariable(name: string): string { // If global value equals its placeholder value 'placeholderValue', it is considered undefined const placeholderValue: string = '${' + name + '}' - if (globalValue === placeholderValue || globalValue === undefined) + if (globalValue === placeholderValue || !globalValue) throw new Error( `Global variable "${name}" is not set. Verify that your .env file is up to date with .env.example` ) diff --git a/frontend/src/utils/MapMarkers.tsx b/frontend/src/utils/MapMarkers.tsx index 50ffaeca1..4fdb6b0e3 100644 --- a/frontend/src/utils/MapMarkers.tsx +++ b/frontend/src/utils/MapMarkers.tsx @@ -16,7 +16,7 @@ export const PlaceTagsInMap = (mission: Mission, map: HTMLCanvasElement, current return task.taskOrder }) ) - if (currentTaskOrder === undefined) { + if (!currentTaskOrder) { currentTaskOrder = mission.isCompleted ? maxTaskOrder + 1 : 0 } diff --git a/frontend/src/utils/filtersAndSorts.tsx b/frontend/src/utils/filtersAndSorts.tsx index 0adf20ad3..70b1900fc 100644 --- a/frontend/src/utils/filtersAndSorts.tsx +++ b/frontend/src/utils/filtersAndSorts.tsx @@ -7,8 +7,5 @@ export const filterRobots = (robots: Robot[], id: string): Robot[] => { } export const compareByDate = (timeA?: Date, timeB?: Date): number => { - return compareDesc( - timeA === undefined ? new Date(0) : new Date(timeA), - timeB === undefined ? new Date(0) : new Date(timeB) - ) + return compareDesc(!timeA ? new Date(0) : new Date(timeA), !timeB ? new Date(0) : new Date(timeB)) }