dsql-admin/dsql-app/.local_dist/server/pages/admin/[user_id]/settings.js
Benjamin Toby e0a030f10d Updates
2025-01-13 09:00:21 +01:00

1 line
5.7 KiB
JavaScript

"use strict";(()=>{var e={};e.id=189,e.ids=[189],e.modules={47766:(e,t,s)=>{s.r(t),s.d(t,{config:()=>E,default:()=>M,getServerSideProps:()=>C,getStaticPaths:()=>y,getStaticProps:()=>q,reportWebVitals:()=>D,routeModule:()=>k,unstable_getServerProps:()=>H,unstable_getServerSideProps:()=>O,unstable_getStaticParams:()=>I,unstable_getStaticPaths:()=>F,unstable_getStaticProps:()=>R});var a={};s.r(a),s.d(a,{SettingsContext:()=>P,default:()=>_,getServerSideProps:()=>A});var r=s(63865),i=s(9455),l=s(30671),n=s(5583),o=s(19796),c=s(8732),d=s(82015),u=s.n(d),m=s(25562),p=s(92702),g=s(53926),x=s(57660),h=s(65842),f=s(91140),j=s(55904);function S({user:e,image:t,setImage:s}){let a=u().useRef();return(0,c.jsxs)("div",{className:"paper w-full items-center",children:[(0,c.jsx)("h2",{className:"m-0 text-xl",children:"User Image"}),(0,c.jsx)("div",{className:"bg-white rounded-full overflow-hidden w-24 h-24",children:(0,c.jsx)("img",{src:t?"string"==typeof t?t:t.imageBase64Full:"/images/database-placeholder.png",alt:"User Image",width:100,className:"w-full h-full object-cover",ref:a,"data-imagepreview":"image"})}),(0,c.jsxs)("div",{className:"w-full flex-col",id:"upload-user-image-options",children:[(0,c.jsxs)(j.A,{column:!0,className:"w-full",children:[(0,c.jsx)("button",{className:"outlined gray w-full whitespace-normal",onClick:e=>{(0,f.PB)("user-media-popup")},children:"Choose image From your Uploads"}),(0,c.jsx)("button",{className:"secondary w-full whitespace-normal",onClick:e=>{let t=e.target;t.closest("#upload-user-image-options")?.querySelector("input")?.click()},children:(0,c.jsx)("span",{children:"Choose image From your Computer"})})]}),(0,c.jsx)("input",{type:"file",accept:".png,.jpg,.jpeg,.webp",placeholder:"Choose Image",className:"hidden",onChange:async e=>{let t=e.target,a=t?.files?.[0];a&&s(await (0,h.A)({imageInputFile:a,maxWidth:400}))}})]})]})}function b(){let{user:e,image:t,setImage:s,activeUser:a}=u().useContext(P),[r,i]=u().useState(!1);return(0,c.jsxs)(u().Fragment,{children:[(0,c.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,c.jsxs)("div",{className:"w-full flex items-center justify-between",children:[(0,c.jsx)("h1",{className:"text-3xl m-0",children:"Settings"}),(0,c.jsx)("div",{children:!e?.social_login&&(0,c.jsx)("a",{href:"/send-password-reset-link",className:"button outlined",children:"Reset Password"})})]}),(0,c.jsx)(g.A,{user:e})]}),(0,c.jsx)("section",{className:"p-0",children:(0,c.jsxs)("div",{className:"w-full grid grid-cols-1 xl:grid-cols-2 gap-8 items-stretch",children:[(0,c.jsxs)("div",{className:"paper w-full",children:[(0,c.jsx)("h2",{className:"m-0 text-xl",children:"Account Information"}),(0,c.jsxs)("div",{className:"flex flex-row w-full",children:[(0,c.jsx)("span",{children:"USER ID"}),(0,c.jsx)("b",{className:"info w-auto",children:e.id})]}),(0,c.jsx)(x.A,{user:a,image:t})]}),(0,c.jsx)("div",{className:"items-stretch",children:(0,c.jsx)(S,{image:t,setImage:s})})]})}),!1]})}s(16757),s(46169);var v=s(37195),w=s(19134),N=s(71934);let P=u().createContext({});function _({user:e,databases:t,activeUser:s}){let a=(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"})]}),[r,i]=u().useState(s.image);return(0,c.jsx)(m.A,{head:a,user:e,children:(0,c.jsxs)(P.Provider,{value:{user:e,image:r,setImage:i,activeUser:s},children:[(0,c.jsx)(b,{}),(0,c.jsx)(v.A,{setDbImage:i})]})})}async function A({req:e,res:t,query:s}){let a=await (0,p.default)(e,t);if(!a?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let r=await (0,w.A)(`SELECT SCHEMA_NAME AS dbFullName FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME LIKE 'user_${a.id}%'`),i=await (0,N.A)(`SELECT first_name,last_name,username,email,image,image_thumbnail FROM users WHERE id='${a.id}'`);return{props:{user:a,databases:r,activeUser:i[0]}}}let M=(0,l.M)(a,"default"),q=(0,l.M)(a,"getStaticProps"),y=(0,l.M)(a,"getStaticPaths"),C=(0,l.M)(a,"getServerSideProps"),E=(0,l.M)(a,"config"),D=(0,l.M)(a,"reportWebVitals"),R=(0,l.M)(a,"unstable_getStaticProps"),F=(0,l.M)(a,"unstable_getStaticPaths"),I=(0,l.M)(a,"unstable_getStaticParams"),H=(0,l.M)(a,"unstable_getServerProps"),O=(0,l.M)(a,"unstable_getServerSideProps"),k=new r.PagesRouteModule({definition:{kind:i.A.PAGES,page:"/admin/[user_id]/settings",pathname:"/admin/[user_id]/settings",bundlePath:"",filename:""},components:{App:o.default,Document:n.default},userland:a})},19134:(e,t,s)=>{s.d(t,{A:()=>l});var a=s(29021),r=s.n(a),i=s(77047);async function l(e){let t;"production".match(/dev/)&&r().appendFileSync("./.tmp/sqlQuery.sql",e+"\n"+Date()+"\n\n\n","utf8");try{t=await function(...e){let t=global.DSQL_DB_CONN;try{return new Promise((s,a)=>{t.query(...e).then(e=>{t.end(),s(JSON.parse(JSON.stringify(e)))}).catch(e=>{t.end(),s({error:e.message,sql:e.sql})})})}catch(e){return{success:!1,error:e.message}}}(e)}catch(e){(0,i.A)({component:"noDatabaseDbHandler",message:e.message}),console.log("ERROR in noDatabaseDbHandler =>",e.message)}return t||null}},76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},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,1579,8760],()=>s(47766));module.exports=a})();