-
Notifications
You must be signed in to change notification settings - Fork 69
Add badge awarding logic — currently badges can only be assigned via seed #191
Copy link
Copy link
Open
Copy link
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave programapibadgesfeaturegamification
Description
Description
The UserBadge join table, Badge model, and AchievementsDialog component exist and render correctly. However, there is no server-side logic to award badges based on user activity. The only way a user can have badges is if they are manually seeded. The context AWARD_BADGE action updates memory only.
More info
- Create a
checkAndAwardBadges(userId: string)server-side function that evaluates eligibility rules and createsUserBadgerecords. - This function should be called from API endpoints after relevant actions (post created, entry won, etc.).
- Example rules:
- "First Giveaway" badge: awarded when a user creates their first giveaway.
- "Generous Heart" badge: awarded after contributing to 10 help requests.
- "Community Builder" badge: awarded when the user reaches 100 followers.
- The
/api/auth/meendpoint (and/api/users/[id]) already return badges withawardedAt, so the UI will reflect new badges automatically once the awarding logic exists. - Remove the in-memory
checkAndAwardBadgescall fromapp-context.tsxonce the server-side version is in place.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave programapibadgesfeaturegamification