Skip to content

Commit

Permalink
fix: trigger error modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraviolet10 authored and norswap committed Feb 26, 2024
1 parent 467a7df commit 41c691a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/webapp/src/components/modals/globalErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<boolean>(false)
useEffect(() => {
if(config !== null && !open) setOpen(true)
else setOpen(false)
}, [config, open])

return (
<Dialog>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTitle>{config.title}</DialogTitle>
<DialogContent>
{config.message !== "" && (
Expand Down

0 comments on commit 41c691a

Please sign in to comment.