Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add applications count badge

Tim Wilson5ffe52b13ef6
diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
index a1270438cc..c578a35f80 100644
--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
@@ -41,6 +41,7 @@ import { Hyperlink } from "./icons/hyperlink";
import { LinesY } from "./icons/lines-y";
import { User } from "./icons/user";
import { SidebarNav, SidebarNavAreas, SidebarNavGroups } from "./sidebar-nav";
+import { useProgramApplicationsCount } from "./use-program-applications-count";
import { WorkspaceDropdown } from "./workspace-dropdown";
type SidebarNavData = {
@@ -50,6 +51,7 @@ type SidebarNavData = {
defaultProgramId?: string;
session?: Session | null;
showNews?: boolean;
+ applicationsCount?: number;
};
const FIVE_YEARS_SECONDS = 60 * 60 * 24 * 365 * 5;
@@ -175,7 +177,7 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
}),
// Program
- program: ({ slug, showNews }) => ({
+ program: ({ slug, showNews, applicationsCount }) => ({
title: "Partner Program",
showNews,
direction: "left",
@@ -208,6 +210,11 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
name: "Applications",
icon: UserCheck,
href: `/${slug}/program/partners/applications`,
+ badge: applicationsCount
+ ? applicationsCount > 99
+ ? "99+"
+ : applicationsCount
+ : undefined,
},
],
},
@@ -398,6 +405,10 @@ export function AppSidebarNav({
: "default";
}, [slug, pathname]);
+ const applicationsCount = useProgramApplicationsCount({
+ enabled: currentArea === "program",
+ });
+
return (
<SidebarNav
groups={NAV_GROUPS}
@@ -412,6 +423,7 @@ export function AppSidebarNav({
session: session || undefined,
showNews: pathname.startsWith(`/${slug}/program`) ? false : true,
defaultProgramId: defaultProgramId || undefined,
+ applicationsCount,
}}
toolContent={toolContent}
newsContent={newsContent}
diff --git a/apps/web/ui/layout/sidebar/sidebar-nav.tsx b/apps/web/ui/layout/sidebar/sidebar-nav.tsx
index fd7b6e2b88..84994797cc 100644
--- a/apps/web/ui/layout/sidebar/sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/sidebar-nav.tsx
@@ -26,7 +26,7 @@ export type NavItemCommon = {
href: `/${string}`;
exact?: boolean;
isActive?: (pathname: string, href: string) => boolean;
- badge?: string;
+ badge?: ReactNode;
};
export type NavSubItemType = NavItemCommon;
diff --git a/apps/web/ui/layout/sidebar/use-program-applications-count.tsx b/apps/web/ui/layout/sidebar/use-program-applications-count.tsx
new file mode 100644
index 0000000000..72d0a9b178
--- /dev/null
+++ b/apps/web/ui/layout/sidebar/use-program-applications-count.tsx
@@ -0,0 +1,17 @@
+"use client";
+
+import usePartnersCount from "@/lib/swr/use-partners-count";
+
+export function useProgramApplicationsCount({
+ enabled,
+}: {
+ enabled?: boolean;
+}) {
+ const { partnersCount } = usePartnersCount<number | undefined>({
+ status: "pending",
+ ignoreParams: true,
+ enabled,
+ });
+
+ return partnersCount;
+}