Add Instagram points removal to the Instagram Points tool - #20
Add Instagram points removal to the Instagram Points tool#20vickrumsukhlani wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🟡 Changes recommended
The new UI copy hard-codes “1 point” even though the server revokes one award whose pointsPerAward can differ, which can mislead users.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a web-only “revoke” path to the Instagram Points tool so officers can undo a mistaken award without manual Firestore edits, while keeping the write shape compatible with the mobile app’s award-only callable.
Changes:
- Added
POST /api/instagram/revoketo remove the most recent Instagram award per UID (including guarded deletion of now-empty log docs). - Extended the shared batch helper to support deletes within the same batched write flow.
- Added client hook + UI “Remove” action (confirm dialog) and expanded emulator-backed route tests; updated docs accordingly.
File summaries
| File | Description |
|---|---|
| server/routes/instagram.ts | Implements /revoke endpoint and shared canonical event selection. |
| server/lib/db-helpers.ts | Extends BatchWriteOp + chunkedAtomicBatch to support delete operations. |
| scripts/test-instagram-route.ts | Adds emulator tests covering revoke behavior and edge cases. |
| lib/hooks/useInstagramPoints.ts | Adds useRevokeInstagramPoints mutation hook + result type. |
| docs/PURPOSE_AND_FUNCTIONALITY.md | Documents the per-row Remove action and its “one award at a time” semantics. |
| docs/API.md | Documents POST /revoke contract, behavior, and response shape. |
| app/(main)/tools/instagram-points/page.tsx | Adds Remove button, confirm dialog, and revoke mutation handling in the table UI. |
Review details
Suppressed comments (3)
app/(main)/tools/instagram-points/page.tsx:264
- Confirm dialog description says the action "takes away 1 point", but the server revokes one award whose point value is
pointsPerAward(eventsignInPoints) and could differ from 1. Rewording this copy to talk about removing one award avoids lying to the user.
? `Remove the most recent Instagram award from ${pendingRemoval.name}? ` +
`This takes away 1 point, leaving ${pendingRemoval.awardCount - 1} award${
pendingRemoval.awardCount - 1 === 1 ? "" : "s"
}.`
app/(main)/tools/instagram-points/page.tsx:258
- Dialog title says "Remove Instagram point", but the operation revokes one award (worth
pointsPerAwardpoints). Using "award" here keeps the UI correct even if the point value per award ever changes.
title="Remove Instagram point"
app/(main)/tools/instagram-points/page.tsx:267
- Confirm button label says "Remove point", but the operation revokes one award (worth
pointsPerAwardpoints). Using "award" avoids implying it's always exactly 1 point.
confirmLabel="Remove point"
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new Instagram Points UI copy/labels and one formatting issue in the removal flow are inconsistent with the revoke behavior and may cause lint/copy inaccuracies.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (3)
app/(main)/tools/instagram-points/page.tsx:258
- The confirm dialog title says "Remove Instagram point", but this action revokes the most recent award (and may remove more than 1 point if the hidden event's point value ever changes). Using "award" avoids implying a specific point amount.
title="Remove Instagram point"
app/(main)/tools/instagram-points/page.tsx:264
- The confirm dialog description hard-codes "takes away 1 point" even though the server revokes the event's
signInPointsper award; the UI copy should avoid stating a specific point amount and just describe removing one award.
? `Remove the most recent Instagram award from ${pendingRemoval.name}? ` +
`This takes away 1 point, leaving ${pendingRemoval.awardCount - 1} award${
pendingRemoval.awardCount - 1 === 1 ? "" : "s"
}.`
app/(main)/tools/instagram-points/page.tsx:267
- The confirm button label says "Remove point", but this action removes one Instagram award. Using "award" better matches the server behavior and avoids implying a specific point value.
confirmLabel="Remove point"
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Instagram points were award-only — a point given to the wrong member could
only be fixed by hand-editing both log docs in the Firebase console.
Adds POST /api/instagram/revoke (the mirror of /award) and a per-row Remove
button behind a confirm dialog. Removes one award at a time, not the whole
history, so weekly awards stay individually correctable.
Verified against the emulators: scripts/test-instagram-route.ts 28/28