:feature: Notifications

Signed-off-by: Pau Costa <mico@micodev.es>
main
Pau Costa Ferrer 2024-02-12 12:02:39 +01:00
parent fc79245f9a
commit a4ba28eaef
2 changed files with 38 additions and 5 deletions

View File

@ -1,11 +1,16 @@
import NotificationsIcon from "@mui/icons-material/Notifications"; import NotificationsIcon from "@mui/icons-material/Notifications";
import { Badge, Tooltip } from "@mui/material"; import { Badge, Tooltip } from "@mui/material";
import { useNavigate } from "react-router-dom";
export default function NotificationBell() { export default function NotificationBell() {
const navigate = useNavigate();
const handleClick = () => {
navigate("/notifications");
};
return ( return (
<Badge badgeContent={4} color="secondary"> <Badge badgeContent={0} color="secondary">
<Tooltip title="Notifications"> <Tooltip title="Notifications">
<NotificationsIcon /> <NotificationsIcon onClick={handleClick} />
</Tooltip> </Tooltip>
</Badge> </Badge>
); );

View File

@ -1,3 +1,31 @@
export default function Notification() { import { useSelector } from "react-redux";
return <>Notification</>; import { selectUserInfo } from "../app/loginSlice";
import { Box, List, ListItem, Paper } from "@mui/material";
export default function ANotification() {
const userInfo = useSelector(selectUserInfo);
return (
<Box sx={{ display: "flex", flexDirection: "column" }}>
<List sx={{ width: "100%" }}>
{userInfo.notifications.length === 0 ? (
<ListItem sx={{ width: "100%" }}>No notifications</ListItem>
) : (
userInfo.notifications.map((notification: any) => (
<ListItem key={notification.id} sx={{ width: "100%" }}>
<Paper
sx={{
width: "100%",
margin: "1rem",
padding: "0.2rem 1rem 0.2rem 1rem",
}}
>
{notification.message}
</Paper>
</ListItem>
))
)}
</List>
</Box>
);
} }