From d585b511fa58f71abf55aed0904af8f3e92b60d0 Mon Sep 17 00:00:00 2001 From: eagle Date: Fri, 7 Jun 2024 18:31:58 +0530 Subject: [PATCH] feat: add useApplications --- .../src/features/projects/hooks/useProject.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/grant-explorer/src/features/projects/hooks/useProject.ts b/packages/grant-explorer/src/features/projects/hooks/useProject.ts index 4040b38ca..8a64f0531 100644 --- a/packages/grant-explorer/src/features/projects/hooks/useProject.ts +++ b/packages/grant-explorer/src/features/projects/hooks/useProject.ts @@ -14,3 +14,14 @@ export function useProject(params: Params, dataLayer: DataLayer) { return (await dataLayer.getProjectById(validatedParams)) ?? undefined; }); } + +export function useApplications(params: Params, dataLayer: DataLayer) { + return useSWR(["applications", params], async () => { + const validatedParams = { + projectId: params.projectId, + }; + return ( + (await dataLayer.getApplicationsByProjectId(validatedParams)) ?? undefined + ); + }); +}