The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Merge branch 'main' into async-folders
Tim Wilsona14f3b45c3cc
diff --cc apps/web/app/api/folders/route.tsindex 86b4abe953,705597f4ab..dcf6dc7840--- a/apps/web/app/api/folders/route.ts+++ b/apps/web/app/api/folders/route.ts@@@ -15,16 -15,14 +15,16 @@@ import { NextResponse } from "next/serv// GET /api/folders - get all folders for a workspaceexport const GET = withWorkspace(async ({ workspace, headers, session, searchParams }) => {- const { search, pageSize, page } =- const { search, includeLinkCount } =++ const { search, includeLinkCount, pageSize, page } =listFoldersQuerySchema.parse(searchParams);const folders = await getFolders({workspaceId: workspace.id,userId: session.user.id,- includeLinkCount: true,search,+ pageSize,+ page,+ includeLinkCount,});return NextResponse.json(FolderSchema.array().parse(folders), {diff --cc apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/folders/page-client.tsxindex 023c3eb4cb,4e7f3f7f49..8061528296--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/folders/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/folders/page-client.tsx@@@ -30,11 -28,9 +30,12 @@@ export const FoldersPageClient = () =>const { AddFolderButton, AddFolderModal } = useAddFolderModal();+ const { data: foldersCount } = useFoldersCount({+ includeParams: true,+ });const { folders, loading, isValidating } = useFolders({includeParams: true,+ includeLinkCount: true,});const { data: allLinksCount } = useLinksCount({diff --cc apps/web/lib/swr/use-folders.tsindex 70b7bbbe49,c59e1933d1..bcf696ea0b--- a/apps/web/lib/swr/use-folders.ts+++ b/apps/web/lib/swr/use-folders.ts@@@ -6,12 -6,10 +6,14 @@@ import useWorkspace from "./use-workspaexport default function useFolders({includeParams = false,+ includeLinkCount = false,+ query,+ options,}: {includeParams?: boolean;+ includeLinkCount?: boolean;+ query?: Record<string, any>;+ options?: SWRConfiguration;} = {}) {const { id: workspaceId, plan, flags } = useWorkspace();const { getQueryString } = useRouterStuff();diff --cc apps/web/lib/zod/schemas/folders.tsindex 4c73f22f87,c504ae7ef3..16091f4f6a--- a/apps/web/lib/zod/schemas/folders.ts+++ b/apps/web/lib/zod/schemas/folders.ts@@@ -5,7 -5,7 +5,7 @@@ importimport { FolderAccessLevel } from "@/lib/types";import z from "@/lib/zod";import { FolderUserRole } from "@dub/prisma/client";- import { getPaginationQuerySchema } from "./misc";-import { booleanQuerySchema } from "./misc";++import { booleanQuerySchema, getPaginationQuerySchema } from "./misc";const workspaceFolderAccess = z.enum(@@@ -39,15 -39,16 +39,18 @@@ export const createFolderSchema = z.objaccessLevel: workspaceFolderAccess,});-export const listFoldersQuerySchema = z.object({- search: z- .string()- .optional()- .describe("The search term to filter the folders by."),- includeLinkCount: booleanQuerySchema- .optional()- .describe("Whether to include the link count in the response."),-});+export const FOLDERS_MAX_PAGE_SIZE = 50;-export const updateFolderSchema = createFolderSchema.partial();+export const listFoldersQuerySchema = z+ .object({+ search: z+ .string()+ .optional()+ .describe("The search term to filter the folders by."),++ includeLinkCount: booleanQuerySchema++ .optional()++ .describe("Whether to include the link count in the response."),+ })+ .merge(getPaginationQuerySchema({ pageSize: FOLDERS_MAX_PAGE_SIZE }));-export const FOLDERS_MAX_PAGE_SIZE = 50;+export const updateFolderSchema = createFolderSchema.partial();