UNPKG

@churchapps/apphelper

Version:

Library of helper functions for React and NextJS ChurchApps

21 lines 955 B
"use client"; import { jsx as _jsx } from "react/jsx-runtime"; import { Alert, Snackbar } from "@mui/material"; import React, { useEffect } from "react"; export const ErrorMessages = props => { const [open, setOpen] = React.useState(false); const [items, setItems] = React.useState([]); useEffect(() => { if (props.errors.length > 0) { const _items = []; for (let i = 0; i < props.errors.length; i++) { _items.push(_jsx("div", { children: props.errors[i] }, props.errors[i])); } setItems(_items); setOpen(true); } }, [props.errors]); const result = (_jsx(Snackbar, { open: open, anchorOrigin: { horizontal: "center", vertical: "bottom" }, autoHideDuration: 6000, onClose: () => setOpen(false), children: _jsx(Alert, { variant: "filled", severity: "error", children: items }) })); return result; }; //# sourceMappingURL=ErrorMessages.js.map