completionId: cgen-7225407d65ee4c9786fdc789d96ca389
cgen-7225407d65ee4c9786fdc789d96ca389
This commit is contained in:
parent
08d3ea25f3
commit
70771dc21c
1 changed files with 14 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue