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-13 08:00:21 +00:00
"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,"reportWebVit