Computing for good
Atlanta Food Consortium/Feature Docs

Nonprofit Route

Product browsing and claiming dashboard. Requires an authenticated session with an associated nonprofit.

Overview

The Nonprofit route (/nonprofit) allows verified nonprofit organizations to browse available food products and submit claim requests. Access requires both an active session and a nonprofitId associated with the user's account.

Source directory: src/app/nonprofit/

Access control

CheckValue
RequiredAuthenticated session
Additional checkUser must have a nonprofitId
Redirect on failure/onboarding/nonprofit (if no nonprofitId) or / (if unauthenticated)

Tabs

TabDescription
Browse ProductsGrid of available product listings with claim button on each card
My ClaimsTable of the nonprofit's submitted and active claims
HistoryCompleted and expired claim records

Claiming a product

const { claim, unclaim, isClaiming } = useClaim(product.id);

<button onClick={claim} disabled={isClaiming}>
  Claim Product
</button>;

Unclaiming requires the requestId (the ID of the existing claim record):

const { unclaim } = useClaim(product.id);

<button onClick={() => unclaim(requestId)}>Unclaim</button>;

Data hooks

HookFileReturns
useNonprofitData()src/hooks/useNonprofitData.tsAvailable products and the nonprofit's own claims
useClaim(productId)src/hooks/useClaim.ts{ claim, unclaim, isClaiming }

API routes used

EndpointMethodPurpose
/api/products/availableGETFetch products available for claiming
/api/product-requestsPOSTSubmit a new claim
/api/product-requests/[id]DELETERemove an existing claim
/api/nonprofit/claimsGETFetch the nonprofit's claim history