1 line
6.2 KiB
JavaScript
1 line
6.2 KiB
JavaScript
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5114],{97037:function(e,a,s){s.d(a,{Z:function(){return t}});var l=s(85893);s(67294);function t(e){var a=e.message;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})]})}},65114:function(e,a,s){s.d(a,{Z:function(){return p}});var l=s(828),t=s(85893),n=s(67294),r=s(86729),i=s(47568),o=s(97582);function d(){return(d=(0,i.Z)((function(e){var a,s,l,t,n,i,d;return(0,o.__generator)(this,(function(o){return a=e.e,s=e.setLoading,l=e.user,t=e.image,n=e.query,s(!0),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===n||void 0===n?void 0:n.invite)&&(i.inviteObject=n),d=l?"/api/updateUser":"/api/registerUser",(0,r.Z)(d,{method:"post",body:i},!!l).then((function(e){console.log(e),!l&&(null===e||void 0===e?void 0:e.insertId)?(localStorage.setItem("id",e.insertId),(0,r.Z)("/api/loginUser",{method:"post",body:{email:i.email,password:i.password}}).then((function(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?void 0:e.user)?window.location.reload():(null===e||void 0===e?void 0:e.msg)&&alert(e.msg)})).catch((function(e){console.log(e)})).finally((function(){setTimeout((function(){s(!1)}),2e3)})),[2]}))}))).apply(this,arguments)}var u,c=s(97037),m=s(95264),f=s(98374);function p(e){var a=e.user,s=e.query,i=e.image,o=(null===s||void 0===s?void 0:s.email)?s.email:(null===a||void 0===a?void 0:a.email)?a.email:"",p=(0,l.Z)(n.useState(null),2),g=p[0],v=p[1],x=(0,l.Z)(n.useState(!1),2),h=x[0],w=x[1];return(0,t.jsxs)("div",{className:"relative w-full max-w-2xl flex-col items-start",children:[h&&(0,t.jsx)(m.Z,{}),!a&&(0,t.jsxs)(n.Fragment,{children:[(0,t.jsx)("hr",{className:"opacity-0"}),(0,t.jsx)(f.Z,{user:null,userType:"admin",setLoading:w}),(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:function(e){e.preventDefault(),function(e){d.apply(this,arguments)}({e:e,setLoading:w,user:a,image:i,query:s})},children:[g&&(0,t.jsx)(c.Z,{message:g}),(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:function(e){var a=e.target;a.value.match(/./)?(a.classList.remove("warning"),v(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:function(e){var a=e.target;a.value.match(/./)?(a.classList.remove("warning"),v(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:function(e){var a=e.target;a.value.match(/./)?(a.classList.remove("warning"),v(null)):a.classList.add("warning"),window.clearTimeout(u),u=setTimeout((function(){(0,r.Z)("/api/checkDuplicateData?type=username&value=".concat(a.value,"&tableName=users")).then((function(e){console.log(e),(null===e||void 0===e?void 0:e.result)?(v("Username Already Exists"),a.classList.add("warning")):(v(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:"email_address",placeholder:"Email Address",autoComplete:"email",onInput:function(e){var a=e.target;window.clearTimeout(u),u=setTimeout((function(){(0,r.Z)("/api/checkDuplicateData?type=email&value=".concat(a.value,"&tableName=users")).then((function(e){console.log(e),(null===e||void 0===e?void 0:e.result)?(v("Email Already Exists"),a.classList.add("warning")):(v(null),a.classList.remove("warning"))}))}),300)},defaultValue:o,required:!0,readOnly:!!a})]}),!a&&(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:function(e){var a,s=e.target;(null===(a=s.closest("form"))||void 0===a?void 0:a.password.value)===s.value?s.classList.remove("warning"):s.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:a?(0,t.jsx)("span",{children:"Update Account Info"}):(0,t.jsx)("span",{children:"Create Account"})}),!a&&(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"})]})})]})]})}}}]); |