dsql-admin/dsql-app/.local_dist/server/chunks/8760.js
Benjamin Toby e0a030f10d Updates
2025-01-13 09:00:21 +01:00

16 lines
6.6 KiB
JavaScript

"use strict";exports.id=8760,exports.ids=[8760],exports.modules={57660:(e,a,s)=>{let l;s.d(a,{A:()=>u});var t=s(8732),r=s(82015),n=s.n(r),i=s(46169);async function o({e,setLoading:a,user:s,image:l,query:t}){a(!0);let r={first_name:e.target.first_name.value,last_name:e.target.last_name.value,email:s?null:e.target.email_address.value,username:s?null:e.target.username.value,password:s?null:e.target.password.value,image:l||null};t?.invite&&(r.inviteObject=t),(0,i.A)(s?"/api/updateUser":"/api/registerUser",{method:"post",body:r},!!s).then(e=>{console.log(e),!s&&e?.insertId?(localStorage.setItem("id",e.insertId),(0,i.A)("/api/loginUser",{method:"post",body:{email:r.email,password:r.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"})):s&&e?.user?window.location.reload():e?.msg&&alert(e.msg)}).catch(e=>{console.log(e)}).finally(()=>{setTimeout(()=>{a(!1)},2e3)})}var m=s(10621),d=s(16757),c=s(5406);function u({user:e,query:a,image:s}){let r=a?.email?a.email:e?.email?e.email:"",[u,p]=n().useState(null),[g,f]=n().useState(!1);return(0,t.jsxs)("div",{className:"relative w-full max-w-2xl flex-col items-start",children:[g&&(0,t.jsx)(d.A,{}),!e&&(0,t.jsxs)(n().Fragment,{children:[(0,t.jsx)("hr",{className:"opacity-0"}),(0,t.jsx)(c.A,{user:null,userType:"admin",setLoading:f}),(0,t.jsxs)("div",{className:"w-full justify-center relative",children:[(0,t.jsx)("span",{className:"bg-white dark:bg-slate-800 px-3 relative z-10",children:"OR"}),(0,t.jsx)("hr",{className:"absolute"})]})]}),(0,t.jsxs)("form",{className:"w-full flex flex-col items-start gap-4 relative",onSubmit:l=>{l.preventDefault(),window.confirm("Update Account Information?")&&o({e:l,setLoading:f,user:e,image:s,query:a})},children:[u&&(0,t.jsx)(m.A,{message:u}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,t.jsx)("label",{htmlFor:"first_name",children:"First Name"}),(0,t.jsx)("input",{type:"text",name:"first_name",id:"first_name",placeholder:"First Name",autoComplete:"given-name",onInput:e=>{let a=e.target;a.value.match(/./)?(a.classList.remove("warning"),p(null)):a.classList.add("warning")},defaultValue:e?e.first_name:"",required:!0})]}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,t.jsx)("label",{htmlFor:"last_name",children:"Last Name"}),(0,t.jsx)("input",{type:"text",name:"last_name",id:"last_name",placeholder:"Last Name",autoComplete:"family-name",onInput:e=>{let a=e.target;a.value.match(/./)?(a.classList.remove("warning"),p(null)):a.classList.add("warning")},defaultValue:e?e.last_name:"",required:!0})]}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,t.jsx)("label",{htmlFor:"username",children:"Username"}),(0,t.jsx)("input",{type:"text",name:"username",id:"username",placeholder:"Username",autoComplete:"username",onInput:e=>{let a=e.target;a.value.match(/./)?(a.classList.remove("warning"),p(null)):a.classList.add("warning"),window.clearTimeout(l),l=setTimeout(()=>{(0,i.A)(`/api/checkDuplicateData?type=username&value=${a.value}&tableName=users`).then(e=>{console.log(e),e?.result?(p("Username Already Exists"),a.classList.add("warning")):(p(null),a.classList.remove("warning"))})},300)},defaultValue:e?e.username:"",required:!e,readOnly:!!e})]}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,t.jsx)("label",{htmlFor:"email_address",children:"Email Address"}),(0,t.jsx)("input",{type:"email",name:"email_address",id:"email_address",placeholder:"Email Address",autoComplete:"email",onInput:e=>{let a=e.target;window.clearTimeout(l),l=setTimeout(()=>{(0,i.A)(`/api/checkDuplicateData?type=email&value=${a.value}&tableName=users`).then(e=>{console.log(e),e?.result?(p("Email Already Exists"),a.classList.add("warning")):(p(null),a.classList.remove("warning"))})},300)},defaultValue:r,required:!0,readOnly:!!e})]}),!e&&(0,t.jsxs)(n().Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,t.jsx)("label",{htmlFor:"password",children:"Password"}),(0,t.jsx)("input",{type:"password",name:"password",id:"password",placeholder:"Password",required:!0})]}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,t.jsx)("label",{htmlFor:"confirm_password",children:"Confirm Password"}),(0,t.jsx)("input",{type:"password",name:"confirm_password",id:"confirm_password",placeholder:"Confirm Password",onInput:e=>{let a=e.target;a.closest("form")?.password.value===a.value?a.classList.remove("warning"):a.classList.add("warning")},required:!0})]}),(0,t.jsxs)("span",{className:"text-sm",children:['By clicking "Create Account" you agree to our'," ",(0,t.jsx)("a",{href:"/terms",target:"_blank",className:"font-bold",children:"Terms and Conditions"})]})]}),(0,t.jsx)("button",{type:"submit",className:"w-full",children:e?(0,t.jsx)("span",{children:"Update Account Info"}):(0,t.jsx)("span",{children:"Create Account"})}),!e&&(0,t.jsx)(n().Fragment,{children:(0,t.jsxs)("span",{className:"text-sm",children:["Already Have an Account?"," ",(0,t.jsx)("a",{href:"/login",className:"font-bold",children:"Login"})]})})]})]})}},5406:(e,a,s)=>{function l({user:e,userType:a,setLoading:s}){return null}s.d(a,{A:()=>l}),s(8732),s(82015),s(46169),s(45731)},45731:(e,a,s)=>{s.d(a,{A:()=>l});async function l(){try{let e=await caches.keys();e[0]&&await Promise.all(e.map(e=>caches.delete(e)))}catch(e){console.log("Error in clearing cache =>",e.message)}}},77047:(e,a,s)=>{s.d(a,{A:()=>r});var l=s(29021),t=s.n(l);async function r({user:e,message:a,component:s,noMail:l,req:r}){let n=new Date,i=(()=>{if(!r)return null;try{let e=r.headers["x-forwarded-for"],a=r.headers["x-real-ip"],s=r.headers["cf-connecting-ip"],l=Array.isArray(e)?e[0]:e?.split(",")[0],t=s||l||a||r.socket.remoteAddress;if(!t)return null;return String(t)}catch(e){return null}})();try{let l=`🚀 SERVER ERROR ===========================
Error Message: ${a}
Component: ${s}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(l+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),r?.url&&(l+=`
URL: ${r.url}`),r?.body&&(l+=`
Request Body: ${JSON.stringify(r.body,null,4)}`),i&&(l+=`
IP: ${i}`),l+=`
Date: ${n.toDateString()}
========================================`,t().existsSync("./.tmp/error.log")||t().writeFileSync("./.tmp/error.log","","utf-8");let o=t().readFileSync("./.tmp/error.log","utf-8");t().writeFileSync("./.tmp/error.log",l),t().appendFileSync("./.tmp/error.log",`
${o}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}}};