dsql-admin/dsql-app/.local_dist/server/pages/su/users.js

1 line
4.7 KiB
JavaScript
Raw Normal View History

2024-12-09 09:39:09 +00:00
"use strict";(()=>{var e={};e.id=5109,e.ids=[5109],e.modules={93701:(e,s,t)=>{t.r(s),t.d(s,{config:()=>D,default:()=>b,getServerSideProps:()=>w,getStaticPaths:()=>P,getStaticProps:()=>_,reportWebVitals:()=>N,routeModule:()=>O,unstable_getServerProps:()=>A,unstable_getServerSideProps:()=>L,unstable_getStaticParams:()=>q,unstable_getStaticPaths:()=>M,unstable_getStaticProps:()=>y});var r={};t.r(r),t.d(r,{default:()=>v,getServerSideProps:()=>j});var a=t(63865),l=t(9455),n=t(30671),i=t(49407),c=t(89600),o=t(8732),u=t(82015),d=t.n(u),p=t(93615),m=t.n(p),x=t(49888),h=t(21498);function g({data:e}){return(0,o.jsx)(d().Fragment,{children:(0,o.jsxs)("section",{className:"items-start justify-start p-6",children:[(0,o.jsxs)("div",{className:"flex flex-row items-center w-full gap-20 mb-6 justify-between",children:[(0,o.jsx)("h2",{className:"text-xl m-0",children:"Users"}),(0,o.jsx)("a",{href:"/su/users/new",className:"button",children:"Add User"})]}),(0,o.jsx)("div",{className:"flex-col items-stretch gap-10 w-full",children:e.users.map((e,s)=>(0,o.jsx)(h.A,{userObject:e},s+1))})]})})}var S=t(67216),f=t.n(S);function v({user:e,data:s}){let t=(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"})]});return(0,o.jsx)(x.A,{head:t,user:e,children:(0,o.jsx)(g,{data:s})})}async function j({req:e,res:s,query:t}){let r=await m()(e);return r?.logged_in_status?{props:{user:r,data:{users:(await f()("SELECT * FROM users")).reverse()}}}:{redirect:{destination:"/su/login",permanent:!1}}}let b=(0,n.M)(r,"default"),_=(0,n.M)(r,"getStaticProps"),P=(0,n.M)(r,"getStaticPaths"),w=(0,n.M)(r,"getServerSideProps"),D=(0,n.M)(r,"config"),N=(0,n.M)(r,"reportWebVitals"),y=(0,n.M)(r,"unstable_getStaticProps"),M=(0,n.M)(r,"unstable_getStaticPaths"),q=(0,n.M)(r,"unstable_getStaticParams"),A=(0,n.M)(r,"unstable_getServerProps"),L=(0,n.M)(r,"unstable_getServerSideProps"),O=new a.PagesRouteModule({definition:{kind:l.A.PAGES,page:"/su/users",pathname:"/su/users",bundlePath:"",filename:""},components:{App:c.default,Document:i.default},userland:r})},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,c]=l().useState(0),[o,u]=l().useState(!s);return(0,r.jsxs)("div",{className:"card col green w-full overflow-hidden"+(o?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=>{o?u(!1):u(!0)},children:o?"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`);