completionId: cgen-7225407d65ee4c9786fdc789d96ca389

cgen-7225407d65ee4c9786fdc789d96ca389
This commit is contained in:
Builder.io 2025-11-10 23:55:41 +00:00
parent 08d3ea25f3
commit 70771dc21c

View file

@ -910,6 +910,7 @@ export const aethexAchievementService = {
const newTotalXP = (currentProfile.total_xp || 0) + xpDelta;
const newLevel = Math.floor(newTotalXP / 1000) + 1;
const newLoyaltyPoints = (currentProfile.loyalty_points || 0) + xpDelta;
const oldLevel = currentProfile.level || 1;
const updates: Record<string, number> = {};
if ("total_xp" in currentProfile) updates.total_xp = newTotalXP;
@ -924,6 +925,19 @@ export const aethexAchievementService = {
.eq("id", userId);
if (updateError) throw updateError;
if (newLevel > oldLevel) {
try {
await aethexNotificationService.createNotification(
userId,
"success",
`⬆️ Level Up!`,
`You've reached level ${newLevel}! Keep it up!`,
);
} catch (notifError) {
console.warn("Failed to create level up notification:", notifError);
}
}
}
},