Repository navigation
Ezra/321 request fulfillment and history dashboard - #342
Conversation
✅ Deploy Preview for hope-for-haiti ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Greptile SummaryThis PR adds an admin-side Requests dashboard with "Current" and "Past" tabs, backed by a new service that classifies
Confidence Score: 4/5
Important Files Changed
|
| const requests = await db.generalItemRequest.findMany({ | ||
| where, | ||
| include: requestInclude, | ||
| }); |
There was a problem hiding this comment.
All records fetched for in-memory pagination
Both getCurrentRequests and getPastRequests issue an unbounded findMany — no take/skip — load every GeneralItemRequest row into memory, classify them, group them, and then slice. getPastRequests is the worst case because it also lacks a DB-level date filter; the entire request history is loaded just to compute which page of groups to return. As the dataset grows this will cause timeouts and OOM pressure.
The root issue is that classification requires joined data (line items, allocations, sign-offs) that can't be pushed into a single Prisma where. A pragmatic middle ground: apply a coarse DB-level filter (e.g. donorOffer.state for the past-requests path) to reduce the result set before the in-memory classification step.
| } from "@/types/api/adminRequests.types"; | ||
|
|
||
| export default function CurrentRequestsTable() { | ||
| const { apiClient } = useApiClient(); |
There was a problem hiding this comment.
tableRef is created but never used within the component
tableRef is passed to AdvancedBaseTable via ref={tableRef}, but CurrentRequestsTable is not a forwardRef component and never calls tableRef.current itself. The ref handle is therefore inaccessible to any parent. The same applies to PastRequestsTable. Either expose the ref with forwardRef/useImperativeHandle if a parent needs programmatic control, or remove the useRef and ref prop entirely to avoid dead code.
|
Ignore greptile, implementation is sufficient. UI and table layout is clean, nice work. |
Description
Resolves ticket number: #321
Explain what your code changes:
Added an admin side Requests dashboard with Current and Past tabs
Backend:
services/adminRequestsService.ts - classifies request at Current or Past, groups by date + partner
app/api/adminRequests/route.ts - receives GET requests from the frontend, checks staff permissions, and asks the service for current or past data
types/api/adminRequests.types.ts - defines the shape of the data the API sends back to the frontend tables
Frontend:
app/adminRequests/page.tsx - auth gatekeeper page
screens/AdminRequestsScreen.tsx - main page with Current / Past tab switcher
components/CurrentRequestsTable.tsx - page for the tab with Current tab switchers
component/PastRequestsTable.tsx - page for tab with past tab switchers
components/NavBarLayout.tsx - new sidebar link added
List the steps you took to test your code:
Checklist