Adicionar web/upgrade.js
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
async function loadPlans() {
|
||||
const r = await fetch("/admin/plans");
|
||||
const plans = await r.json();
|
||||
document.getElementById("plan-list").innerHTML =
|
||||
plans.map(p => `
|
||||
<div class="plan">
|
||||
<h3>${p.name}</h3>
|
||||
<p>R$ ${p.price_monthly}/mês</p>
|
||||
<button onclick="subscribe('${p.id}')">Assinar</button>
|
||||
</div>
|
||||
`).join("");
|
||||
}
|
||||
|
||||
async function subscribe(planId) {
|
||||
await fetch("/api/subscribe", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({plan_id: planId})
|
||||
});
|
||||
alert("Assinatura criada com sucesso");
|
||||
}
|
||||
Reference in New Issue
Block a user