Close Nigeria grants to new applications#1430
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR adds grant ChangesGrant Status Closure
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/features/grants/utils/validateGrantRequest.ts (1)
7-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider declaring an explicit return type.
validateGrantRequest's signature was modified in this change (newskipStatusCheckoption) but the function still relies on inferred return type ({ grant, user }). As per coding guidelines,**/*.ts: "Declare return types for top-level module functions in TypeScript (exception: React components returning JSX)".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/features/grants/utils/validateGrantRequest.ts` around lines 7 - 11, `validateGrantRequest` is a top-level TypeScript function and should not rely on an inferred `{ grant, user }` return type. Add an explicit return type to the `validateGrantRequest` signature, using the same `grant` and `user` shape currently returned, and keep the new `skipStatusCheck` option unchanged.Source: Coding guidelines
src/features/grants/components/GrantEntry.tsx (1)
42-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFail-closed on missing
status, and duplicated closure logic.Two issues:
status?: stringmeans an omitted prop silently resolvesisClosedtotrue(sinceundefined !== 'OPEN'). As per coding guidelines,**/*.{ts,tsx}: "Useproperty: Type | undefinedinstead ofproperty?: Type... to force explicit property passing and prevent bugs from accidentally omitting required properties." Making the fieldstatus: string | undefined(still optional at the value level, but requiring callers to explicitly pass it) would surface any caller that forgets to wire it up, rather than silently mislabeling an open grant as "Closed".- The
status !== 'OPEN'check duplicates the same logic inApplicationActionButton.tsx(Line 44:isClosedForNewApplications). If more grant statuses are introduced later, these two independent checks could drift. Consider extracting a shared helper (e.g.isGrantClosed(status)) into a common grants util.♻️ Example shared helper
// src/features/grants/utils/grantStatus.ts export function isGrantClosed(status: string | undefined): boolean { return status !== 'OPEN'; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/features/grants/components/GrantEntry.tsx` around lines 42 - 53, In GrantEntry, make the status prop explicit as string | undefined instead of optional so callers must pass it, and update the isClosed logic to use a shared grants helper rather than duplicating the check. Add or reuse a common utility such as isGrantClosed(status) and call it from both GrantEntry and ApplicationActionButton so the closure rule stays consistent. Keep the behavior fail-closed for undefined status, but ensure missing wiring is surfaced by the type signature.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/features/grants/components/GrantEntry.tsx`:
- Around line 42-53: In GrantEntry, make the status prop explicit as string |
undefined instead of optional so callers must pass it, and update the isClosed
logic to use a shared grants helper rather than duplicating the check. Add or
reuse a common utility such as isGrantClosed(status) and call it from both
GrantEntry and ApplicationActionButton so the closure rule stays consistent.
Keep the behavior fail-closed for undefined status, but ensure missing wiring is
surfaced by the type signature.
In `@src/features/grants/utils/validateGrantRequest.ts`:
- Around line 7-11: `validateGrantRequest` is a top-level TypeScript function
and should not rely on an inferred `{ grant, user }` return type. Add an
explicit return type to the `validateGrantRequest` signature, using the same
`grant` and `user` shape currently returned, and keep the new `skipStatusCheck`
option unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c6aafb70-f664-4eec-a749-792bac34aaf7
📒 Files selected for processing (7)
src/app/api/grant-application/update/route.tssrc/features/grants/components/ApplicationActionButton.tsxsrc/features/grants/components/GrantEntry.tsxsrc/features/grants/constants/schema.tssrc/features/grants/hooks/useApplicationState.tssrc/features/grants/utils/validateGrantRequest.tssrc/pages/earn/grants/index.tsx
Problem
We need to stop accepting new applications for the Nigeria grants:
touching-grass-nigeriasolana-foundation-nigeria-grantsChanging the DB rows to
CLOSEDalready makes the grant header look closed, but it did not fully close the application flow. A user could still see application-oriented CTAs in some places, and direct API submissions were not guarded by grant status.Solution
This makes
Grant.status = CLOSEDmean "not accepting new applications" across the grant application path:Closedand disables only the new-application state.Closedinstead ofApply Nowfor closed grants.The code is intentionally not hardcoded to Nigeria. The rollout stays scoped to Nigeria by updating only those two grant rows to
CLOSEDin the DB.Why this approach
Hardcoding Nigeria slugs would solve today's request, but it would make future grant closures require code changes. Since the product already has
OPEN | CLOSEDgrant status and the header already treats non-open grants as closed, using that status as the source of truth is the simpler and more maintainable path.DB follow-up
After this is deployed, close only the two Nigeria grants:
Checks
pnpm lintpassedgit diff --checkpassedpnpm check-typeswas run and still fails on existing generated/schema mismatches unrelated to this changeSummary by CodeRabbit
New Features
Bug Fixes