Spaces:
Sleeping
Sleeping
Nathan commited on
Commit ·
32246b9
1
Parent(s): f6fe3a9
UI: Luxury Plans Page Upgrade and fixed Pro status detection
Browse files10 unmodified lines11121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031045 unmodified lines1101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062 unmodified lines20921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528610 unmodified lines<script src="https://checkout.razorpay.com/v1/checkout.js"></script><style>:root {--bg: #020617;--surface: #0f172a;--accent: #6366f1;--accent-light: #818cf8;--text: #f8fafc;--text-dim: #94a3b8;--glass: rgba(255, 255, 255, 0.03);--glass-border: rgba(255, 255, 255, 0.08);--success: #10b981;}body {background-color: var(--bg);color: var(--text);font-family: 'Plus Jakarta Sans', sans-serif;margin: 0;padding: 40px;display: flex;flex-direction: column;align-items: center;}.container { width: 100%; max-width: 900px; }header {display: flex;justify-content: space-between;align-items: center;margin-bottom: 60px;}.logo { font-family: 'Outfit', sans-serif; font-size: 1.8rem; font-weight: 900; background: linear-gradient(to right, #fff, var(--accent-light)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }.btn-back { color: var(--text-dim); text-decoration: none; display: flex; align-items: center; gap: 8px; font-weight: 600; }.status-panel {background: var(--glass);border: 1px solid var(--glass-border);padding: 30px;border-radius: 32px;margin-bottom: 40px;display: flex;justify-content: space-between;align-items: center;}.plans-grid {display: grid;grid-template-columns: 1fr 1fr;gap: 25px;}.plan-card {background: var(--surface);border: 1px solid var(--glass-border);padding: 40px;border-radius: 40px;position: relative;transition: all 0.3s ease;}.plan-card:hover { transform: translateY(-10px); border-color: var(--accent); }.plan-card.featured { border-color: var(--accent); background: linear-gradient(180deg, rgba(99,102,241,0.1) 0%, rgba(15,23,42,1) 100%); }.price { font-size: 3rem; font-weight: 900; margin: 20px 0; font-family: 'Outfit', sans-serif; }.old-price { text-decoration: line-through; color: var(--text-dim); font-size: 1.2rem; margin-right: 10px; }.features { list-style: none; padding: 0; margin: 30px 0; }.features li { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; font-size: 0.95rem; color: var(--text-dim); }.features li i { color: var(--success); width: 18px; }.btn-buy {width: 100%;padding: 16px;border-radius: 20px;border: none;background: var(--accent);color: white;font-weight: 800;font-size: 1rem;cursor: pointer;box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);}.tag { position: absolute; top: 20px; right: 20px; background: var(--accent); color: white; padding: 6px 12px; border-radius: 12px; font-size: 0.7rem; font-weight: 800; }@media (max-width: 700px) { .plans-grid { grid-template-columns: 1fr; } }</style></head><body>5 unmodified lines<div class="status-panel"><div><div style="font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; font-weight: 800;">Current Status</div><div id="current-plan" style="font-size: 1.5rem; font-weight: 900; margin-top: 5px;">Loading...</div></div><div style="text-align: right;"><div style="font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; font-weight: 800;">Access Expiry</div><div id="expiry-date" style="font-size: 1.1rem; font-weight: 700; margin-top: 5px; color: var(--accent-light);">Loading...</div></div></div><div class="plans-grid" style="grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));"><!-- FREE PLAN --><div class="plan-card"><div style="font-weight: 800; color: var(--text-dim);">FREE CREATOR</div><div class="price">₹0</div><div style="color: var(--text-dim); font-size: 0.8rem; margin-bottom: 20px;">The Perfect Start for New Creators</div><ul class="features"><li><i data-lucide="check-circle-2"></i> 1 Video per Day</li><li><i data-lucide="check-circle-2"></i> 100% Automated Workflow</li><li><i data-lucide="x-circle" style="color: var(--danger);"></i> Priority Support</li></ul><button class="btn-buy" style="background: var(--glass); cursor: default;">Current Plan</button></div><!-- PRO MONTHLY --><div class="plan-card featured"><div class="tag">POPULAR</div><div style="font-weight: 800; color: var(--accent-light);">PRO MONTHLY</div><div class="price"><span id="old-m" style="display: none;" class="old-price">₹299</span><span id="new-m">₹299</span></div><div id="m-text" style="color: var(--text-dim); font-size: 0.8rem; margin-bottom: 20px;">+30 Days of High-Speed Automation</div><ul class="features"><li><i data-lucide="check-circle-2"></i> 2 YouTube Channels</li><li><i data-lucide="check-circle-2"></i> 5 Videos per Day</li><li><i data-lucide="check-circle-2"></i> Auto-Scheduling Engine</li><li><i data-lucide="check-circle-2"></i> Priority AI Processing</li></ul><button class="btn-buy" onclick="buyPlan('pro_monthly')">Add 30 Days</button></div><!-- PRO YEARLY --><div class="plan-card featured" style="border-color: #10b981;"><div class="tag" style="background: #10b981;">BEST VALUE</div><div style="font-weight: 800; color: #10b981;">PRO YEARLY</div><div class="price"><span id="old-y" style="display: none;" class="old-price">₹2,999</span><span id="new-y">₹2,999</span></div><div id="y-text" style="color: var(--text-dim); font-size: 0.8rem; margin-bottom: 20px;">+365 Days of Global Dominance</div><ul class="features"><li><i data-lucide="check-circle-2"></i> 2 YouTube Channels</li><li><i data-lucide="check-circle-2"></i> 5 Videos per Day</li><li><i data-lucide="check-circle-2"></i> Priority 24/7 Support</li><li><i data-lucide="check-circle-2"></i> Beta Access to New AI Models</li></ul><button class="btn-buy" onclick="buyPlan('pro_yearly')" style="background: #10b981;">Add 365 Days</button></div><!-- ULTRA PLAN --><div id="ultra-card" class="plan-card" style="border-color: #f59e0b; background: linear-gradient(180deg, rgba(245, 158, 11, 0.1) 0%, rgba(15,23,42,1) 100%);"><div class="tag" style="background: #f59e0b;">GOD MODE</div><div style="font-weight: 800; color: #f59e0b;">ULTRA CREATOR</div><div class="price">👑</div><div style="color: var(--text-dim); font-size: 0.8rem; margin-bottom: 20px;">Unlimited Power. Zero Limits.</div><ul class="features"><li><i data-lucide="zap" style="color: #f59e0b;"></i> Unlimited Videos Daily</li><li><i data-lucide="zap" style="color: #f59e0b;"></i> 2 YouTube Channels</li><li><i data-lucide="zap" style="color: #f59e0b;"></i> Dedicated Server Core</li></ul><button class="btn-buy" style="background: #f59e0b; cursor: default;">Contact Admin</button></div></div></div><script>lucide.createIcons();const authToken = localStorage.getItem('saas_token');if (!authToken) window.location.href = 'index.html';async function init() {try {// 1. Load Pricing First (Cache-Busted)const pRes = await fetch(`/api/platform/pricing?t=${Date.now()}`);const p = await pRes.json();// FALLBACKS: Use defaults if DB is not initializedconst monthlyBase = p.pro_monthly || 299;const yearlyBase = p.pro_yearly || 2999;// Monthly Discountif (p.m_discount_active) {document.getElementById('old-m').innerText = `₹${monthlyBase}`;document.getElementById('old-m').style.display = 'inline';2 unmodified linesdocument.getElementById('old-m').style.display = 'none';document.getElementById('new-m').innerText = `₹${monthlyBase}`;}// Yearly Discountif (p.y_discount_active) {document.getElementById('old-y').innerText = `₹${yearlyBase}`;document.getElementById('old-y').style.display = 'inline';document.getElementById('new-y').innerText = `₹${Math.round(yearlyBase * (1 - p.discount_percent/100))}`;} else {document.getElementById('old-y').style.display = 'none';document.getElementById('new-y').innerText = `₹${yearlyBase}`;}// 2. Load User Statusconst res = await fetch('/api/auth/me', { headers: { 'Authorization': `Bearer ${authToken}` } });const user = await res.json();if (user.loggedIn) {let statusText = '🛡️ FREE CREATOR';if (user.role === 'admin' || user.plan === 'ultra') statusText = '☢️ GOD MODE';else if (user.plan === 'premium') statusText = '💎 PRO CREATOR';document.getElementById('current-plan').innerText = statusText;if (user.role === 'admin' || user.plan === 'ultra') {document.getElementById('expiry-date').innerText = '∞ Permanent Access';} else if (user.expires_at) {const date = new Date(user.expires_at).toLocaleDateString('en-IN', { day: 'numeric', month: 'long', year: 'numeric' });const daysLeft = Math.ceil((new Date(user.expires_at) - new Date()) / (1000 * 60 * 60 * 24));document.getElementById('expiry-date').innerText = `${date} (${daysLeft} Days Left)`;} else {document.getElementById('expiry-date').innerText = 'No Active Plan';}}} catch (e) {console.error("Initialization Failed:", e);document.getElementById('current-plan').innerText = "System Error";document.getElementById('expiry-date').innerText = "Please Refresh";}}async function buyPlan(plan) {const res = await fetch('/api/payments/create-order', {method: 'POST',headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },body: JSON.stringify({ plan })});const order = await res.json();const options = {"key": "rzp_live_SlfVPYNAQ7dyZ4","amount": order.amount,"currency": "INR","name": "ViralFlow AI","description": `Adding Time: ${plan}`,"order_id": order.id,"handler": async function (response) {response.plan_type = plan;const verify = await fetch('/api/payments/verify', {method: 'POST',headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },body: JSON.stringify(response)});if (verify.ok) {alert("Time Stacked Successfully! 🚀💎");location.reload();}},"theme": { "color": "#6366f1" }};const rzp1 = new Razorpay(options);rzp1.open();}init();</script></body></html>10 unmodified lines11121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411425 unmodified lines1481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242 unmodified lines22722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631710 unmodified lines<script src="https://checkout.razorpay.com/v1/checkout.js"></script><style>:root {--bg: #030712;--surface: #0f172a;--accent: #8b5cf6;--accent-light: #c084fc;--text: #f8fafc;--text-dim: #94a3b8;--glass: rgba(255, 255, 255, 0.03);--glass-border: rgba(255, 255, 255, 0.08);--success: #10b981;--danger: #ef4444;}body {background: radial-gradient(circle at top right, #1e1b4b, #030712);color: var(--text);font-family: 'Plus Jakarta Sans', sans-serif;margin: 0;padding: 20px;min-height: 100vh;}.container { width: 100%; max-width: 1000px; margin: 0 auto; padding-top: 40px; }header {display: flex;justify-content: space-between;align-items: center;margin-bottom: 40px;}.logo { font-family: 'Outfit', sans-serif; font-size: 1.8rem; font-weight: 900; color: #fff; letter-spacing: -1px; }.btn-back {color: var(--text-dim);text-decoration: none;display: flex;align-items: center;gap: 8px;font-weight: 600;background: var(--glass);padding: 10px 20px;border-radius: 14px;border: 1px solid var(--glass-border);font-size: 0.9rem;transition: 0.3s;}.btn-back:hover { background: rgba(255,255,255,0.1); color: #fff; }.status-panel {background: rgba(139, 92, 246, 0.05);border: 1px solid rgba(139, 92, 246, 0.15);padding: 30px;border-radius: 32px;margin-bottom: 40px;display: flex;justify-content: space-between;align-items: center;backdrop-filter: blur(20px);}.plans-grid {display: grid;grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));gap: 25px;margin-bottom: 60px;}.plan-card {background: rgba(15, 23, 42, 0.6);border: 1px solid var(--glass-border);padding: 40px;border-radius: 40px;position: relative;transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);backdrop-filter: blur(20px);display: flex;flex-direction: column;}.plan-card:hover { transform: translateY(-10px); border-color: var(--accent); box-shadow: 0 20px 40px rgba(0,0,0,0.4); }.plan-card.active-plan {border: 2px solid var(--accent);background: linear-gradient(180deg, rgba(139, 92, 246, 0.1) 0%, rgba(15, 23, 42, 0.8) 100%);box-shadow: 0 0 30px rgba(139, 92, 246, 0.1);}.price { font-size: 3.5rem; font-weight: 900; margin: 20px 0; font-family: 'Outfit', sans-serif; letter-spacing: -2px; }.old-price { text-decoration: line-through; color: var(--text-dim); font-size: 1.2rem; margin-right: 10px; opacity: 0.5; }.features { list-style: none; padding: 0; margin: 30px 0; flex: 1; }.features li { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; font-size: 0.95rem; color: var(--text-dim); }.features li i { color: var(--success); width: 18px; }.btn-buy {width: 100%;padding: 18px;border-radius: 22px;border: none;background: var(--accent);color: white;font-weight: 800;font-size: 1.1rem;cursor: pointer;transition: 0.3s;box-shadow: 0 10px 20px rgba(139, 92, 246, 0.3);}.btn-buy:hover { transform: scale(1.02); filter: brightness(1.1); }.btn-buy:disabled { background: var(--glass); color: var(--text-dim); cursor: default; box-shadow: none; }.tag { position: absolute; top: -15px; left: 40px; background: var(--accent); color: white; padding: 8px 16px; border-radius: 12px; font-size: 0.75rem; font-weight: 900; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }.current-label {position: absolute;top: 20px;right: 20px;background: var(--success);color: white;padding: 4px 10px;border-radius: 8px;font-size: 0.65rem;font-weight: 900;display: none;}@media (max-width: 700px) { body { padding: 15px; } .plans-grid { grid-template-columns: 1fr; } .status-panel { flex-direction: column; gap: 20px; text-align: center; } }</style></head><body>5 unmodified lines<div class="status-panel"><div><div style="font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; font-weight: 800; letter-spacing: 1px;">Current Tier</div><div id="current-plan" style="font-size: 1.8rem; font-weight: 900; margin-top: 5px; font-family: 'Outfit';">Loading...</div></div><div style="text-align: right;"><div style="font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; font-weight: 800; letter-spacing: 1px;">Access Validity</div><div id="expiry-date" style="font-size: 1.1rem; font-weight: 700; margin-top: 5px; color: var(--accent-light);">Loading...</div></div></div><div class="plans-grid"><!-- FREE PLAN --><div class="plan-card" id="card-free"><div class="current-label">ACTIVE</div><div style="font-weight: 800; color: var(--text-dim); font-size: 0.8rem; letter-spacing: 1px;">CREATOR START</div><div class="price">₹0</div><div style="color: var(--text-dim); font-size: 0.85rem;">For new creators testing the waters</div><ul class="features"><li><i data-lucide="check-circle-2"></i> 1 Video / Day</li><li><i data-lucide="check-circle-2"></i> Standard Processing</li><li><i data-lucide="x-circle" style="color: var(--danger); opacity:0.3;"></i> Multi-Channel Support</li></ul><button class="btn-buy" disabled>Free Forever</button></div><!-- PRO PLAN --><div class="plan-card featured" id="card-pro"><div class="tag">MOST POPULAR</div><div class="current-label">ACTIVE</div><div style="font-weight: 800; color: var(--accent-light); font-size: 0.8rem; letter-spacing: 1px;">PRO AUTOMATION</div><div class="price"><span id="old-m" style="display: none;" class="old-price">₹499</span><span id="new-m">₹299</span></div><div style="color: var(--text-dim); font-size: 0.85rem;">+30 Days of Unlimited Growth</div><ul class="features"><li><i data-lucide="check-circle-2"></i> 2 YouTube Channels</li><li><i data-lucide="check-circle-2"></i> 5 Videos / Day</li><li><i data-lucide="check-circle-2"></i> Priority Server Core</li><li><i data-lucide="check-circle-2"></i> Auto-Scheduling Engine</li></ul><button class="btn-buy" id="btn-pro" onclick="buyPlan('pro_monthly')">Add 30 Days</button></div><!-- ULTRA PLAN --><div class="plan-card" id="card-ultra" style="border-color: #f59e0b;"><div class="tag" style="background: #f59e0b;">GOD MODE</div><div class="current-label">ACTIVE</div><div style="font-weight: 800; color: #f59e0b; font-size: 0.8rem; letter-spacing: 1px;">ULTRA UNLIMITED</div><div class="price">👑</div><div style="color: var(--text-dim); font-size: 0.85rem;">Maximum Power. No Boundaries.</div><ul class="features"><li><i data-lucide="zap" style="color: #f59e0b;"></i> Unlimited Production</li><li><i data-lucide="zap" style="color: #f59e0b;"></i> Bulk Management</li><li><i data-lucide="zap" style="color: #f59e0b;"></i> Personal Account Manager</li></ul><button class="btn-buy" style="background: #f59e0b;" disabled>Contact Sales</button></div></div></div><script>const authToken = localStorage.getItem('saas_token');if (!authToken) window.location.href = 'index.html';async function init() {try {// 1. Load Pricingconst pRes = await fetch(`/api/platform/pricing?t=${Date.now()}`);const p = await pRes.json();const monthlyBase = p.pro_monthly || 299;if (p.m_discount_active) {document.getElementById('old-m').innerText = `₹${monthlyBase}`;document.getElementById('old-m').style.display = 'inline';2 unmodified linesdocument.getElementById('old-m').style.display = 'none';document.getElementById('new-m').innerText = `₹${monthlyBase}`;}// 2. Load User Statusconst res = await fetch('/api/auth/me', { headers: { 'Authorization': `Bearer ${authToken}` } });const user = await res.json();if (user.loggedIn) {let plan = user.plan || 'free';if (user.role === 'admin') plan = 'ultra'; // Admins always treated as Ultra in UIlet statusText = '🛡️ FREE START';if (plan === 'ultra') {statusText = '☢️ GOD MODE';document.getElementById('card-ultra').classList.add('active-plan');document.getElementById('card-ultra').querySelector('.current-label').style.display = 'block';} else if (plan === 'pro' || plan === 'premium') {statusText = '⚡ PRO CREATOR';document.getElementById('card-pro').classList.add('active-plan');document.getElementById('card-pro').querySelector('.current-label').style.display = 'block';document.getElementById('btn-pro').innerText = "Extend Pro Access";} else {document.getElementById('card-free').classList.add('active-plan');document.getElementById('card-free').querySelector('.current-label').style.display = 'block';}document.getElementById('current-plan').innerText = statusText;if (user.role === 'admin' || plan === 'ultra') {document.getElementById('expiry-date').innerText = '∞ Permanent Access';} else if (user.expires_at) {const date = new Date(user.expires_at).toLocaleDateString('en-IN', { day: 'numeric', month: 'long', year: 'numeric' });const daysLeft = Math.ceil((new Date(user.expires_at) - new Date()) / (1000 * 60 * 60 * 24));document.getElementById('expiry-date').innerText = daysLeft > 0 ? `${date} (${daysLeft} Days Left)` : 'Expired';} else {document.getElementById('expiry-date').innerText = 'No Active Plan';}}lucide.createIcons();} catch (e) { console.error(e); }}async function buyPlan(plan) {const btn = event.target;const orig = btn.innerText;btn.innerText = "Securing Order...";try {const res = await fetch('/api/payments/create-order', {method: 'POST',headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },body: JSON.stringify({ plan })});const order = await res.json();const options = {"key": "rzp_live_SlfVPYNAQ7dyZ4","amount": order.amount,"currency": "INR","name": "ViralFlow AI","description": "Pro Creator Upgrade","order_id": order.id,"handler": async function (response) {response.plan_type = plan;const verify = await fetch('/api/payments/verify', {method: 'POST',headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },body: JSON.stringify(response)});if (verify.ok) {alert("Time Stacked Successfully! 🚀💎");location.reload();}},"theme": { "color": "#8b5cf6" }};const rzp1 = new Razorpay(options);rzp1.open();} catch(e) { alert("Payment Failed"); }btn.innerText = orig;}init();</script></body></html>init();</script></body></html>
dashboard/plans.html+160-129