1 line
5.7 KiB
JavaScript
1 line
5.7 KiB
JavaScript
|
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4147],{41696:(e,a,s)=>{s.d(a,{A:()=>t});var l=s(74848);function t(e){let{message:a}=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:a})]})}s(96540)},84147:(e,a,s)=>{let l;s.d(a,{A:()=>c});var t=s(74848),r=s(96540),n=s(23698);async function i(e){let{e:a,setLoading:s,user:l,image:t,query:r}=e;s(!0);let i={first_name:a.target.first_name.value,last_name:a.target.last_name.value,email:l?null:a.target.email_address.value,username:l?null:a.target.username.value,password:l?null:a.target.password.value,image:t||null};(null==r?void 0:r.invite)&&(i.inviteObject=r),(0,n.A)(l?"/api/updateUser":"/api/registerUser",{method:"post",body:i},!!l).then(e=>{console.log(e),!l&&(null==e?void 0:e.insertId)?(localStorage.setItem("id",e.insertId),(0,n.A)("/api/loginUser",{method:"post",body:{email:i.email,password:i.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"})):l&&(null==e?void 0:e.user)?window.location.reload():(null==e?void 0:e.msg)&&alert(e.msg)}).catch(e=>{console.log(e)}).finally(()=>{setTimeout(()=>{s(!1)},2e3)})}var o=s(41696),d=s(620),m=s(29907);function c(e){let{user:a,query:s,image:c}=e,u=(null==s?void 0:s.email)?s.email:(null==a?void 0:a.email)?a.email:"",[p,g]=r.useState(null),[x,f]=r.useState(!1);return(0,t.jsxs)("div",{className:"relative w-full max-w-2xl flex-col items-start",children:[x&&(0,t.jsx)(d.A,{}),!a&&(0,t.jsxs)(r.Fragment,{children:[(0,t.jsx)("hr",{className:"opacity-0"}),(0,t.jsx)(m.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:e=>{e.preventDefault(),i({e,setLoading:f,user:a,image:c,query:s})},children:[p&&(0,t.jsx)(o.A,{message:p}),(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"),g(null)):a.classList.add("warning")},defaultValue:a?a.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"),g(null)):a.classList.add("warning")},defaultValue:a?a.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"),g(null)):a.classList.add("warning"),window.clearTimeout(l),l=setTimeout(()=>{(0,n.A)("/api/checkDuplicateData?type=username&value=".concat(a.value,"&tableName=users")).then(e=>{console.log(e),(null==e?void 0:e.result)?(g("Username Already Exists"),a.classList.add("warning")):(g(null),a.classList.remove("warning"))})},300)},defaultValue:a?a.username:"",required:!a,readOnly:!!a})]}),(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:"ema
|