Description
The GET /api/posts list query only includes user and _count: { entries, interactions, comments }. It never aggregates helpContributions.amount nor returns a currentAmount field, and lib/map-api-post.ts does not derive one. As a result post.currentAmount is undefined everywhere the feed renders it, so help-request cards show "$undefined / $0 raised" and 0% progress, and ContributionForm's "remaining" math is wrong. Only the dedicated per-post contributions endpoint computes totalRaised.
More info
- File:
app/app/api/posts/route.ts (GET include, approx. lines 271-286)
- File:
app/lib/map-api-post.ts
- File:
app/components/post-card.tsx (approx. lines 350-365), app/components/contribution-form.tsx
- Aggregate
helpContributions sums in the posts query (or via _sum) and map to currentAmount in mapApiPostToClientPost.
- Add a test asserting a request post with contributions reports the correct
currentAmount and progress percentage from the list endpoint.
Description
The
GET /api/postslist query only includesuserand_count: { entries, interactions, comments }. It never aggregateshelpContributions.amountnor returns acurrentAmountfield, andlib/map-api-post.tsdoes not derive one. As a resultpost.currentAmountisundefinedeverywhere the feed renders it, so help-request cards show "$undefined / $0 raised" and 0% progress, andContributionForm's "remaining" math is wrong. Only the dedicated per-post contributions endpoint computestotalRaised.More info
app/app/api/posts/route.ts(GET include, approx. lines 271-286)app/lib/map-api-post.tsapp/components/post-card.tsx(approx. lines 350-365),app/components/contribution-form.tsxhelpContributionssums in the posts query (or via_sum) and map tocurrentAmountinmapApiPostToClientPost.currentAmountand progress percentage from the list endpoint.