16 lines
6.6 KiB
JavaScript
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",{classNam
|
||
|
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)}}}};
|