diff --git a/Dashboard/src/Components/IncidentSeverity/FetchIncidentSeverity.tsx b/Dashboard/src/Components/IncidentSeverity/FetchIncidentSeverity.tsx index df66f7970e..4078396d39 100644 --- a/Dashboard/src/Components/IncidentSeverity/FetchIncidentSeverity.tsx +++ b/Dashboard/src/Components/IncidentSeverity/FetchIncidentSeverity.tsx @@ -26,35 +26,36 @@ const FetchIncidentSeverities: FunctionComponent = ( Array >([]); - const fetchIncidentSeverities: PromiseVoidFunction = async (): Promise => { - setIsLoading(true); - setError(""); + const fetchIncidentSeverities: PromiseVoidFunction = + async (): Promise => { + setIsLoading(true); + setError(""); - try { - const incidentSeverities: ListResult = - await ModelAPI.getList({ - modelType: IncidentSeverity, - query: { - _id: new Includes(props.onCallDutyPolicyIds), - }, - skip: 0, - limit: LIMIT_PER_PROJECT, - select: { - name: true, - _id: true, - }, - sort: { - name: SortOrder.Ascending, - }, - }); + try { + const incidentSeverities: ListResult = + await ModelAPI.getList({ + modelType: IncidentSeverity, + query: { + _id: new Includes(props.onCallDutyPolicyIds), + }, + skip: 0, + limit: LIMIT_PER_PROJECT, + select: { + name: true, + _id: true, + }, + sort: { + name: SortOrder.Ascending, + }, + }); - setIncidentSeverities(incidentSeverities.data); - } catch (err) { - setError(API.getFriendlyMessage(err)); - } + setIncidentSeverities(incidentSeverities.data); + } catch (err) { + setError(API.getFriendlyMessage(err)); + } - setIsLoading(false); - }; + setIsLoading(false); + }; useEffect(() => { fetchIncidentSeverities().catch((err: Exception) => { diff --git a/Dashboard/src/Components/Monitor/FetchMonitors.tsx b/Dashboard/src/Components/Monitor/FetchMonitors.tsx index fa35a897e7..33f0b18b73 100644 --- a/Dashboard/src/Components/Monitor/FetchMonitors.tsx +++ b/Dashboard/src/Components/Monitor/FetchMonitors.tsx @@ -10,6 +10,8 @@ import ListResult from "Common/UI/Utils/BaseDatabase/ListResult"; import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; import ComponentLoader from "Common/UI/Components/ComponentLoader/ComponentLoader"; import MonitorsElement from "./Monitors"; +import { PromiseVoidFunction } from "Common/Types/FunctionTypes"; +import Exception from "Common/Types/Exception/Exception"; export interface ComponentProps { monitorIds: Array; @@ -22,7 +24,7 @@ const FetchMonitors: FunctionComponent = ( const [error, setError] = React.useState(""); const [monitor, setMonitor] = React.useState>([]); - const fetchMonitor = async () => { + const fetchMonitor: PromiseVoidFunction = async (): Promise => { setIsLoading(true); setError(""); @@ -52,7 +54,7 @@ const FetchMonitors: FunctionComponent = ( }; useEffect(() => { - fetchMonitor().catch((err) => { + fetchMonitor().catch((err: Exception) => { setError(API.getFriendlyMessage(err)); }); }, []); diff --git a/Dashboard/src/Components/MonitorStatus/FetchMonitorStatuses.tsx b/Dashboard/src/Components/MonitorStatus/FetchMonitorStatuses.tsx index 9a3ac0ddd1..c168900138 100644 --- a/Dashboard/src/Components/MonitorStatus/FetchMonitorStatuses.tsx +++ b/Dashboard/src/Components/MonitorStatus/FetchMonitorStatuses.tsx @@ -10,6 +10,8 @@ import ListResult from "Common/UI/Utils/BaseDatabase/ListResult"; import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; import ComponentLoader from "Common/UI/Components/ComponentLoader/ComponentLoader"; import MonitorStatusesElement from "./MonitorStatusesElement"; +import { PromiseVoidFunction } from "Common/Types/FunctionTypes"; +import Exception from "Common/Types/Exception/Exception"; export interface ComponentProps { monitorStatusIds: Array; @@ -24,7 +26,7 @@ const FetchMonitorStatuses: FunctionComponent = ( Array >([]); - const fetchMonitorStatus = async () => { + const fetchMonitorStatus: PromiseVoidFunction = async (): Promise => { setIsLoading(true); setError(""); @@ -54,7 +56,7 @@ const FetchMonitorStatuses: FunctionComponent = ( }; useEffect(() => { - fetchMonitorStatus().catch((err) => { + fetchMonitorStatus().catch((err: Exception) => { setError(API.getFriendlyMessage(err)); }); }, []); diff --git a/Dashboard/src/Components/OnCallPolicy/FetchOnCallPolicies.tsx b/Dashboard/src/Components/OnCallPolicy/FetchOnCallPolicies.tsx index 0f1023799e..94ed57d952 100644 --- a/Dashboard/src/Components/OnCallPolicy/FetchOnCallPolicies.tsx +++ b/Dashboard/src/Components/OnCallPolicy/FetchOnCallPolicies.tsx @@ -10,6 +10,8 @@ import ListResult from "Common/UI/Utils/BaseDatabase/ListResult"; import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; import ComponentLoader from "Common/UI/Components/ComponentLoader/ComponentLoader"; import OnCallPoliciesElement from "./OnCallPolicies"; +import { PromiseVoidFunction } from "Common/Types/FunctionTypes"; +import Exception from "Common/Types/Exception/Exception"; export interface ComponentProps { onCallDutyPolicyIds: Array; @@ -24,38 +26,39 @@ const FetchOnCallDutyPolicies: FunctionComponent = ( Array >([]); - const fetchOnCallDutyPolicies = async () => { - setIsLoading(true); - setError(""); + const fetchOnCallDutyPolicies: PromiseVoidFunction = + async (): Promise => { + setIsLoading(true); + setError(""); - try { - const onCallDutyPolicies: ListResult = - await ModelAPI.getList({ - modelType: OnCallDutyPolicy, - query: { - _id: new Includes(props.onCallDutyPolicyIds), - }, - skip: 0, - limit: LIMIT_PER_PROJECT, - select: { - name: true, - _id: true, - }, - sort: { - name: SortOrder.Ascending, - }, - }); + try { + const onCallDutyPolicies: ListResult = + await ModelAPI.getList({ + modelType: OnCallDutyPolicy, + query: { + _id: new Includes(props.onCallDutyPolicyIds), + }, + skip: 0, + limit: LIMIT_PER_PROJECT, + select: { + name: true, + _id: true, + }, + sort: { + name: SortOrder.Ascending, + }, + }); - setOnCallDutyPolicies(onCallDutyPolicies.data); - } catch (err) { - setError(API.getFriendlyMessage(err)); - } + setOnCallDutyPolicies(onCallDutyPolicies.data); + } catch (err) { + setError(API.getFriendlyMessage(err)); + } - setIsLoading(false); - }; + setIsLoading(false); + }; useEffect(() => { - fetchOnCallDutyPolicies().catch((err) => { + fetchOnCallDutyPolicies().catch((err: Exception) => { setError(API.getFriendlyMessage(err)); }); }, []);