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.

623 B
Raw Blame
import { fetcher } from "@dub/utils";
import { FolderAccessRequest } from "@prisma/client";
import useSWR from "swr";
import useWorkspace from "./use-workspace";

export function useFolderAccessRequests() {
  const { id, plan } = useWorkspace();

  const { data, error, isLoading, isValidating, mutate } = useSWR<
    FolderAccessRequest[]
  >(
    id && plan !== "free" && plan !== "pro"
      ? `/api/folders/access-requests?workspaceId=${id}`
      : null,
    fetcher,
    {
      dedupingInterval: 60000,
    },
  );

  return {
    accessRequests: data,
    error,
    isLoading,
    isValidating,
    mutate,
  };
}