update faces of clean air page#3782
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughRestructures the API proxy route's request handling order and narrows body-forwarding to POST/PUT, adds a selfie-by-id route and normalized submission id typing to the Faces of Clean Air service, updates the page's data typing/keys accordingly, restyles the page from blue to teal, and removes unused glare effects. README badges also updated. ChangesAPI proxy and README badge
Estimated code review effort: 2 (Simple) | ~12 minutes Faces of Clean Air id normalization and teal restyle
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## staging #3782 +/- ##
============================================
+ Coverage 53.30% 64.74% +11.43%
============================================
Files 112 158 +46
Lines 4523 7930 +3407
Branches 1476 1923 +447
============================================
+ Hits 2411 5134 +2723
- Misses 2112 2734 +622
- Partials 0 62 +62 🚀 New features to boost your workflow:
|
|
New azure website changes available for preview here |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@src/website/src/features/faces-of-clean-air/FacesOfCleanAirPage.tsx`:
- Around line 760-804: The delete/hide handlers in FacesOfCleanAirPage currently
only react to thrown errors, but deleteSubmission and hideSubmission can fail by
returning false, so the user gets no feedback and the modal closes as if
success. Update handleConfirmDelete and handleConfirmHide to check the success
result explicitly, and surface a visible failure state (toast, inline message,
or similar) when the service returns false or throws, instead of silently
resetting state in the finally block. Use the existing handleConfirmDelete,
handleConfirmHide, and facesOfCleanAirService.deleteSubmission/hideSubmission
symbols to place the fix.
- Around line 1304-1365: The moderation modal in FacesOfCleanAirPage is missing
accessible dialog behavior; update the deleteTarget overlay/panel motion.divs to
expose proper dialog semantics with role="dialog", aria-modal="true", and an
aria-labelledby tied to the title, add an Escape key handler to close it, and
ensure focus is moved into the modal when it opens and trapped there until
handleCancelDelete runs.
In `@src/website/src/services/api/api-client.ts`:
- Around line 141-144: The client-side auth token handling in api-client.ts is
using a token query parameter that the Next.js proxy strips before the backend
sees it. Update the request path in the api-client logic to pass authToken
through a header or otherwise use an explicitly allow-listed parameter, and make
sure the token injection point in the client request builder is aligned with the
proxy behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 51204733-2394-4811-ab1c-5c505644457b
📒 Files selected for processing (7)
src/website/README.mdsrc/website/src/app/api/v2/[...slug]/route.tssrc/website/src/features/faces-of-clean-air/FacesOfCleanAirPage.tsxsrc/website/src/services/api/api-client.tssrc/website/src/services/api/api-error.tssrc/website/src/services/api/api-routes.tssrc/website/src/services/external/faces-of-clean-air.service.ts
| // Add auth token for client-side authenticated requests | ||
| if (!isServerSide && authToken) { | ||
| searchParams.set('token', authToken); | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the API client and proxy route around the referenced lines.
git ls-files 'src/website/src/services/api/api-client.ts' 'src/website/src/app/api/v2/[...slug]/route.ts'
echo
echo '--- api-client.ts (relevant slice) ---'
sed -n '120,170p' src/website/src/services/api/api-client.ts
echo
echo '--- route.ts (relevant slice) ---'
sed -n '1,220p' src/website/src/app/api/v2/[...slug]/route.tsRepository: airqo-platform/AirQo-frontend
Length of output: 7452
Client-side authToken is dropped by the proxy
The Next.js proxy strips any incoming token query param and replaces it with API_TOKEN, so the value set here never reaches the backend. If per-user auth is intended, forward it in a header or explicitly allow-list this param.
🤖 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/website/src/services/api/api-client.ts` around lines 141 - 144, The
client-side auth token handling in api-client.ts is using a token query
parameter that the Next.js proxy strips before the backend sees it. Update the
request path in the api-client logic to pass authToken through a header or
otherwise use an explicitly allow-listed parameter, and make sure the token
injection point in the client request builder is aligned with the proxy
behavior.
… FacesOfCleanAirPage
There was a problem hiding this comment.
Pull request overview
Updates the “Faces of Clean Air” website page to support moderation actions (hide/delete submissions), improves robustness of submission identifiers, and refreshes the page’s visual theme.
Changes:
- Normalizes selfie submission IDs to handle both
idand_id, and adds service methods to hide/delete submissions. - Extends the Next.js
/api/v2/*proxy to supportPATCHrequests. - Refreshes the Faces of Clean Air page UI styling/layout and updates website README badges.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/website/src/services/external/faces-of-clean-air.service.ts | Normalizes submission identifiers and adds hide/delete service calls. |
| src/website/src/services/api/api-routes.ts | Adds a SELFIE_BY_ID route helper for moderation actions. |
| src/website/src/features/faces-of-clean-air/FacesOfCleanAirPage.tsx | Updates page styling and introduces moderation UI + client-side handlers. |
| src/website/src/app/api/v2/[...slug]/route.ts | Adds PATCH method support to the API proxy route. |
| src/website/README.md | Updates badges/links for CI, Codecov, Node.js, and TypeScript. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export interface CleanAirSubmission { | ||
| id: string; | ||
| _id: string; | ||
| eventId: string; |
| if (response.success && response.data) { | ||
| return response.data.selfies ?? []; | ||
| const selfies = response.data.selfies ?? []; | ||
| return selfies.map((s) => ({ ...s, id: s.id || s._id })); | ||
| } |
| onPointerMove={handlePointerMove} | ||
| onPointerLeave={resetPointerPosition} | ||
| onDoubleClick={() => onDeleteRequest?.(submission)} | ||
| style={{ |
| isMobile ? page === 0 : page === 0 && index < 3 | ||
| } | ||
| reduceMotion={shouldReduceMotion} | ||
| onDeleteRequest={handleDeleteRequest} | ||
| /> |
| export async function PATCH( | ||
| request: NextRequest, | ||
| { params }: { params: { slug: string[] } }, | ||
| ) { | ||
| return handleRequest(request, params.slug, 'PATCH'); | ||
| } |
… remove delete/hide submission logic
|
New azure website changes available for preview here |
Summary of Changes (What does this PR do?)
Status of maturity (all need to be checked before merging):
Screenshots (optional)
Summary by CodeRabbit
New Features
Bug Fixes
Style
Documentation