diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index fd7caa640..d7aba2236 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -20,6 +20,10 @@ import { usePlan } from "@/lib/swr/use-billing"; import Image from "next/image"; import SelectTeam from "./teams/select-team"; import { TeamContextType, initialState, useTeam } from "@/context/team-context"; +import NotificationDropdown from "./notifications/notification-dropdown"; +import { Bell, Webhook } from "lucide-react"; +import useNotifications from "@/lib/swr/use-notifications"; +import { mutate } from "swr"; export default function Sidebar() { const { data: session, status } = useSession(); @@ -31,6 +35,8 @@ export default function Sidebar() { const { currentTeam, teams, isLoading }: TeamContextType = useTeam() || initialState; + const { notifications } = useNotifications(); + const navigation = [ // { // name: "Overview", @@ -53,6 +59,13 @@ export default function Sidebar() { current: router.pathname.includes("analytics"), disabled: true, }, + { + name: "Webhooks", + href: "/webhooks", + icon: Webhook, + current: router.pathname.includes("webhooks"), + disabled: false, + }, { name: "Settings", href: "/settings/general", @@ -75,6 +88,16 @@ export default function Sidebar() { const userPlan = plan && plan.plan; + const getUnReadNotificationCount = () => { + let count = 0; + for (let notification of notifications || []) { + if (!notification.isRead) { + count++; + } + } + return count; + }; + return ( <> @@ -186,7 +209,7 @@ export default function Sidebar() {
{/* Sidebar component, swap this element with another sidebar if you like */}
-
+

Papermark{" "} {userPlan == "pro" ? ( @@ -195,6 +218,18 @@ export default function Sidebar() { ) : null}

+ +
+ + {getUnReadNotificationCount() !== 0 && ( + + {getUnReadNotificationCount() > 9 + ? "9+" + : getUnReadNotificationCount()} + + )} +
+