aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/sidebar/InvitationNotificationBadge.tsx
blob: e4d7b39fb40bb4959aee0b3ad2bd37fbf5ef11d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"use client";

import { api } from "@/lib/trpc";

export function InvitationNotificationBadge() {
  const { data: pendingInvitations } = api.lists.getPendingInvitations.useQuery(
    undefined,
    {
      refetchInterval: 1000 * 60 * 5,
    },
  );
  const pendingInvitationsCount = pendingInvitations?.length ?? 0;

  if (pendingInvitationsCount === 0) {
    return null;
  }

  return (
    <div className="flex items-center px-1">
      <span className="rounded-full bg-blue-500 px-2 py-0.5 text-center text-xs text-white">
        {pendingInvitationsCount}
      </span>
    </div>
  );
}