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

1 line
5.5 KiB
JavaScript
Raw Normal View History

2024-12-06 13:24:26 +00:00
"use strict";exports.id=45,exports.ids=[45],exports.modules={64535:(e,a,s)=>{s.d(a,{A:()=>t});var l=s(8732);function t({message:e}){return(0,l.jsxs)("div",{className:"p-2 bg-orange-50 w-full justify-center rounded text-sm text-orange-700 border border-orange-400 border-solid",children:[(0,l.jsx)("img",{src:"/images/warning.png",alt:"Warning Image Icon",width:22,className:"-my-2"}),(0,l.jsx)("span",{children:e})]})}s(82015)},70045:(e,a,s)=>{let l;s.d(a,{A:()=>u});var t=s(8732),r=s(82015),n=s.n(r),i=s(63715);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 d=s(64535),m=s(32415),c=s(72414);function u({user:e,query:a,image:s}){let r=a?.email?a.email:e?.email?e.email:"",[u,p]=n().useState(null),[x,g]=n().useState(!1);return(0,t.jsxs)("div",{className:"relative w-full max-w-2xl flex-col items-start",children:[x&&(0,t.jsx)(m.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:g}),(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(),o({e:l,setLoading:g,user:e,image:s,query:a})},children:[u&&(0,t.jsx)(d.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)(`/