diff options
Diffstat (limited to 'FrontEnd/src/views/common/alert/AlertHost.tsx')
-rw-r--r-- | FrontEnd/src/views/common/alert/AlertHost.tsx | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/FrontEnd/src/views/common/alert/AlertHost.tsx b/FrontEnd/src/views/common/alert/AlertHost.tsx index 949be7ed..ba6d6a0f 100644 --- a/FrontEnd/src/views/common/alert/AlertHost.tsx +++ b/FrontEnd/src/views/common/alert/AlertHost.tsx @@ -1,16 +1,13 @@ import React from "react"; import without from "lodash/without"; import { useTranslation } from "react-i18next"; -import { Alert } from "react-bootstrap"; +import classNames from "classnames"; -import { - alertService, - AlertInfoEx, - kAlertHostId, - AlertInfo, -} from "@/services/alert"; +import { alertService, AlertInfoEx, AlertInfo } from "@/services/alert"; import { convertI18nText } from "@/common"; +import "./alert.css"; + interface AutoCloseAlertProps { alert: AlertInfo; close: () => void; @@ -52,29 +49,36 @@ export const AutoCloseAlert: React.FC<AutoCloseAlertProps> = (props) => { }; return ( - <Alert - className="m-3" - variant={alert.type ?? "primary"} + <div + className={classNames( + "m-3 cru-alert", + "cru-" + (alert.type ?? "primary") + )} onClick={cancelTimer} - onClose={close} - dismissible > - {(() => { - const { message } = alert; - if (typeof message === "function") { - const Message = message; - return <Message />; - } else return convertI18nText(message, t); - })()} - </Alert> + <div className="cru-alert-content"> + {(() => { + const { message, customMessage } = alert; + if (customMessage != null) { + return customMessage; + } else { + return convertI18nText(message, t); + } + })()} + </div> + <div className="cru-alert-close-button-container"> + <i + className={classNames("icon-button bi-x cru-alert-close-button")} + onClick={close} + /> + </div> + </div> ); }; const AlertHost: React.FC = () => { const [alerts, setAlerts] = React.useState<AlertInfoEx[]>([]); - // react guarantee that state setters are stable, so we don't need to add it to dependency list - React.useEffect(() => { const consume = (alert: AlertInfoEx): void => { setAlerts((old) => [...old, alert]); @@ -87,7 +91,7 @@ const AlertHost: React.FC = () => { }, []); return ( - <div id={kAlertHostId} className="alert-container"> + <div className="alert-container"> {alerts.map((alert) => { return ( <AutoCloseAlert |