diff --git a/frontend/src/container/GridGraphLayout/Graph/index.tsx b/frontend/src/container/GridGraphLayout/Graph/index.tsx index 2c163c2b05..0cf795b06d 100644 --- a/frontend/src/container/GridGraphLayout/Graph/index.tsx +++ b/frontend/src/container/GridGraphLayout/Graph/index.tsx @@ -23,7 +23,7 @@ import { Widgets } from 'types/api/dashboard/getAll'; import Bar from './Bar'; import FullView from './FullView'; -import { Modal, FullViewContainer } from './styles'; +import { Modal, FullViewContainer, ErrorContainer } from './styles'; const GridCardGraph = ({ widget, @@ -124,6 +124,38 @@ const GridCardGraph = ({ [], ); + const getModals = () => { + return ( + <> + onToggleModal(setDeletModal)} + visible={deleteModal} + title="Delete" + height="10vh" + onOk={onDeleteHandler} + centered + > + Are you sure you want to delete this widget + + + onToggleModal(setModal)} + width="85%" + destroyOnClose + > + + + + + + ); + }; + const onDeleteHandler = useCallback(() => { deleteWidget({ widgetId: widget.id }); onToggleModal(setDeletModal); @@ -131,7 +163,18 @@ const GridCardGraph = ({ }, [deleteWidget, widget, onToggleModal, isDeleted]); if (state.error) { - return
{state.errorMessage}
; + return ( + <> + {getModals()} + onToggleModal(setModal)} + widget={widget} + onDeleteHandler={(): void => onToggleModal(setDeletModal)} + /> + + {state.errorMessage} + + ); } if (state.loading === true || state.payload === undefined) { @@ -146,31 +189,7 @@ const GridCardGraph = ({ onDeleteHandler={(): void => onToggleModal(setDeletModal)} /> - onToggleModal(setDeletModal)} - visible={deleteModal} - title="Delete" - height="10vh" - onOk={onDeleteHandler} - centered - > - Are you sure you want to delete this widget - - - onToggleModal(setModal)} - width="85%" - destroyOnClose - > - - - - + {getModals()} ` export const FullViewContainer = styled.div` height: 70vh; `; + +export const ErrorContainer = styled.div` + margin-top: 2rem; + padding-left: 2rem; + padding-right: 2rem; +`;