1 line
5.7 KiB
JavaScript
1 line
5.7 KiB
JavaScript
"use strict";(()=>{var e={};e.id=5516,e.ids=[5516],e.modules={84231:(e,s,r)=>{r.r(s),r.d(s,{config:()=>L,default:()=>f,getServerSideProps:()=>N,getStaticPaths:()=>b,getStaticProps:()=>j,reportWebVitals:()=>P,routeModule:()=>y,unstable_getServerProps:()=>E,unstable_getServerSideProps:()=>B,unstable_getStaticParams:()=>O,unstable_getStaticPaths:()=>w,unstable_getStaticProps:()=>A});var t={};r.r(t),r.d(t,{default:()=>D,getServerSideProps:()=>v});var a=r(63865),n=r(9455),o=r(30671),l=r(5583),i=r(19796),c=r(8732),u=r(82015),d=r.n(u),p=r(61197),S=r(40778),m=r(46169),_=r(16757),h=r(1360);function x({data:e}){Object.keys(e.users[0]);let[s,r]=d().useState(null),[t,a]=d().useState(0),[n,o]=d().useState(!1);return console.log(typeof s),(0,c.jsx)(d().Fragment,{children:(0,c.jsxs)("div",{className:"items-stretch gap-10 w-full",children:[(0,c.jsxs)("section",{className:"paper w-full",children:[(0,c.jsx)("h2",{className:"text-xl m-0 mb-6",children:"Users"}),(0,c.jsx)("div",{className:"flex-col items-stretch gap-10",children:e.users.map((e,s)=>(0,c.jsx)(h.A,{userObject:e},s+1))})]}),(0,c.jsxs)("section",{className:"paper",children:[(0,c.jsxs)("div",{className:"w-full justify-between",children:[(0,c.jsx)("h2",{className:"text-xl m-0",children:"Error Logs"}),(0,c.jsx)("div",{children:(0,c.jsxs)("button",{onClick:e=>{window.confirm("Clear Error Logs?")&&(o(!0),(0,m.A)("/api/admin/clearErrorLogs",{method:"POST"}).then(e=>{a(e=>e+1)}),setTimeout(()=>{o(!1)},2e3))},className:"outlined gray relative",children:[n&&(0,c.jsx)(_.A,{width:"20px"}),"Clear Error Log"]})})]}),s&&(0,c.jsx)("p",{dangerouslySetInnerHTML:{__html:s||"No Log"}}),"string"!=typeof s&&(0,c.jsx)(_.A,{position:"relative",width:"25px"})]})]})})}var g=r(71934);function D({user:e,data:s}){let r=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,c.jsx)("meta",{name:"description",content:"Welcome to your data app"})]});return(0,c.jsx)(S.A,{head:r,user:e,children:(0,c.jsx)(x,{data:s})})}async function v({req:e,res:s,query:r}){let t=await (0,p.A)(e);return t?.logged_in_status?{props:{user:t,data:{users:await (0,g.A)("SELECT * FROM users ORDER BY id DESC")}}}:{redirect:{destination:"/su/login",permanent:!1}}}let f=(0,o.M)(t,"default"),j=(0,o.M)(t,"getStaticProps"),b=(0,o.M)(t,"getStaticPaths"),N=(0,o.M)(t,"getServerSideProps"),L=(0,o.M)(t,"config"),P=(0,o.M)(t,"reportWebVitals"),A=(0,o.M)(t,"unstable_getStaticProps"),w=(0,o.M)(t,"unstable_getStaticPaths"),O=(0,o.M)(t,"unstable_getStaticParams"),E=(0,o.M)(t,"unstable_getServerProps"),B=(0,o.M)(t,"unstable_getServerSideProps"),y=new a.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/su",pathname:"/su",bundlePath:"",filename:""},components:{App:i.default,Document:l.default},userland:t})},1360:(e,s,r)=>{r.d(s,{A:()=>o});var t=r(8732),a=r(82015),n=r.n(a);function o({userObject:e,userPage:s}){let r=Object.keys(e),[a,o]=n().useState(!1),[l,i]=n().useState(0),[c,u]=n().useState(!s);return(0,t.jsxs)("div",{className:"card col green w-full overflow-hidden"+(c?s?" h-[100px]":" h-[85px]":" "),children:[(0,t.jsxs)("div",{className:"items-center w-full",children:[(0,t.jsx)("img",{src:e.image_thumbnail,alt:"",className:"rounded-full object-cover"+(s?" w-16 h-16":" w-12 h-12")}),!s&&(0,t.jsxs)("h3",{className:"m-0 text-xl",children:[e.first_name," ",e.last_name," "]}),(0,t.jsxs)("div",{className:"ml-auto",children:[(0,t.jsx)("button",{className:"outlined gray small-text",onClick:e=>{c?u(!1):u(!0)},children:c?"More Details":"Collapse"}),!s&&(0,t.jsx)("a",{href:`/su/users/${e.id}`,className:"button outlined gray small-text",children:"View User"})]})]}),(0,t.jsx)("div",{className:"card no-hover col w-full light-gray-bg",children:r.map((s,a)=>(0,t.jsxs)(n().Fragment,{children:[(0,t.jsx)("div",{children:(0,t.jsxs)("span",{style:{wordBreak:"break-all"},children:[s,":"," ",(0,t.jsx)("b",{children:e[s]})]})}),a<r.length-1&&(0,t.jsx)("hr",{})]},a+1))}),(0,t.jsx)("button",{className:"outlined gray small-text w-full",onClick:e=>{u(!0)},children:"Collapse"})]})}},71934:(e,s,r)=>{r.d(s,{A:()=>a});var t=r(51779);async function a(...e){let s=(0,t.A)();try{if(!s)throw Error("No Connection provided to DB_HANDLER function!");let r=await s.query(...e);return JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await s?.end()}}},51779:(e,s,r)=>{r.d(s,{A:()=>n});var t=r(9973),a=r.n(t);function n(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||a()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||a()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||a()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},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")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},33873:e=>{e.exports=require("path")}};var s=require("../webpack-runtime.js");s.C(e);var r=e=>s(s.s=e),t=s.X(0,[883,9821,9796,6622],()=>r(84231));module.exports=t})(); |