This commit is contained in:
Your Name
2026-04-11 09:31:36 -03:00
parent 8af11561d0
commit 8f68959256
+7 -11
View File
@@ -375,18 +375,11 @@
.addEventListener("click", () => buyProduct("powerhouse")); .addEventListener("click", () => buyProduct("powerhouse"));
// ── Apply current-plan state ────────────────────────────────────────────── // ── Apply current-plan state ──────────────────────────────────────────────
function addOneYear(dateStr) {
if (!dateStr) return dateStr;
var d = new Date(dateStr);
d.setFullYear(d.getFullYear() + 1);
return d.toISOString().slice(0, 10);
}
function applyPlanState(contractName, expires) { function applyPlanState(contractName, expires) {
const currentIdx = PLAN_ORDER.indexOf(contractName); const currentIdx = PLAN_ORDER.indexOf(contractName);
if (currentIdx === -1) return; // unknown plan leave defaults if (currentIdx === -1) return; // unknown plan leave defaults
const badgeLabel = expires ? "✅ " + addOneYear(expires) : "✅"; const badgeLabel = expires ? "✅ " + expires : "✅";
PLAN_ORDER.forEach(function (plan, idx) { PLAN_ORDER.forEach(function (plan, idx) {
var meta = PLAN_META[plan]; var meta = PLAN_META[plan];
@@ -396,15 +389,18 @@
if (!btn || !card) return; if (!btn || !card) return;
if (idx === currentIdx) { if (idx === currentIdx) {
// Current plan green frame, badge with +1yr date, "Currently" button // Current plan green frame, badge with expiry date, "Add 1 Year" button
card.classList.add("current"); card.classList.add("current");
var badge = document.createElement("div"); var badge = document.createElement("div");
badge.className = "plan-badge"; badge.className = "plan-badge";
badge.textContent = badgeLabel; badge.textContent = badgeLabel;
card.insertBefore(badge, card.firstChild); card.insertBefore(badge, card.firstChild);
btn.textContent = "Currently"; btn.textContent = "Add 1 Year";
btn.disabled = true; btn.disabled = false;
btn.classList.add("is-current-plan"); btn.classList.add("is-current-plan");
btn.addEventListener("click", function () {
buyProduct("extend-" + meta.productId);
});
} else if (idx < currentIdx) { } else if (idx < currentIdx) {
// Lower tier hide entirely // Lower tier hide entirely
card.style.display = "none"; card.style.display = "none";