Skip to content

Commit

Permalink
Add function to fetch all active grants
Browse files Browse the repository at this point in the history
  • Loading branch information
Pabl0cks committed Feb 26, 2024
1 parent cafca3a commit ce92082
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/nextjs/services/database/grants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ export const getAllCompletedGrants = async () => {
}
};

export const getAllActiveGrants = async () => {
try {
const grantsSnapshot = await grantsCollection.where("status", "==", PROPOSAL_STATUS.APPROVED).get();
const grants: GrantData[] = [];
grantsSnapshot.forEach(doc => {
grants.push({ id: doc.id, ...doc.data() } as GrantData);
});
return grants;
} catch (error) {
console.error("Error getting all active grants:", error);
throw error;
}
};

export const reviewGrant = async (grantId: string, action: ProposalStatusType) => {
try {
await grantsCollection.doc(grantId).update({ status: action });
Expand Down

0 comments on commit ce92082

Please sign in to comment.