Skip to content
Snippets Groups Projects
Commit db0dec01 authored by Max Frederiksen's avatar Max Frederiksen Committed by Max Frederiksen
Browse files

isNotFound

parent dcf965ad
No related branches found
No related tags found
2 merge requests!612Release 5.0.0,!590CE-3429: Convert to typescript
export const isNotFound = (status: string | number | null | undefined) =>
status === "404" || status === 404;
...@@ -5,6 +5,8 @@ import { IOCDetailsView } from "./IOCDetailsView"; ...@@ -5,6 +5,8 @@ import { IOCDetailsView } from "./IOCDetailsView";
import { NotFoundView } from "../../components/navigation/NotFoundView/NotFoundView"; import { NotFoundView } from "../../components/navigation/NotFoundView/NotFoundView";
import { useGetIocQuery } from "../../store/enhancedApi"; import { useGetIocQuery } from "../../store/enhancedApi";
import { ApiAlertError } from "../../components/common/Alerts/ApiAlertError"; import { ApiAlertError } from "../../components/common/Alerts/ApiAlertError";
import { getErrorState } from "../../components/common/Alerts/AlertsData";
import { isNotFound } from "../../components/navigation/NotFoundView/isNotFound";
const IOC_POLL_INTERVAL = 5000; const IOC_POLL_INTERVAL = 5000;
...@@ -22,7 +24,9 @@ export function IOCDetailsContainer({ id }: IOCDetailsContainerProps) { ...@@ -22,7 +24,9 @@ export function IOCDetailsContainer({ id }: IOCDetailsContainerProps) {
{ skip: !id, pollingInterval: IOC_POLL_INTERVAL } { skip: !id, pollingInterval: IOC_POLL_INTERVAL }
); );
if (error && "status" in error && error.status === 404) { const { status } = getErrorState(error);
if (isNotFound(status)) {
return <NotFoundView />; return <NotFoundView />;
} }
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
useFindNetBoxHostByHostIdQuery useFindNetBoxHostByHostIdQuery
} from "../../../store/deployApi"; } from "../../../store/deployApi";
import { getErrorState } from "../../../components/common/Alerts/AlertsData"; import { getErrorState } from "../../../components/common/Alerts/AlertsData";
import { isNotFound } from "../../../components/navigation/NotFoundView/isNotFound";
interface HostDetailsContainerProps { interface HostDetailsContainerProps {
hostId?: string; hostId?: string;
...@@ -28,7 +29,7 @@ export function HostDetailsContainer({ hostId }: HostDetailsContainerProps) { ...@@ -28,7 +29,7 @@ export function HostDetailsContainer({ hostId }: HostDetailsContainerProps) {
const { status, message } = getErrorState(fetchError || alertError); const { status, message } = getErrorState(fetchError || alertError);
if (status === "404" || status === 404) { if (isNotFound(status)) {
return ( return (
<NotFoundView <NotFoundView
message={message} message={message}
......
...@@ -5,6 +5,7 @@ import { JobDetailsView } from "./JobDetailsView"; ...@@ -5,6 +5,7 @@ import { JobDetailsView } from "./JobDetailsView";
import { NotFoundView } from "../../components/navigation/NotFoundView/NotFoundView"; import { NotFoundView } from "../../components/navigation/NotFoundView/NotFoundView";
import { useFetchJobQuery } from "../../store/deployApi"; import { useFetchJobQuery } from "../../store/deployApi";
import { getErrorState } from "../../components/common/Alerts/AlertsData"; import { getErrorState } from "../../components/common/Alerts/AlertsData";
import { isNotFound } from "../../components/navigation/NotFoundView/isNotFound";
const POLL_DEPLOYMENT_INTERVAL = 5000; const POLL_DEPLOYMENT_INTERVAL = 5000;
export function JobDetailsContainer({ id }: { id?: string }) { export function JobDetailsContainer({ id }: { id?: string }) {
...@@ -30,7 +31,7 @@ export function JobDetailsContainer({ id }: { id?: string }) { ...@@ -30,7 +31,7 @@ export function JobDetailsContainer({ id }: { id?: string }) {
const { status, message } = getErrorState(jobError); const { status, message } = getErrorState(jobError);
if (status === "404" || status === 404) { if (isNotFound(status)) {
return ( return (
<NotFoundView <NotFoundView
message={message} message={message}
......
...@@ -18,6 +18,7 @@ import { NotFoundView } from "../../components/navigation/NotFoundView/NotFoundV ...@@ -18,6 +18,7 @@ import { NotFoundView } from "../../components/navigation/NotFoundView/NotFoundV
import { RecordDetails, useGetRecordQuery } from "../../store/deployApi"; import { RecordDetails, useGetRecordQuery } from "../../store/deployApi";
import { GlobalAppBarContext as GlobalAppBarContextType } from "../../types/common"; import { GlobalAppBarContext as GlobalAppBarContextType } from "../../types/common";
import { getErrorState } from "../../components/common/Alerts/AlertsData"; import { getErrorState } from "../../components/common/Alerts/AlertsData";
import { isNotFound } from "../../components/navigation/NotFoundView/isNotFound";
const LAST_UPDATED = "Last updated"; const LAST_UPDATED = "Last updated";
const RECORD_TYPE = "Record type"; const RECORD_TYPE = "Record type";
...@@ -93,7 +94,7 @@ export function RecordDetailsView() { ...@@ -93,7 +94,7 @@ export function RecordDetailsView() {
const { status } = getErrorState(fetchError); const { status } = getErrorState(fetchError);
if (decodedName.includes(";") || status === "404" || status === 404) { if (decodedName.includes(";") || isNotFound(status)) {
return <NotFoundView />; return <NotFoundView />;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment