[eric] fix dead annual subscribe buttons: desktop was sending billing_interval="annual" but cloud zod enum only accepted

"monthly"|"yearly" so the POST returned 400 and the click silently no-opped — now map annual→yearly at the fetch boundary,
  UI/types/analytics stay on "annual"
This commit is contained in:
ciregenz
2026-04-21 16:48:05 -07:00
parent 11b07bde28
commit c8360cc921
5 changed files with 26 additions and 23 deletions
+4 -1
View File
@@ -26,10 +26,13 @@ export async function subscribeToPlan(
});
try {
// Cloud schema uses "yearly"; the desktop UI/analytics uses "annual".
// Normalize at the boundary so the rest of the client stays consistent.
const wireInterval = billingInterval === 'annual' ? 'yearly' : billingInterval;
const r = await fetch('https://api.openswarm.com/api/stripe/checkout', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ plan, billing_interval: billingInterval }),
body: JSON.stringify({ plan, billing_interval: wireInterval }),
});
if (!r.ok) {
console.error(`Checkout request failed: ${r.status}`);