From 83c0bde22ba560fb8f4f04d8136c146b7f0a025f Mon Sep 17 00:00:00 2001 From: GyDi Date: Thu, 16 Dec 2021 21:37:55 +0800 Subject: [PATCH] feat: distinguish level notice --- src/utils/use-notice.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/utils/use-notice.tsx b/src/utils/use-notice.tsx index 4999f05..26cab4c 100644 --- a/src/utils/use-notice.tsx +++ b/src/utils/use-notice.tsx @@ -1,6 +1,6 @@ import { useMemo, useState } from "react"; -import { IconButton, Slide, Snackbar } from "@mui/material"; -import { Close } from "@mui/icons-material"; +import { Box, IconButton, Slide, Snackbar } from "@mui/material"; +import { Close, CheckCircleRounded, ErrorRounded } from "@mui/icons-material"; interface NoticeInstance { info: (msg: string) => void; @@ -16,6 +16,17 @@ const useNotice = () => { if (reason !== "clickaway") setMessage(""); }; + const msgElement = + level === "info" ? ( + message + ) : ( + + {level === "error" && } + {level === "success" && } + {message} + + ); + const element = useMemo( () => ( { anchorOrigin={{ vertical: "top", horizontal: "right" }} autoHideDuration={3000} onClose={handleClose} - message={message} + message={msgElement} + sx={{ maxWidth: 360 }} TransitionComponent={(p) => } + transitionDuration={200} action={