Repository navigation
feat: add badge system - #209
Open
TheSKBroook wants to merge 33 commits into
Open
TheSKBroook wants to merge 33 commits into
TheSKBroook wants to merge 33 commits into
Conversation
…not contain this for now
…into feature/badge-profile-frontend
… but not event with badge.
…ath, in case when image is stored but badge is not created.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
rebeccafitzpatr
approved these changes
Oct 23, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Badge system: event badges, admin management, and badges on profiles
Summary
Adds badges to the site. Admins can attach an optional badge to an event when creating or editing it. The event, badge and images are saved together or not at all. Members' badges show on their profile and public profile.
Database
Tables used:
badges,member_badgesMigrations
Long story short,
-> I first think that deleting an event should NOT delete the badge associated with it,
-> then I think it should, so I change it to the opposite ( delete event also delete the badge )
Click here to see the migration detail
(in
supabase/migrations/; each one runs once in the Supabase SQL Editor):20261001120000_badge_event_links_and_save_function.sqlmember_badges.badgeid→ON DELETE CASCADE(deleting a badge deletes all awards of it)UNIQUE (badgeid, memberid)(a member can't hold the same badge twice)save_event_with_badgedatabase function20261007120000_delete_event_badge_with_event.sqlbadges.eventid→ON DELETE CASCADE(deleting an event deletes its badge)p_remove_badge)Existing rules:
badges.eventidis unique (at most one badge per event);member_badges.memberid→registrations.id.Storage: the
badgesbucket is public, and images are stored asbadge_image/<uuid>.<ext>.Security: only the server (service role) can call
save_event_with_badge. The public anon key is blocked.What admins can do (Admin → Events)
Create
Update
Delete
What members see
/profileand on their public profile/profile/[id]: round images, with name, category, description, criteria and award date on hoverAPI
PUT /api/admin/events: now multipart (payloadJSON +event_image+badge_image). Creates or updates the event and its badge in one transaction. The old JSON body still works for event-only savesDELETE /api/admin/events: deletes the event, its badge, the awards and both image files. Returns 404 for an unknown idPOST /api/admin/events/image(images now go with the save)POST /api/admin/badgesandPOST /api/admin/badges/image: create a standalone badge and upload a badge image (not used by the UI yet)Services
BadgesService: CRUD,uploadBadgeImage,getBadgeImagePath(only our own public links),deleteBadgeImageMemberBadgesService: award (idempotent), check, list (with badge details), revokeEventService:saveEventWithBadge,deleteEvent, and the image helpers take the server clientTesting
Automated
badges-service.test.ts: 36 passing (CRUD, image upload, path parsing, image delete)Manual (to do before merging)
category = EVENT), and both files are in Storage/profileand/profile/[id]Not in this PR / follow-ups
POST /api/admin/badgesis ready for it)