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 placeholder for groups/count API

Kiran K859e38613606
diff --git a/apps/web/app/(ee)/api/groups/count/route.ts b/apps/web/app/(ee)/api/groups/count/route.ts
new file mode 100644
index 0000000000..5cb8c0fe08
--- /dev/null
+++ b/apps/web/app/(ee)/api/groups/count/route.ts
@@ -0,0 +1,25 @@
+import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
+import { withWorkspace } from "@/lib/auth";
+import { NextResponse } from "next/server";
+
+// GET /api/groups/count - get the count of groups for a program
+export const GET = withWorkspace(
+ async ({ workspace, searchParams }) => {
+ const programId = getDefaultProgramIdOrThrow(workspace);
+
+ // TODO:
+ // Decide the filters we want to fetch the count by
+
+ return NextResponse.json(1);
+ },
+ {
+ requiredPlan: [
+ "business",
+ "business extra",
+ "business max",
+ "business plus",
+ "advanced",
+ "enterprise",
+ ],
+ },
+);
diff --git a/apps/web/app/(ee)/api/groups/route.ts b/apps/web/app/(ee)/api/groups/route.ts
index df28b52c85..1ef595a5f5 100644
--- a/apps/web/app/(ee)/api/groups/route.ts
+++ b/apps/web/app/(ee)/api/groups/route.ts
@@ -23,10 +23,14 @@ export const GET = withWorkspace(
const groups = await prisma.partnerGroup.findMany({
where: {
programId,
- OR: [
- { name: { startsWith: search } },
- { slug: { startsWith: search } },
- ],
+ ...(search
+ ? {
+ OR: [
+ { name: { startsWith: search } },
+ { slug: { startsWith: search } },
+ ],
+ }
+ : {}),
},
orderBy: {
createdAt: "desc",
@@ -35,6 +39,8 @@ export const GET = withWorkspace(
take: pageSize,
});
+ console.log(groups);
+
return NextResponse.json(z.array(GroupSchema).parse(groups));
},
{