mirror of
https://github.com/hanzo-apps/dataroom.git
synced 2026-10-30 14:47:36 +00:00
- 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]>
40 lines
1.0 KiB
TypeScript
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,
|
|
};
|
|
}
|