Files
zkldi_Tachi/client/src/components/layout/header/UserNotificationButton.tsx
T
zkldi 54a0578ebc refactor: remove /dashboard prefix and change /users/ to /u/
This overhaul automatically redirects old routes to new routes
they served no purpose anyway and were link noise.
i don't like them
2022-12-19 02:31:35 +00:00

36 lines
1.0 KiB
TypeScript

import Icon from "components/util/Icon";
import useApiQuery from "components/util/query/useApiQuery";
import { NotificationsContext } from "context/NotificationsContext";
import React, { useContext, useMemo } from "react";
import { Link } from "react-router-dom";
import { NotificationDocument, UserDocument } from "tachi-common";
export function UserNotificationButton({ user }: { user: UserDocument }) {
const { notifications } = useContext(NotificationsContext);
const unread = useMemo(() => {
if (!notifications) {
return 0;
}
return notifications.filter((e) => e.read === false).length;
}, [notifications]);
return (
<div className="topbar-item">
<Link to="/notifications">
<div
className="btn btn-icon btn-hover-transparent-white btn-dropdown btn-lg mr-1"
id="kt_quick_notifications_toggle"
>
{unread > 0 ? (
<Icon type="envelope" colour="primary" />
) : (
<Icon type="envelope" regular colour="muted" />
)}
</div>
</Link>
</div>
);
}