completionId: cgen-159cec7030a340cb9cea8b144d369ce4

cgen-159cec7030a340cb9cea8b144d369ce4
This commit is contained in:
Builder.io 2025-11-16 08:34:08 +00:00
parent 0a9e6167e1
commit 5f5521eb3a

View file

@ -1031,11 +1031,23 @@ export const aethexAchievementService = {
username?: string; username?: string;
}): Promise<ActivateRewardsResponse | null> { }): Promise<ActivateRewardsResponse | null> {
try { try {
// Skip if API_BASE is not configured (development edge case)
if (!API_BASE) {
console.warn(
"[Rewards] Skipping activation - API_BASE not configured",
);
return null;
}
const payload = { const payload = {
targetEmail: target?.email, targetEmail: target?.email,
targetUsername: target?.username, targetUsername: target?.username,
}; };
const response = await fetch(`${API_BASE}/api/achievements/activate`, {
const url = `${API_BASE}/api/achievements/activate`;
console.log("[Rewards] Activating at:", url);
const response = await fetch(url, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload), body: JSON.stringify(payload),
@ -1043,11 +1055,19 @@ export const aethexAchievementService = {
if (!response.ok) { if (!response.ok) {
const errorText = await response.text(); const errorText = await response.text();
throw new Error(errorText || "Failed to activate community rewards"); console.warn(
"[Rewards] Activation failed:",
response.status,
errorText,
);
return null;
} }
return (await response.json()) as ActivateRewardsResponse; const result = (await response.json()) as ActivateRewardsResponse;
} catch { console.log("[Rewards] Activation succeeded:", result);
return result;
} catch (error: any) {
console.warn("[Rewards] Activation error:", error?.message || error);
return null; return null;
} }
}, },