Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/hooks/useOrgProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ export const useOrgProjects = (
async (requestUrl: string) => {
const data = await fetcher<Paged<ProjectDTO>>(requestUrl);
// the list endpoint returns plain projects; the nested tree is fetched
// lazily, so drop it here rather than pretend it is the frontend shape
// lazily, so drop it here rather than pretend it is the frontend shape.
// when searching, the endpoint already returns the tree, so keep it.
return {
...data,
data: data.data.map(({ subGroupsAndAsset: _nested, ...item }) => ({
...item,
resourceType: "project" as const,
})),
data: data.data.map(
({ subGroupsAndAsset, ...item }) =>
({
...item,
resourceType: "project" as const,
...(isSearchActive ? { subGroupsAndAsset } : {}),
}) as SubGroupsAndAsset,
),
} satisfies Paged<SubGroupsAndAsset>;
},
{ keepPreviousData: true },
Expand Down
Loading