Files
dataroom/lib/swr/use-datarooms-simple.ts
zeekayandmarcftone cf0a984ee9 feat: show dataroom internal name in sidebar when present
- Updated API to include internalName in simple mode response
- Updated DataroomSimple type to include internalName
- Modified sidebar to display internalName instead of name when available

Co-authored-by: marcftone <[email protected]>
2026-01-19 09:29:24 +00:00

40 lines
1.0 KiB
TypeScript

import { useTeam } from "@/context/team-context";
import { Dataroom } from "@prisma/client";
import useSWR from "swr";
import { fetcher } from "@/lib/utils";
export type DataroomSimple = Pick<Dataroom, "id" | "name" | "internalName" | "createdAt">;
type DataroomsSimpleResponse = {
datarooms: DataroomSimple[];
};
/**
* A lightweight hook for fetching datarooms without filtering or extended data.
* Use this for simple use cases like dropdowns, sidebars, or modals that only need
* basic dataroom info (id, name, createdAt).
*
* For full features (search, tags, counts), use `useDatarooms` instead.
*/
export default function useDataroomsSimple() {
const teamInfo = useTeam();
const { data, error, mutate } = useSWR<DataroomsSimpleResponse>(
teamInfo?.currentTeam?.id &&
`/api/teams/${teamInfo?.currentTeam?.id}/datarooms?simple=true`,
fetcher,
{
revalidateOnFocus: false,
dedupingInterval: 30000,
},
);
return {
datarooms: data?.datarooms,
loading: !data && !error,
error,
mutate,
};
}