dsql-admin/dsql-app/.local_dist/server/pages/admin/[user_id]/settings.js

1 line
5.7 KiB
JavaScript
Raw Normal View History

2025-01-14 06:10:36 +00:00
"use strict";(()=>{var e={};e.id=189,e.ids=[189],e.modules={47766:(e,s,t)=>{t.r(s),t.d(s,{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={};t.r(a),t.d(a,{SettingsContext:()=>A,default:()=>P,getServerSideProps:()=>_});var r=t(63865),i=t(9455),l=t(30671),n=t(5583),o=t(19796),c=t(8732),d=t(82015),u=t.n(d),m=t(25562),p=t(92702),g=t(53926),x=t(57660),h=t(65842),f=t(91140),j=t(55904);function S({user:e,image:s,setImage:t}){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:s?"string"==typeof s?s:s.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 s=e.target;s.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 s=e.target,a=s?.files?.[0];a&&t(await (0,h.A)({imageInputFile:a,maxWidth:400}))}})]})]})}function b(){let{user:e,image:s,setImage:t,activeUser:a}=u().useContext(A),[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:s})]}),(0,c.jsx)("div",{className:"items-stretch",children:(0,c.jsx)(S,{image:s,setImage:t})})]})}),!1]})}t(16757),t(46169);var v=t(37195),w=t(19134),N=t(71934);let A=u().createContext({});function P({user:e,databases:s,activeUser:t}){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(t.image);return(0,c.jsx)(m.A,{head:a,user:e,children:(0,c.jsxs)(A.Provider,{value:{user:e,image:r,setImage:i,activeUser:t},children:[(0,c.jsx)(b,{}),(0,c.jsx)(v.A,{setDbImage:i})]})})}async function _({req:e,res:s,query:t}){let a=await (0,p.A)(e,s);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"),