(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[849],{4964:function(t,e,s){Promise.resolve().then(s.bind(s,9898))},9898:function(t,e,s){"use strict";s.r(e),s.d(e,{default:function(){return d}});var r=s(7437),l=s(2265);let a=t=>{var e;return"purchased"===t.status?"purchased: ".concat(null!==(e=t.plan)&&void 0!==e?e:"?"):"completed"===t.status?"onb completed":"".concat(t.progress,"%")},n=t=>"purchased"===t?"#22c55e":"completed"===t?"#3b82f6":"#f59e0b";function d(){let[t,e]=(0,l.useState)([]),[s,d]=(0,l.useState)(!0),[o,c]=(0,l.useState)(null),h=()=>{d(!0),fetch("/api/dashboard_aya").then(t=>t.json()).then(t=>{var s;e(null!==(s=t.users)&&void 0!==s?s:[]),c(null)}).catch(()=>c("Failed to load data")).finally(()=>d(!1))};(0,l.useEffect)(()=>{h();let t=setInterval(h,15e3);return()=>clearInterval(t)},[]);let p=t.length,u=t.filter(t=>"completed"===t.status||"purchased"===t.status).length,x=t.filter(t=>"purchased"===t.status).length,b=p>0?Math.round(t.reduce((t,e)=>t+e.progress,0)/p):0;return(0,r.jsxs)("main",{style:i.page,children:[(0,r.jsx)("h1",{style:i.title,children:"Ayatique Onboarding Dashboard"}),(0,r.jsxs)("div",{style:i.statsRow,children:[(0,r.jsxs)("div",{style:i.statCard,children:[(0,r.jsx)("span",{style:i.statNumber,children:p}),(0,r.jsx)("span",{style:i.statLabel,children:"Total Users"})]}),(0,r.jsxs)("div",{style:i.statCard,children:[(0,r.jsxs)("span",{style:i.statNumber,children:[b,"%"]}),(0,r.jsx)("span",{style:i.statLabel,children:"Avg Progress"})]}),(0,r.jsxs)("div",{style:i.statCard,children:[(0,r.jsx)("span",{style:i.statNumber,children:u}),(0,r.jsx)("span",{style:i.statLabel,children:"Completed"})]}),(0,r.jsxs)("div",{style:i.statCard,children:[(0,r.jsx)("span",{style:i.statNumber,children:x}),(0,r.jsx)("span",{style:i.statLabel,children:"Purchased"})]})]}),(0,r.jsxs)("div",{style:i.toolbar,children:[(0,r.jsx)("button",{type:"button",onClick:h,style:i.refreshBtn,children:"Refresh"}),s&&(0,r.jsx)("span",{style:i.loadingText,children:"Loading..."}),o&&(0,r.jsx)("span",{style:i.errorText,children:o})]}),(0,r.jsx)("div",{style:i.tableWrapper,children:(0,r.jsxs)("table",{style:i.table,children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{style:i.th,children:"ID"}),(0,r.jsx)("th",{style:i.th,children:"Action"}),(0,r.jsx)("th",{style:i.th,children:"Current Page"}),(0,r.jsx)("th",{style:i.th,children:"UTM Ad"}),(0,r.jsx)("th",{style:i.th,children:"Created"}),(0,r.jsx)("th",{style:i.th,children:"Last Active"})]})}),(0,r.jsxs)("tbody",{children:[t.map(t=>{var e;return(0,r.jsxs)("tr",{style:i.tr,children:[(0,r.jsx)("td",{style:i.td,children:(0,r.jsx)("code",{style:i.userId,children:t.id.slice(0,8)})}),(0,r.jsx)("td",{style:i.td,children:(0,r.jsx)("span",{style:{...i.badge,backgroundColor:n(t.status)},children:a(t)})}),(0,r.jsx)("td",{style:i.td,children:t.current_page}),(0,r.jsx)("td",{style:i.td,children:null!==(e=t.utm_ad)&&void 0!==e?e:"-"}),(0,r.jsx)("td",{style:i.td,children:new Date(t.created_at).toLocaleString()}),(0,r.jsx)("td",{style:i.td,children:new Date(t.updated_at).toLocaleString()})]},t.id)}),0===t.length&&!s&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,style:{...i.td,textAlign:"center",opacity:.5},children:"No users tracked yet"})})]})]})})]})}let i={page:{maxWidth:1100,margin:"0 auto",padding:"40px 20px",fontFamily:"'Plus Jakarta Sans', system-ui, sans-serif"},title:{fontSize:28,fontWeight:700,marginBottom:24},statsRow:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))",gap:16,marginBottom:24},statCard:{background:"#111629",borderRadius:12,padding:"20px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:4},statNumber:{fontSize:32,fontWeight:700},statLabel:{fontSize:13,color:"#b3bacd"},toolbar:{display:"flex",alignItems:"center",gap:12,marginBottom:16},refreshBtn:{padding:"8px 20px",borderRadius:8,border:"none",background:"#3b82f6",color:"#fff",fontWeight:600,cursor:"pointer",fontSize:14},loadingText:{color:"#b3bacd",fontSize:13},errorText:{color:"#ef4444",fontSize:13},tableWrapper:{overflowX:"auto",borderRadius:12,border:"1px solid rgba(255,255,255,0.08)"},table:{width:"100%",borderCollapse:"collapse"},th:{textAlign:"left",padding:"12px 16px",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"#b3bacd",borderBottom:"1px solid rgba(255,255,255,0.08)",background:"#111629"},tr:{borderBottom:"1px solid rgba(255,255,255,0.04)"},td:{padding:"10px 16px",fontSize:14,whiteSpace:"nowrap"},userId:{fontFamily:"monospace",fontSize:13,color:"#93a3bf"},badge:{display:"inline-block",padding:"3px 10px",borderRadius:6,fontSize:12,fontWeight:600,color:"#fff"}}}},function(t){t.O(0,[971,23,744],function(){return t(t.s=4964)}),_N_E=t.O()}]);