From 41c691ad4c13262097c5504d0d141d3035de7202 Mon Sep 17 00:00:00 2001 From: Aritra Chatterjee Date: Wed, 21 Feb 2024 19:06:59 +0530 Subject: [PATCH] fix: trigger error modal --- .../webapp/src/components/modals/globalErrorModal.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/webapp/src/components/modals/globalErrorModal.tsx b/packages/webapp/src/components/modals/globalErrorModal.tsx index e030fe9a..20f43bf9 100644 --- a/packages/webapp/src/components/modals/globalErrorModal.tsx +++ b/packages/webapp/src/components/modals/globalErrorModal.tsx @@ -6,6 +6,7 @@ import { DialogTitle, } from "../ui/dialog" import { Button } from "src/components/ui/button" +import { useEffect, useState } from "react" /** * A modal displayed globally (setup in _app.tsx) whenever the errorConfig state is set to non-null. @@ -16,9 +17,14 @@ export const GlobalErrorModal = ({ config }: { config: ErrorConfig }) => { // UI. This is good practice as it lets the user figure out what happened. Really not a priority // at the moment, and the error should be systematically logged to the console instead, for // debugging purposes. + const [ open, setOpen ] = useState(false) + useEffect(() => { + if(config !== null && !open) setOpen(true) + else setOpen(false) + }, [config, open]) return ( - + {config.title} {config.message !== "" && (