fix
This commit is contained in:
+7
-11
@@ -375,18 +375,11 @@
|
||||
.addEventListener("click", () => buyProduct("powerhouse"));
|
||||
|
||||
// ── 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) {
|
||||
const currentIdx = PLAN_ORDER.indexOf(contractName);
|
||||
if (currentIdx === -1) return; // unknown plan – leave defaults
|
||||
|
||||
const badgeLabel = expires ? "✅ " + addOneYear(expires) : "✅";
|
||||
const badgeLabel = expires ? "✅ " + expires : "✅";
|
||||
|
||||
PLAN_ORDER.forEach(function (plan, idx) {
|
||||
var meta = PLAN_META[plan];
|
||||
@@ -396,15 +389,18 @@
|
||||
if (!btn || !card) return;
|
||||
|
||||
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");
|
||||
var badge = document.createElement("div");
|
||||
badge.className = "plan-badge";
|
||||
badge.textContent = badgeLabel;
|
||||
card.insertBefore(badge, card.firstChild);
|
||||
btn.textContent = "Currently";
|
||||
btn.disabled = true;
|
||||
btn.textContent = "Add 1 Year";
|
||||
btn.disabled = false;
|
||||
btn.classList.add("is-current-plan");
|
||||
btn.addEventListener("click", function () {
|
||||
buyProduct("extend-" + meta.productId);
|
||||
});
|
||||
} else if (idx < currentIdx) {
|
||||
// Lower tier – hide entirely
|
||||
card.style.display = "none";
|
||||
|
||||
Reference in New Issue
Block a user