diff --git a/src/lib/services/clients.service.ts b/src/lib/services/clients.service.ts
index 7bfc5ac..290c2e1 100644
--- a/src/lib/services/clients.service.ts
+++ b/src/lib/services/clients.service.ts
@@ -4,6 +4,7 @@ import { db } from '@/lib/db';
import {
clients,
clientContacts,
+ clientNotes,
clientRelationships,
clientTags,
clientAddresses,
@@ -251,6 +252,19 @@ export async function getClientById(id: string, portId: string) {
const portalEnabled = await isPortalEnabledForPort(portId);
+ // Counts surfaced for tab badges (Interests + Notes — Yachts/Companies/etc
+ // get their counts from the corresponding row arrays we already fetched).
+ const [interestCountRow] = await db
+ .select({ count: count() })
+ .from(interests)
+ .where(
+ and(eq(interests.portId, portId), eq(interests.clientId, id), isNull(interests.archivedAt)),
+ );
+ const [noteCountRow] = await db
+ .select({ count: count() })
+ .from(clientNotes)
+ .where(eq(clientNotes.clientId, id));
+
return {
...client,
contacts,
@@ -259,6 +273,8 @@ export async function getClientById(id: string, portId: string) {
yachts: yachtRows,
companies: membershipRows,
activeReservations,
+ interestCount: interestCountRow?.count ?? 0,
+ noteCount: noteCountRow?.count ?? 0,
clientPortalEnabled: portalEnabled,
};
}