dsql-admin/dsql-app/.local_dist/server/chunks/7303.js

16 lines
7.5 KiB
JavaScript
Raw Normal View History

2025-01-14 15:27:08 +00:00
"use strict";exports.id=7303,exports.ids=[7303],exports.modules={57660:(e,s,a)=>{let r;a.d(s,{A:()=>u});var l=a(8732),t=a(82015),n=a.n(t),i=a(46169);async function o({e,setLoading:s,user:a,image:r,query:l}){s(!0);let t={first_name:e.target.first_name.value,last_name:e.target.last_name.value,email:a?null:e.target.email_address.value,username:a?null:e.target.username.value,password:a?null:e.target.password.value,image:r||null};l?.invite&&(t.inviteObject=l),(0,i.A)(a?"/api/updateUser":"/api/registerUser",{method:"post",body:t},!!a).then(e=>{console.log(e),!a&&e?.insertId?(localStorage.setItem("id",e.insertId),(0,i.A)("/api/loginUser",{method:"post",body:{email:t.email,password:t.password}}).then(e=>{console.log(e),localStorage.setItem("csrf",e.user.csrf_k),localStorage.setItem("stripe_id",e.user.stripe_id),localStorage.setItem("user",JSON.stringify(e.userPayload)),window.location.href="/admin"})):a&&e?.user?window.location.reload():e?.msg&&alert(e.msg)}).catch(e=>{console.log(e)}).finally(()=>{setTimeout(()=>{s(!1)},2e3)})}var c=a(10621),d=a(16757),m=a(96997);function u({user:e,query:s,image:a}){let t=s?.email?s.email:e?.email?e.email:"",[u,p]=n().useState(null),[f,g]=n().useState(!1);return(0,l.jsxs)("div",{className:"relative w-full max-w-2xl flex-col items-start",children:[f&&(0,l.jsx)(d.A,{}),!e&&(0,l.jsxs)(n().Fragment,{children:[(0,l.jsx)("hr",{className:"opacity-0"}),(0,l.jsx)(m.A,{user:null,userType:"admin",setLoading:g}),(0,l.jsxs)("div",{className:"w-full justify-center relative",children:[(0,l.jsx)("span",{className:"bg-white dark:bg-slate-800 px-3 relative z-10",children:"OR"}),(0,l.jsx)("hr",{className:"absolute"})]})]}),(0,l.jsxs)("form",{className:"w-full flex flex-col items-start gap-4 relative",onSubmit:r=>{r.preventDefault(),window.confirm("Update Account Information?")&&o({e:r,setLoading:g,user:e,image:a,query:s})},children:[u&&(0,l.jsx)(c.A,{message:u}),(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,l.jsx)("label",{htmlFor:"first_name",children:"First Name"}),(0,l.jsx)("input",{type:"text",name:"first_name",id:"first_name",placeholder:"First Name",autoComplete:"given-name",onInput:e=>{let s=e.target;s.value.match(/./)?(s.classList.remove("warning"),p(null)):s.classList.add("warning")},defaultValue:e?e.first_name:"",required:!0})]}),(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,l.jsx)("label",{htmlFor:"last_name",children:"Last Name"}),(0,l.jsx)("input",{type:"text",name:"last_name",id:"last_name",placeholder:"Last Name",autoComplete:"family-name",onInput:e=>{let s=e.target;s.value.match(/./)?(s.classList.remove("warning"),p(null)):s.classList.add("warning")},defaultValue:e?e.last_name:"",required:!0})]}),(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,l.jsx)("label",{htmlFor:"username",children:"Username"}),(0,l.jsx)("input",{type:"text",name:"username",id:"username",placeholder:"Username",autoComplete:"username",onInput:e=>{let s=e.target;s.value.match(/./)?(s.classList.remove("warning"),p(null)):s.classList.add("warning"),window.clearTimeout(r),r=setTimeout(()=>{(0,i.A)(`/api/checkDuplicateData?type=username&value=${s.value}&tableName=users`).then(e=>{console.log(e),e?.result?(p("Username Already Exists"),s.classList.add("warning")):(p(null),s.classList.remove("warning"))})},300)},defaultValue:e?e.username:"",required:!e,readOnly:!!e})]}),(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,l.jsx)("label",{htmlFor:"email_address",children:"Email Address"}),(0,l.jsx)("input",{type:"email",name:"email_address",id:"email_address",placeholder:"Email Address",autoComplete:"email",onInput:e=>{let s=e.target;window.clearTimeout(r),r=setTimeout(()=>{(0,i.A)(`/api/checkDuplicateData?type=email&value=${s.value}&tableName=users`).then(e=>{console.log(e),e?.result?(p("Email Already Exists"),s.classList.add("warning")):(p(null),s.classList.remove("warning"))})},300)},defaultValue:t,required:!0,readOnly:!!e})]}),!e&&(0,l.jsxs)(n().Fragment,{children:[(0,l.jsxs)("div",{classNa
Error Message: ${s}
Component: ${a}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(r+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),t?.url&&(r+=`
URL: ${t.url}`),t?.body&&(r+=`
Request Body: ${JSON.stringify(t.body,null,4)}`),i&&(r+=`
IP: ${i}`),r+=`
Date: ${n.toDateString()}
========================================`,l().existsSync("./.tmp/error.log")||l().writeFileSync("./.tmp/error.log","","utf-8");let o=l().readFileSync("./.tmp/error.log","utf-8");l().writeFileSync("./.tmp/error.log",r),l().appendFileSync("./.tmp/error.log",`
${o}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},71934:(e,s,a)=>{a.d(s,{A:()=>l});var r=a(51779);async function l(...e){let s=(0,r.A)();try{if(!s)throw Error("No Connection provided to DB_HANDLER function!");let a=await s.query(...e);return JSON.parse(JSON.stringify(a))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await s?.end()}}},51779:(e,s,a)=>{a.d(s,{A:()=>t});var r=a(9973),l=a.n(r);function t(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||l()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||l()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||l()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}}};