/* App shell — state, cart (localStorage), routing, Checkout. Mounts the storefront. */ (function(){ const { AnnouncementBar, Header, Footer, Toast } = window.AXChrome; const { Home } = window.AXScreens; const { Products, ProductDetail, Cart, OrderSummary, OrderSuccess } = window.AXShop; const { Login, Register, Forgot, Account } = window.AXAuth; const { About, Contact, FAQ, ShippingReturns, Privacy, Terms } = window.AXPages; const { Button, Input, Eyebrow } = window.AXUI; const Ic=()=>window.AXIcons; const D=()=>window.AX_DATA; const wrap={maxWidth:'var(--container-max)',margin:'0 auto',padding:'0 var(--gutter)'}; const LS='ax_cart_v1'; function Checkout({ items, onPlace, onNav }){ const i=Ic(); const [method,setMethod]=React.useState('standard'); const [pay,setPay]=React.useState('card'); const sub=items.reduce((s,it)=>s+it.price*it.qty,0); const ship=method==='express'?14.99:(sub>49?0:6.99); const tax=+(sub*0.08).toFixed(2); const total=+(sub+ship+tax).toFixed(2); return

Checkout

{e.preventDefault();onPlace();}} style={{display:'flex',flexDirection:'column',gap:28}}>
{[['standard','Standard','3–5 business days',sub>49?'Free':'$6.99'],['express','Express','1–2 business days','$14.99']].map(([v,t,d,p])=> )}
{[['card','Card'],['paypal','PayPal'],['applepay','Apple Pay']].map(([v,t])=>)}
{pay==='card' ?
:
You'll be redirected to {pay==='paypal'?'PayPal':'Apple Pay'} to complete payment. (Demo — no real payment.)
}
{React.createElement(i.Shield,{size:15})} This is a demo storefront — payment is not collected. createPaymentIntent() is stubbed.
{items.map(it=>
{it.name.charAt(0)}{it.qty}
{it.name} ${(it.price*it.qty).toFixed(2)}
)}
onPlace()} cta="Place Order"/>
; } function Section({ title, children }){ return

{title}

{children}
; } function TrackOrder({ presetOrder, onNav }){ const i=Ic(); const [num,setNum]=React.useState(presetOrder||''); const [email,setEmail]=React.useState(''); const [result,setResult]=React.useState(presetOrder?'ok':null); const steps=['Order Placed','Processing','Shipped','Out for Delivery','Delivered']; const current=2; return
Order tracking

Track your order

{e.preventDefault();setResult('ok');}} style={{display:'flex',gap:12,alignItems:'flex-end',flexWrap:'wrap',background:'var(--surface-card)',border:'1px solid var(--border-subtle)',borderRadius:'var(--radius-xl)',padding:20,boxShadow:'var(--shadow-sm)'}}> setNum(e.target.value)} placeholder="ORD-2026-XXXXX" containerStyle={{flex:1,minWidth:180}}/> setEmail(e.target.value)} placeholder="you@example.com" containerStyle={{flex:1,minWidth:180}}/>
{result==='ok' &&
Order
{num||'ORD-2026-04817'}
Est. delivery
Jun 19, 2026
{steps.map((s,k)=>
{k<=current?React.createElement(i.Check,{size:15,sw:3}):''} {k}
{s}
{k===current &&
In transit · expected soon
}
)}
}
; } function App(){ const [route,setRoute]=React.useState({type:'home'}); const [cart,setCart]=React.useState(()=>{try{return JSON.parse(localStorage.getItem(LS))||[];}catch(e){return [];}}); const [toast,setToast]=React.useState(null); const [query,setQuery]=React.useState(''); const [orderNo,setOrderNo]=React.useState(''); const [authed,setAuthed]=React.useState(false); const toastT=React.useRef(); React.useEffect(()=>{try{localStorage.setItem(LS,JSON.stringify(cart));}catch(e){}},[cart]); React.useEffect(()=>{window.scrollTo(0,0);},[route]); const showToast=(m)=>{setToast(m);clearTimeout(toastT.current);toastT.current=setTimeout(()=>setToast(null),2200);}; const cartCount=cart.reduce((s,i)=>s+i.qty,0); const add=(p,qty=1)=>{setCart(c=>{const e=c.find(x=>x.id===p.id);if(e)return c.map(x=>x.id===p.id?{...x,qty:Math.min(x.qty+qty,p.stock)}:x);return [...c,{id:p.id,name:p.name,category:p.category,price:p.price,compareAt:p.compareAt,accent:p.accent,stock:p.stock,qty}];});showToast(`Added ${p.name} to cart`);}; const setQty=(id,q)=>setCart(c=>c.map(x=>x.id===id?{...x,qty:q}:x)); const remove=(id)=>setCart(c=>c.filter(x=>x.id!==id)); const pageMap={'Track Order':{type:'track'},'Shipping & Returns':{type:'shipping'},'FAQ':{type:'faq'},'Contact Us':{type:'contact'},'About AshopNexa':{type:'about'},'Privacy Policy':{type:'privacy'},'Terms of Service':{type:'terms'},'Best Sellers':{type:'products',label:'Best Sellers'},'New Arrivals':{type:'products',label:'New Arrivals'},'Collections':{type:'products',label:'All Products'},'Gift Cards':{type:'products',label:'All Products'},'Careers':{type:'about'}}; const nav=(r)=>{ if(r.type==='page'){ setRoute(pageMap[r.label]||{type:'home'}); } else setRoute(r); }; const place=()=>{const n='ORD-2026-'+Math.floor(10000+Math.random()*89999);setOrderNo(n);setCart([]);setRoute({type:'success'});}; let view; if(route.type==='home') view=setRoute({type:'detail',product:p})}/>; else if(route.type==='products') view=setRoute({type:'detail',product:p})} onNav={nav}/>; else if(route.type==='detail') view={add(p,q);setRoute({type:'checkout'});}} onView={p=>setRoute({type:'detail',product:p})} onNav={nav}/>; else if(route.type==='cart') view=setRoute({type:'checkout'})}/>; else if(route.type==='checkout') view=cart.length?:; else if(route.type==='success') view=; else if(route.type==='track') view=; else if(route.type==='login') view={setAuthed(true);showToast('Signed in — welcome back!');setRoute({type:'account'});}}/>; else if(route.type==='register') view={setAuthed(true);showToast('Account created — welcome to AshopNexa!');setRoute({type:'account'});}}/>; else if(route.type==='forgot') view=; else if(route.type==='account') view=authed?{setAuthed(false);showToast('Signed out');setRoute({type:'home'});}}/>:{setAuthed(true);showToast('Signed in — welcome back!');setRoute({type:'account'});}}/>; else if(route.type==='about') view=; else if(route.type==='contact') view=; else if(route.type==='faq') view=; else if(route.type==='shipping') view=; else if(route.type==='privacy') view=; else if(route.type==='terms') view=; else view=setRoute({type:'detail',product:p})}/>; return
setRoute({type:authed?'account':'login'})} onCart={()=>setRoute({type:'cart'})} query={query} onQuery={setQuery} onSearch={()=>setRoute({type:'products',label:'All Products'})}/>
{view}
; } ReactDOM.createRoot(document.getElementById('root')).render(); })();