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 creates UserBadge records.
- 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/me endpoint (and /api/users/[id]) already return badges with awardedAt, so the UI will reflect new badges automatically once the awarding logic exists.
- Remove the in-memory
checkAndAwardBadges call from app-context.tsx once the server-side version is in place.
Description
The
UserBadgejoin table,Badgemodel, andAchievementsDialogcomponent 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 contextAWARD_BADGEaction updates memory only.More info
checkAndAwardBadges(userId: string)server-side function that evaluates eligibility rules and createsUserBadgerecords./api/auth/meendpoint (and/api/users/[id]) already return badges withawardedAt, so the UI will reflect new badges automatically once the awarding logic exists.checkAndAwardBadgescall fromapp-context.tsxonce the server-side version is in place.