route onboarding achievement award via server API
cgen-14c7ba865740498c83ef39749a97f40b
This commit is contained in:
parent
140f5132b7
commit
c322b37910
1 changed files with 22 additions and 15 deletions
|
|
@ -489,21 +489,28 @@ export const aethexAchievementService = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async checkAndAwardOnboardingAchievement(userId: string): Promise<void> {
|
async checkAndAwardOnboardingAchievement(userId: string): Promise<void> {
|
||||||
// Support either seeded name or legacy name
|
try {
|
||||||
const { data: achList, error } = await supabase
|
const resp = await fetch(`/api/achievements/award`, {
|
||||||
.from("achievements")
|
method: "POST",
|
||||||
.select("id, name")
|
headers: { "Content-Type": "application/json" },
|
||||||
.in("name", ["Welcome to AeThex", "AeThex Explorer"])
|
body: JSON.stringify({
|
||||||
.limit(1);
|
user_id: userId,
|
||||||
|
achievement_names: ["Welcome to AeThex", "AeThex Explorer"],
|
||||||
if (error) {
|
}),
|
||||||
console.warn("Onboarding achievement lookup failed:", error);
|
});
|
||||||
return;
|
if (!resp.ok) {
|
||||||
}
|
const text = await resp.text().catch(() => "");
|
||||||
|
console.warn("Award onboarding achievement failed:", text);
|
||||||
const achievement = Array.isArray(achList) ? achList[0] : null;
|
return;
|
||||||
if (achievement) {
|
}
|
||||||
await this.awardAchievement(userId, (achievement as any).id);
|
// Show celebratory toast
|
||||||
|
aethexToast.aethex({
|
||||||
|
title: "Achievement Unlocked! 🎉",
|
||||||
|
description: "Welcome to AeThex - Profile setup complete",
|
||||||
|
duration: 8000,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Award onboarding achievement exception:", e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue