2025-01-13 08:00:21 +00:00
|
|
|
"use strict";exports.id=3474,exports.ids=[3474],exports.modules={30671:(e,a)=>{Object.defineProperty(a,"M",{enumerable:!0,get:function(){return function e(a,t){return t in a?a[t]:"then"in a&&"function"==typeof a.then?a.then(a=>e(a,t)):"function"==typeof a&&"default"===t?a:void 0}}})},92090:(e,a,t)=>{t.a(e,async(e,r)=>{try{t.d(a,{A:()=>h});var l=t(8732),s=t(82015),n=t.n(s),i=t(53926),d=t(59023),o=t(46169),c=t(16757),u=t(20136),m=t(50264),p=e([m]);function h(){let{singleUser:e,database:a,user:t}=n().useContext(m.SingleDbUserContext),r=Object.keys(e).filter(e=>!e.match(/^id$|^date_|^user_id$|^social_|^disk_usage|user_type/)),[s,p]=n().useState(!1),[h,y]=n().useState(e.image);return(0,l.jsxs)(n().Fragment,{children:[(0,l.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,l.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(d.A,{}),h&&"string"==typeof h&&(0,l.jsx)("img",{src:h,alt:"",className:"avatar large outlined"}),(0,l.jsxs)("h1",{className:"text-3xl m-0",children:[e.first_name," ",e.last_name]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("a",{href:`/admin/${t?.id}/databases/${a.db_slug}/users/${e.id}/change-password`,className:"button outlined gray",children:"Change Password"}),(0,l.jsx)("button",{className:"bg-red-500",onClick:r=>{p(!0),window.confirm("Delete this user?")&&(0,o.A)("/api/deleteDbUser",{method:"post",body:{userId:e.id,dbFullName:a.db_full_name}},!0).then(e=>{e.success&&(window.location.pathname=`/admin/${t?.id}/databases/${a.db_slug}/users`)})},children:"Delete User"})]})]}),(0,l.jsx)(i.A,{user:t})]}),(0,l.jsxs)("section",{className:"paper",children:[s&&(0,l.jsx)(c.A,{}),(0,l.jsx)("div",{className:"w-full flex-col items-stretch",children:(0,l.jsxs)("form",{className:"flex flex-col items-stretch gap-4",onSubmit:t=>{t.preventDefault(),p(!0);let r=t.target,l=Array.from(r),s={};l.forEach(e=>{!e?.nodeName?.match(/button/i)&&e?.name&&e?.value?.match(/./)&&(e?.name?.match(/username|email/)||(s[e.name]=e.value))});let n={dbFullName:a.db_full_name,payload:{...s,id:e.id}};(0,o.A)("/api/updateDbUser",{method:"post",body:n},!0).then(t=>{"object"==typeof h&&h?.imageBase64?(h.imageName=`${a.db_slug}-user-${e.id}`,h.mimeType="jpeg",delete h.imageBase64Full,(0,o.A)("/api/addUserMedia",{method:"post",body:{media:[h],folder:a.db_slug.replace(/_/g,"-"),type:"image"}},!0).then(t=>{t&&t.mediaData&&t.mediaData[0]?.media_url?(0,o.A)("/api/updateDbUser",{method:"post",body:{dbFullName:a.db_full_name,payload:{id:e.id,image:t.mediaData[0].media_url,image_thumbnail:t.mediaData[0].media_thumbnail_url}}},!0).then(e=>{e.success&&window.location.reload(),setTimeout(()=>{p(!1)},500)}):window.location.reload()})):window.location.reload()})},children:[r.map((a,t)=>a?.match(/password|^database|email|username/)?(0,l.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,l.jsx)("label",{htmlFor:a,children:a}),(0,l.jsx)("input",{type:"text",name:a,id:a,value:e[a],placeholder:a,className:"opacity-40 pointer-events-none",onChange:e=>{e.preventDefault()}},t+1)]},t+1):a?.match(/more_user_data/)?(0,l.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,l.jsx)("label",{htmlFor:a,children:a}),(0,l.jsx)("textarea",{name:a,id:a,defaultValue:e[a]?e[a]:void 0,placeholder:a,rows:6},t+1)]},t+1):(0,l.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,l.jsx)("label",{htmlFor:a,children:a}),(0,l.jsx)("input",{type:"text",name:a,id:a,defaultValue:e[a]?e[a]:void 0,placeholder:a},t+1)]},t+1)),(0,l.jsxs)("div",{className:"border border-slate-300 dark:border-slate-600 border-solid bg-slate-100 dark:bg-slate-700 rounded p-6 flex-col items-start w-full",children:[(0,l.jsx)("h3",{className:"m-0 text-lg font-semibold mb-1 text-slate-600",children:"Update Image"}),(0,l.jsx)(u.A,{userImage:h,setUserImage:y})]}),(0,l.jsx)("button",{children:"Update User"})]})})]})]})}m=(p.then?(await p)():p)[0],r()}catch(e){r(e)}})},20136:(e,a,t)=>{t.d(a,{A:()=>i});var r=t(8732),l=t(82015),s=t.n(l),n=t(65842);function i({user:e,userImage:a,setUserImage:t,d
|
2025-01-14 15:27:08 +00:00
|
|
|
${d}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},52854:(e,a,t)=>{t.d(a,{A:()=>o});var r=t(71205);let l=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;async function s({unparsedResults:e,tableSchema:a}){let t=[];try{for(let s=0;s<e.length;s++){let n=e[s],i=Object.keys(n);for(let e=0;e<i.length;e++){let t=i[e],s=a?.fields[e];if(t?.match(l))continue;let d=n[t];("number"==typeof d||d)&&s?.encrypted&&d?.match(/./)&&(n[t]=(0,r.A)({encryptedString:d}))}t.push(n)}return t}catch(a){return console.log("ERROR in parseDbResults Function =>",a.message),e}}var n=t(77047),i=t(51779),d=t(84640);async function o({queryString:e,queryValuesArray:a,database:t,tableSchema:r,useLocal:l,debug:o}){let c=(0,i.A)({fa:!0});l&&(c=(0,i.A)({local:!0})),t?.match(/^datasquirel$/)&&(c=(0,i.A)()),o&&(console.log("varDatabaseDbHandler:query:",e),console.log("varDatabaseDbHandler:values:",a));let u=await (0,d.A)(c,e,a);if(o&&console.log("varDatabaseDbHandler:results:",u),u&&r)try{return await s({unparsedResults:u,tableSchema:r})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",t,e),(0,n.A)({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(u)return u;else return null}},71205:(e,a,t)=>{t.d(a,{A:()=>n});var r=t(55511),l=t(79428),s=t(48243);function n({encryptedString:e,encryptionKey:a,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:n,salt:i,keyLen:d,algorithm:o,bufferAllocSize:c}=(0,s.A)({encryptionKey:a});if(!n?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let u=(0,r.scryptSync)(n,i,d),m=l.Buffer.alloc(c,0),p=(0,r.createDecipheriv)(o,u,m);try{let a=p.update(e,"hex","utf8");return a+=p.final("utf8")}catch(a){return console.log("Error in decrypting =>",a.message),e}}},84640:(e,a,t)=>{async function r(e,a,t){try{if("string"==typeof a){let r=await e.query(l(a),t);return JSON.parse(JSON.stringify(r))}if("object"!=typeof a)return null;{let t=[];for(let r=0;r<a.length;r++)try{let s=a[r],n=await e.query(l(s.query),s.values);t.push(JSON.parse(JSON.stringify(n)))}catch(e){t.push(null)}return t}}catch(e){return null}finally{e.end()}}function l(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}t.d(a,{A:()=>r})},48243:(e,a,t)=>{t.d(a,{A:()=>r});function r(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?function(e,a){try{let a=Number(e);if("number"!=typeof a||isNaN(a))return 0;return Math.round(a)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},50264:(e,a,t)=>{t.a(e,async(e,r)=>{try{t.r(a),t.d(a,{SingleDbUserContext:()=>A,default:()=>g,getServerSideProps:()=>b});var l=t(8732),s=t(29021),n=t.n(s),i=t(82015),d=t.n(i),o=t(25562),c=t(92702),u=t(55880),m=t(22873),p=t(92090),h=t(71934),y=t(52854),f=e([u,p]);[u,p]=f.then?(await f)():f;let A=d().createContext({});function g({user:e,database:a,table:t,dbSchemaData:r,singleUser:s,query:n,confirmedDelegetedUser:i}){let d=`${s.first_name} ${s.last_name} Users | Datasquirel"`,c=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:d}),(0,l.jsx)("meta",{name:"description",content:"Welcome to your data app"})]});return(0,l.jsx)(o.A,{head:c,user:e,extraHeaderContent:(0,l.jsx)(u.A,{database:a,query:n,confirmedDelegetedUser:i,user:e}),children:(0,l.jsx)(A.Provider,{value:{user:e,database:a,table:t,dbSchemaData:r,singleUser:s,query:n,confirmedDelegetedUser:i},children:(0,l.jsx)(p.A,{})})})}async function b({req:e,res:a,query:t}){let r=await (0,c.A)(e,a);if(!r?.logged
|