mirror of
https://github.com/hanzoai/dataroom.git
synced 2026-10-30 18:41:07 +00:00
26 lines
572 B
TypeScript
26 lines
572 B
TypeScript
import { useTeam } from "@/context/team-context";
|
|
import { Invitation } from "@prisma/client";
|
|
import useSWR from "swr";
|
|
|
|
import { fetcher } from "@/lib/utils";
|
|
|
|
export function useInvitations() {
|
|
const teamInfo = useTeam();
|
|
|
|
// only fetch data once when linkId is present
|
|
const { data: invitations, error } = useSWR<Invitation[]>(
|
|
teamInfo?.currentTeam &&
|
|
`/api/teams/${teamInfo.currentTeam.id}/invitations`,
|
|
fetcher,
|
|
{
|
|
dedupingInterval: 10000,
|
|
},
|
|
);
|
|
|
|
return {
|
|
invitations,
|
|
loading: !error && !invitations,
|
|
error,
|
|
};
|
|
}
|