2024-12-06 13:24:26 +00:00
|
|
|
"use strict";(()=>{var e={};e.id=189,e.ids=[189,636],e.modules={19881:(e,t,r)=>{r.r(t),r.d(t,{config:()=>U,default:()=>E,getServerSideProps:()=>D,getStaticPaths:()=>R,getStaticProps:()=>A,reportWebVitals:()=>F,routeModule:()=>k,unstable_getServerProps:()=>H,unstable_getServerSideProps:()=>O,unstable_getStaticParams:()=>W,unstable_getStaticPaths:()=>L,unstable_getStaticProps:()=>I});var s={};r.r(s),r.d(s,{SettingsContext:()=>_,default:()=>M,getServerSideProps:()=>C});var i=r(63865),a=r(9455),l=r(30671),u=r(49407),o=r(68268),n=r(8732),c=r(82015),m=r.n(c),d=r(95222),p=r(20048),x=r.n(p);r(26295);var g=r(58548),h=r(70045),f=r(79100),q=r(55158),S=r(62506);function j({user:e,image:t,setImage:r}){let s=m().useRef();return(0,n.jsxs)("div",{className:"paper w-full items-center",children:[(0,n.jsx)("h2",{className:"m-0 text-xl",children:"User Image"}),(0,n.jsx)("div",{className:"bg-white rounded-full overflow-hidden w-24 h-24",children:(0,n.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:s,"data-imagepreview":"image"})}),(0,n.jsxs)("div",{className:"w-full flex-col",id:"upload-user-image-options",children:[(0,n.jsxs)(S.A,{column:!0,className:"w-full",children:[(0,n.jsx)("button",{className:"outlined gray w-full whitespace-normal",onClick:e=>{(0,q.PB)("user-media-popup")},children:"Choose image From your Uploads"}),(0,n.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,n.jsx)("span",{children:"Choose image From your Computer"})})]}),(0,n.jsx)("input",{type:"file",accept:".png,.jpg,.jpeg,.webp",placeholder:"Choose Image",className:"hidden",onChange:async e=>{let t=e.target,s=t?.files?.[0];s&&r(await (0,f.A)({imageInputFile:s,maxWidth:400}))}})]})]})}function w(e){let{user:t,image:r,setImage:s,activeUser:i}=m().useContext(_),[a,l]=m().useState(!1);return(0,n.jsxs)(m().Fragment,{children:[(0,n.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,n.jsxs)("div",{className:"w-full flex items-center justify-between",children:[(0,n.jsx)("h1",{className:"text-3xl m-0",children:"Settings"}),(0,n.jsx)("div",{children:!t?.social_login&&(0,n.jsx)("a",{href:"/send-password-reset-link",className:"button outlined",children:"Reset Password"})})]}),(0,n.jsx)(g.A,{user:t})]}),(0,n.jsx)("section",{className:"p-0",children:(0,n.jsxs)("div",{className:"w-full grid grid-cols-1 xl:grid-cols-2 gap-8 items-stretch",children:[(0,n.jsxs)("div",{className:"paper w-full",children:[(0,n.jsx)("h2",{className:"m-0 text-xl",children:"Account Information"}),(0,n.jsxs)("div",{className:"flex flex-row w-full",children:[(0,n.jsx)("span",{children:"USER ID"}),(0,n.jsx)("b",{className:"info w-auto",children:t.id})]}),(0,n.jsx)(h.A,{user:i,image:r})]}),(0,n.jsx)("div",{className:"items-stretch",children:(0,n.jsx)(j,{image:r,setImage:s})})]})}),!1]})}r(32415);var v=r(42105),b=r(41658),y=r.n(b),N=r(67216),P=r.n(N);let _=m().createContext({});function M({user:e,databases:t,activeUser:r}){let s=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,n.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[i,a]=m().useState(r.image);return(0,n.jsx)(d.A,{head:s,user:e,children:(0,n.jsxs)(_.Provider,{value:{user:e,image:i,setImage:a,activeUser:r},children:[(0,n.jsx)(w,{}),(0,n.jsx)(v.A,{setDbImage:a})]})})}async function C({req:e,res:t,query:r}){let s=await x()(e,t);if(!s?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let i=await y()(`SELECT SCHEMA_NAME AS dbFullName FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME LIKE 'user_${s.id}%'`),a=await P()(`SELECT first_name,last_name,username,email,image,image_thumbnail FROM users WHERE id='${s.id}'`);return{props:{user:s,databases:i,activeUser:a[0]}}}let E=(0,l.M)(s,"default"),A=(0,l.M)(s,"getStaticProps"),R=(0,l.M)(s,"getStaticPaths"),D=(0,l.M)(s,"getServerSideProps"),U=(0,l.M)(s,"config"),F=(0,l
|