import { useState } from "react"; import { ActionIcon, Group, Indicator, Menu, Popover, ScrollArea, Tabs, Text, Tooltip, } from "@mantine/core"; import { IconBell, IconCheck, IconChecks, IconDots, IconFilter, } from "@tabler/icons-react"; import { useTranslation } from "react-i18next"; import { NotificationList } from "./notification-list"; import { NotificationFilter, NotificationTab, } from "../types/notification.types"; import { useMarkAllReadMutation, useUnreadCountQuery, } from "../queries/notification-query"; import classes from "../notification.module.css"; export function NotificationPopover() { const { t } = useTranslation(); const [opened, setOpened] = useState(false); const [tab, setTab] = useState("direct"); const [filter, setFilter] = useState("all"); const { data: unreadData } = useUnreadCountQuery(); const markAllRead = useMarkAllReadMutation(); const unreadCount = unreadData?.count ?? 0; const handleMarkAllRead = () => { markAllRead.mutate(); }; return ( setOpened((o) => !o)} > {t("Notifications")} {t("Filter")} setFilter("all")} rightSection={ filter === "all" ? : null } > {t("All notifications")} setFilter("unread")} rightSection={ filter === "unread" ? : null } > {t("Unread only")} } onClick={handleMarkAllRead} disabled={unreadCount === 0} > {t("Mark all as read")} setTab(value as NotificationTab)} variant="default" color="dark" > {t("Direct")} {t("Updates")} setOpened(false)} /> ); }