From 14e6b69c6bbcfca17199615a80796f64341e1e3b Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Tue, 16 Aug 2022 12:08:12 +0530 Subject: [PATCH] PCORE-2213: added check for data from api (#37) * feat: minor cosmetic change in showing dates * feat: minor cosmetic change in showing dates * feat: scroll to input when editing incident * fix: class to classname * fix: added array check for api data * feat: used created_at instead of updated_at --- react-frontend/src/components/IncidentsBlock.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/react-frontend/src/components/IncidentsBlock.jsx b/react-frontend/src/components/IncidentsBlock.jsx index 1a300332..c1e4199a 100644 --- a/react-frontend/src/components/IncidentsBlock.jsx +++ b/react-frontend/src/components/IncidentsBlock.jsx @@ -17,7 +17,9 @@ const IncidentsBlock = ({ service, group }) => { data = await API.incidents_service(service.id); } - setIncidents(data || []); + if(Array.isArray(data)) { + setIncidents(data); + } } fetchData(); }, [service.id, group?.id]); @@ -37,7 +39,7 @@ const IncidentsBlock = ({ service, group }) => { const latestUpdate = updates?.length > 0 && updates[0]; const updatedAt = latestUpdate - ? latestUpdate.updated_at + ? latestUpdate.created_at : updated_at; return (