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.

Filter links by folder

Kiran K1780a15a6bee
diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.ts
index cec3c585cd..c55e6a88d8 100644
--- a/apps/web/app/api/links/route.ts
+++ b/apps/web/app/api/links/route.ts
@@ -24,6 +24,7 @@ export const GET = withWorkspace(
domain,
tagId,
tagIds,
+ folderIds,
search,
sort,
page,
@@ -43,6 +44,7 @@ export const GET = withWorkspace(
domain,
tagId,
tagIds,
+ folderIds,
search,
sort,
page,
diff --git a/apps/web/lib/api/links/get-links-for-workspace.ts b/apps/web/lib/api/links/get-links-for-workspace.ts
index c75440525c..55a3656d56 100644
--- a/apps/web/lib/api/links/get-links-for-workspace.ts
+++ b/apps/web/lib/api/links/get-links-for-workspace.ts
@@ -9,6 +9,7 @@ export async function getLinksForWorkspace({
tagId,
tagIds,
tagNames,
+ folderIds,
search,
sort = "createdAt",
page,
@@ -60,6 +61,13 @@ export async function getLinksForWorkspace({
}
: {}),
...(userId && { userId }),
+
+ // Filter by folderId
+ ...(folderIds && folderIds.length > 0
+ ? {
+ folderId: { in: folderIds },
+ }
+ : {}),
},
include: {
user: includeUser,
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index a929d1cd82..221ab4c40b 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -50,6 +50,11 @@ const LinksQuerySchema = z.object({
.describe(
"The unique name of the tags assigned to the short link (case insensitive).",
),
+ folderIds: z
+ .union([z.string(), z.array(z.string())])
+ .transform((v) => (Array.isArray(v) ? v : v.split(",")))
+ .optional()
+ .describe("The folder IDs to filter the links by."),
search: z
.string()
.optional()