import React, { useState } from 'react'; import * as API from '../api.js'; const AuthPortal = ({ onLoginSuccess }) => { const [loading, setLoading] = useState(false); const handleSwiggyLogin = async (e) => { e.preventDefault(); setLoading(true); try { const res = await API.fetchLoginUrl(); if (res && res.auth_url) { localStorage.setItem('swiggy_oauth_state', res.state); window.location.href = res.auth_url; } else { alert("Failed to fetch login URL"); setLoading(false); } } catch (err) { console.error("Swiggy login error:", err); alert("Failed to initiate Swiggy login"); setLoading(false); } }; const handleDemoLogin = async (e) => { e.preventDefault(); setLoading(true); try { const response = await fetch('/api/v1/auth/demo', { method: 'POST' }); let token = "demo_jwt_token_fallback"; if (response.ok) { const data = await response.json(); if (data.access_token) token = data.access_token; } localStorage.setItem('swiggy_access_token', token); setTimeout(() => { setLoading(false); if (onLoginSuccess) onLoginSuccess(); }, 600); } catch (err) { localStorage.setItem('swiggy_access_token', "demo_jwt_token_fallback"); setTimeout(() => { setLoading(false); if (onLoginSuccess) onLoginSuccess(); }, 600); } }; return (
{/* Background Starry Glow & Ambient Lighting */}
{/* Left Section: Editorial Serif Hero Title & CTAs (7 Cols) */}
{/* Top Pill Badge */}
AN OPERATING SYSTEM FOR QUICK COMMERCE
{/* Giant Hero Title */}

Hyperlocal Operations.
Simplified.

{/* Subtitle Description */}

Unconstrain demand, smooth ETA jitter, and triage refunds — all in one intelligent platform powered by Swiggy MCP.

{/* Feature Quick Bar (6 Icon Grid) */}
{[ { icon: 'shopping_bag', label: 'DEMAND' }, { icon: 'schedule', label: 'ETA TRUTH' }, { icon: 'verified_user', label: 'REFUND' }, { icon: 'restaurant', label: 'DINEOUT' }, { icon: 'local_shipping', label: 'DISPATCH' }, { icon: 'chat', label: 'MCP AGENT' } ].map((f, i) => (
{f.icon}
{f.label}
))}
{/* Primary CTA Buttons */}
{/* Right Section: Stacked Floating Intelligence Cards (5 Cols) */}
{/* Card 1: Demand Oracle Live Forecast */}
INVENTORY ORACLE
LIVE TELEMETRY

₹1,85,600

TOTAL DEMAND UNCONSTRAINED

+24.28% WMAPE LIFT
Amul Fresh Milk (1L)
81% Stockout Risk (45m)
{/* Card 2: Live Active Order & ETA Truth */}
Order #1024 In Progress
CLIENT Gaurav Nayak
ITEMS 1x Dum Gosht Biryani
ETA SMOOTHER GPS Jitter Suppressed
{/* Card 3: Client & Auth Profile */}
GN

Gaurav Nayak

+91 98765 43210 • Patia Hub

Swiggy OAuth 2.1 PKCE Verified Active
); }; export default AuthPortal;