diff --git a/packages/grant-explorer/src/features/projects/ViewProject.tsx b/packages/grant-explorer/src/features/projects/ViewProject.tsx index 33695ad1b..b6068398e 100644 --- a/packages/grant-explorer/src/features/projects/ViewProject.tsx +++ b/packages/grant-explorer/src/features/projects/ViewProject.tsx @@ -18,6 +18,7 @@ import { Box, Skeleton, SkeletonText, Tab, Tabs } from "@chakra-ui/react"; import { useDataLayer, v2Project } from "data-layer"; import { DefaultLayout } from "../common/DefaultLayout"; import { useProject } from "./hooks/useProject"; +import NotFoundPage from "../common/NotFoundPage"; const CalendarIcon = (props: React.SVGProps) => { return ( @@ -46,7 +47,7 @@ export default function ViewProject() { const dataLayer = useDataLayer(); - const { data, error } = useProject( + const { data, error, isLoading } = useProject( { projectId: projectId, }, @@ -102,51 +103,55 @@ export default function ViewProject() { return ( <> - -
-
- + {data !== undefined || isLoading ? ( + +
+
+ +
-
-
- -
-
-
- +
+ +
+
+
+ +
-
-
-
- {error === undefined ? ( - <> - -

- {title} -

-
- - tab.name)} - /> -
- {projectDetailsTabs[selectedTab].content} -
- - ) : ( -

Couldn't load project data.

- )} +
+
+ {error === undefined ? ( + <> + +

+ {title} +

+
+ + tab.name)} + /> +
+ {projectDetailsTabs[selectedTab].content} +
+ + ) : ( +

Couldn't load project data.

+ )} +
-
- + + ) : ( + + )} ); } diff --git a/packages/grant-explorer/src/features/projects/hooks/useProject.ts b/packages/grant-explorer/src/features/projects/hooks/useProject.ts index 3db0f8a35..b93d8116a 100644 --- a/packages/grant-explorer/src/features/projects/hooks/useProject.ts +++ b/packages/grant-explorer/src/features/projects/hooks/useProject.ts @@ -3,14 +3,13 @@ import { DataLayer } from "data-layer"; import { AlloVersion } from "data-layer/src/data-layer.types"; type Params = { - projectId?: string; + projectId: string; }; export function useProject(params: Params, dataLayer: DataLayer) { - const shouldFetch = Object.values(params).every(Boolean); - return useSWR(shouldFetch ? ["applications", params] : null, async () => { + return useSWR(["projects", params], async () => { const validatedParams = { - projectId: params.projectId as string, + projectId: params.projectId, alloVersion: "allo-v2" as AlloVersion, }; return (await dataLayer.getProjectById(validatedParams)) ?? undefined;