"use strict";(()=>{var e={};e.id=6309,e.ids=[6309],e.modules={13262:(e,t,s)=>{s.r(t),s.d(t,{config:()=>A,default:()=>S,getServerSideProps:()=>C,getStaticPaths:()=>f,getStaticProps:()=>y,reportWebVitals:()=>v,routeModule:()=>k,unstable_getServerProps:()=>M,unstable_getServerSideProps:()=>D,unstable_getStaticParams:()=>P,unstable_getStaticPaths:()=>E,unstable_getStaticProps:()=>_});var a={};s.r(a),s.d(a,{DashboardContext:()=>g,default:()=>b,getServerSideProps:()=>j});var r=s(63865),i=s(9455),n=s(30671),d=s(5583),l=s(19796),o=s(8732),c=s(82015),u=s.n(c),x=s(25562),m=s(92702),p=s(71192),h=s(70355);let g=u().createContext({});function b({user:e,databases:t,metrics:s}){let a=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,o.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[r,i]=u().useState(null);return(0,o.jsx)(x.A,{head:a,user:e,children:(0,o.jsxs)(g.Provider,{value:{user:e,databases:t,targetDatabase:r,setTargetDatabase:i,metrics:s},children:[(0,o.jsx)(p.A,{}),(0,o.jsx)(h.A,{targetDatabase:r})]})})}async function j({req:e,res:t,query:s}){let a=await (0,m.default)(e,t);return a?.logged_in_status?{redirect:{destination:`/admin/${a.id}`,permanent:!1}}:{redirect:{destination:"/login",permanent:!1}}}let S=(0,n.M)(a,"default"),y=(0,n.M)(a,"getStaticProps"),f=(0,n.M)(a,"getStaticPaths"),C=(0,n.M)(a,"getServerSideProps"),A=(0,n.M)(a,"config"),v=(0,n.M)(a,"reportWebVitals"),_=(0,n.M)(a,"unstable_getStaticProps"),E=(0,n.M)(a,"unstable_getStaticPaths"),P=(0,n.M)(a,"unstable_getStaticParams"),M=(0,n.M)(a,"unstable_getServerProps"),D=(0,n.M)(a,"unstable_getServerSideProps"),k=new r.PagesRouteModule({definition:{kind:i.A.PAGES,page:"/admin",pathname:"/admin",bundlePath:"",filename:""},components:{App:l.default,Document:d.default},userland:a})},71192:(e,t,s)=>{s.d(t,{A:()=>j});var a=s(8732),r=s(82015),i=s.n(r),n=s(3530),d=s(53926),l=s(66485),o=s(56331);function c(){let{databases:e,setTargetDatabase:t,user:s}=i().useContext(n.DashboardContext);return(0,a.jsx)(i().Fragment,{children:(0,a.jsx)(o.A,{databases:e,setTargetDatabase:t,title:"Recently added Databases",more:!0,user:s})})}var u=s(67274),x=s(34637),m=s(93213),p=s(83158);let h=(0,s(82544).A)("Key",[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]]);function g({icon:e,metric:t,count:s,url:r}){return(0,a.jsxs)("a",{href:r,className:"card col w-full",children:[(0,a.jsx)("div",{className:"absolute top-4 right-4",children:e}),(0,a.jsxs)("div",{className:"content-block",children:[(0,a.jsx)("span",{className:"metric text-slate-800 dark:text-white",children:s}),(0,a.jsx)("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:t})]})]})}function b(){let{databases:e,setTargetDatabase:t,metrics:s,user:r}=i().useContext(n.DashboardContext);return(0,a.jsx)("section",{className:"p-0",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 w-full gap-6 items-stretch",children:[(0,a.jsx)(g,{metric:"Databases Created",count:s?.dbCount||0,icon:(0,a.jsx)(x.A,{size:20,className:"text-secondary2"}),url:`/admin/${r?.id}/databases`}),(0,a.jsx)(g,{metric:"Tables Created",count:s?.tablesCount||0,icon:(0,a.jsx)(m.A,{size:20,className:"text-primary"})}),(0,a.jsx)(g,{metric:"Media Added",count:s?.mediaCount||0,icon:(0,a.jsx)(p.A,{size:20,className:"text-slate-500"}),url:`/admin/${r?.id}/media`}),(0,a.jsx)(g,{metric:"API Keys",count:s?.apiKeysCount||0,icon:(0,a.jsx)(h,{size:20,className:"text-slate-900 dark:text-white"}),url:`/admin/${r?.id}/api-keys`})]})})}function j(){let{databases:e,user:t}=i().useContext(n.DashboardContext);return(0,a.jsxs)(i().Fragment,{children:[(0,a.jsxs)("div",{className:"flex-col items-start gap-0",children:[(0,a.jsx)("h1",{className:"text-3xl m-0",children:"Dashboard"}),(0,a.jsx)(d.A,{user:t})]}),t?.verification_status?.toString().match(/1/)?(0,a.jsxs)(i().Fragment,{children:[(0,a.jsx)(b,{}),(0,a.jsx)(c,{}),(0,a.jsx)(u.A,{user:t})]}):(0,a.jsx)(l.A,{})]})}},93213:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]])},3530:(e,t,s)=>{s.r(t),s.d(t,{DashboardContext:()=>u,default:()=>x,getServerSideProps:()=>m});var a=s(8732),r=s(82015),i=s.n(r),n=s(25562),d=s(92702),l=s(71192),o=s(70355),c=s(71934);let u=i().createContext({});function x({user:e,databases:t,metrics:s}){let r=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,a.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[d,c]=i().useState();return(0,a.jsx)(n.A,{head:r,user:e,children:(0,a.jsxs)(u.Provider,{value:{user:e,databases:t,targetDatabase:d,setTargetDatabase:c,metrics:s},children:[(0,a.jsx)(l.A,{}),(0,a.jsx)(o.A,{targetDatabase:d})]})})}async function m({req:e,res:t,query:s}){let a=await (0,d.default)(e,t);if(!a?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let r=await (0,c.A)("SELECT * FROM user_databases WHERE user_id=? ORDER BY id DESC LIMIT 3",[a.id]),i=await (0,c.A)(` SELECT ( SELECT COUNT(id) FROM user_databases WHERE user_id=? ) AS dbCount, ( SELECT COUNT(id) FROM user_database_tables WHERE user_id=? ) AS tablesCount, ( SELECT COUNT(id) FROM user_media WHERE user_id=? ) AS mediaCount, ( SELECT COUNT(id) FROM api_keys WHERE user_id=? ) AS apiKeysCount `,[a.id,a.id,a.id,a.id]);return{props:{user:a,databases:r,metrics:i&&i[0]?i[0]:{}}}}},13893:e=>{e.exports=require("@moduletrace/datasquirel/dist/client/fetch")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},8732:e=>{e.exports=require("react/jsx-runtime")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")}};var t=require("../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),a=t.X(0,[883,9821,9796,5392,6160],()=>s(13262));module.exports=a})();