1 line
5.3 KiB
JavaScript
1 line
5.3 KiB
JavaScript
"use strict";(()=>{var e={};e.id=5516,e.ids=[5516],e.modules={42452:(e,s,t)=>{t.r(s),t.d(s,{config:()=>_,default:()=>j,getServerSideProps:()=>b,getStaticPaths:()=>v,getStaticProps:()=>f,reportWebVitals:()=>w,routeModule:()=>q,unstable_getServerProps:()=>D,unstable_getServerSideProps:()=>M,unstable_getStaticParams:()=>y,unstable_getStaticPaths:()=>P,unstable_getStaticProps:()=>N});var r={};t.r(r),t.d(r,{default:()=>g,getServerSideProps:()=>S});var a=t(63865),l=t(9455),n=t(30671),i=t(49407),o=t(89600),c=t(8732);t(82015);var u=t(93615),d=t.n(u),p=t(49888),x=t(36299),m=t(67216),h=t.n(m);function g({user:e,data:s}){let t=(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)(p.A,{head:t,user:e,children:(0,c.jsx)(x.A,{data:s})})}async function S({req:e,res:s,query:t}){let r=await d()(e);return r?.logged_in_status?{props:{user:r,data:{users:await h()("SELECT * FROM users ORDER BY id DESC")}}}:{redirect:{destination:"/su/login",permanent:!1}}}let j=(0,n.M)(r,"default"),f=(0,n.M)(r,"getStaticProps"),v=(0,n.M)(r,"getStaticPaths"),b=(0,n.M)(r,"getServerSideProps"),_=(0,n.M)(r,"config"),w=(0,n.M)(r,"reportWebVitals"),N=(0,n.M)(r,"unstable_getStaticProps"),P=(0,n.M)(r,"unstable_getStaticPaths"),y=(0,n.M)(r,"unstable_getStaticParams"),D=(0,n.M)(r,"unstable_getServerProps"),M=(0,n.M)(r,"unstable_getServerSideProps"),q=new a.PagesRouteModule({definition:{kind:l.A.PAGES,page:"/su",pathname:"/su",bundlePath:"",filename:""},components:{App:o.default,Document:i.default},userland:r})},36299:(e,s,t)=>{t.d(s,{A:()=>c});var r=t(8732),a=t(82015),l=t.n(a),n=t(63715),i=t(32415),o=t(21498);function c({data:e}){Object.keys(e.users[0]);let[s,t]=l().useState(null),[a,c]=l().useState(0),[u,d]=l().useState(!1);return console.log(typeof s),(0,r.jsx)(l().Fragment,{children:(0,r.jsxs)("div",{className:"items-stretch gap-10 w-full",children:[(0,r.jsxs)("section",{className:"paper w-full",children:[(0,r.jsx)("h2",{className:"text-xl m-0 mb-6",children:"Users"}),(0,r.jsx)("div",{className:"flex-col items-stretch gap-10",children:e.users.map((e,s)=>(0,r.jsx)(o.A,{userObject:e},s+1))})]}),(0,r.jsxs)("section",{className:"paper",children:[(0,r.jsxs)("div",{className:"w-full justify-between",children:[(0,r.jsx)("h2",{className:"text-xl m-0",children:"Error Logs"}),(0,r.jsx)("div",{children:(0,r.jsxs)("button",{onClick:e=>{window.confirm("Clear Error Logs?")&&(d(!0),(0,n.A)("/api/admin/clearErrorLogs","post").then(e=>{c(e=>e+1)}),setTimeout(()=>{d(!1)},2e3))},className:"outlined gray relative",children:[u&&(0,r.jsx)(i.A,{width:"20px"}),"Clear Error Log"]})})]}),s&&(0,r.jsx)("p",{dangerouslySetInnerHTML:{__html:s||"No Log"}}),"string"!=typeof s&&(0,r.jsx)(i.A,{position:"relative",width:"25px"})]})]})})}},21498:(e,s,t)=>{t.d(s,{A:()=>n});var r=t(8732),a=t(82015),l=t.n(a);function n({userObject:e,userPage:s}){let t=Object.keys(e),[a,n]=l().useState(!1),[i,o]=l().useState(0),[c,u]=l().useState(!s);return(0,r.jsxs)("div",{className:"card col green w-full overflow-hidden"+(c?s?" h-[100px]":" h-[85px]":" "),children:[(0,r.jsxs)("div",{className:"items-center w-full",children:[(0,r.jsx)("img",{src:e.image_thumbnail,alt:"",className:"rounded-full object-cover"+(s?" w-16 h-16":" w-12 h-12")}),!s&&(0,r.jsxs)("h3",{className:"m-0 text-xl",children:[e.first_name," ",e.last_name," "]}),(0,r.jsxs)("div",{className:"ml-auto",children:[(0,r.jsx)("button",{className:"outlined gray small-text",onClick:e=>{c?u(!1):u(!0)},children:c?"More Details":"Collapse"}),!s&&(0,r.jsx)("a",{href:`/su/users/${e.id}`,className:"button outlined gray small-text",children:"View User"})]})]}),(0,r.jsx)("div",{className:"card no-hover col w-full light-gray-bg",children:t.map((s,a)=>(0,r.jsxs)(l().Fragment,{children:[(0,r.jsx)("div",{children:(0,r.jsxs)("span",{style:{wordBreak:"break-all"},children:[s,":"," ",(0,r.jsx)("b",{children:e[s]})]})}),a<t.length-1&&(0,r.jsx)("hr",{})]},a+1))}),(0,r.jsx)("button",{className:"outlined gray small-text w-full",onClick:e=>{u(!0)},children:"Collapse"})]})}},67216:(e,s,t)=>{let r=t(9973),a=t(31976),l=r({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:a()}});async function n(...e){try{let s=await l.query(...e);return await l.end(),JSON.parse(JSON.stringify(s))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=n},31976:(e,s,t)=>{let r=t(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let s=`${e}/ca-cert.pem`;if(!r.existsSync(s)){console.log(`${s} does not exist`);return}return{ca:r.readFileSync(`${e}/ca-cert.pem`)}}},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")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")}};var s=require("../webpack-runtime.js");s.C(e);var t=e=>s(s.s=e),r=s.X(0,[883,9821,9600,3932],()=>t(42452));module.exports=r})(); |