turboci-admin/dist/web/static/chunks/pages/admin/users/add-user-cb427987939b9d0b.js
2026-03-12 03:56:24 +00:00

1 line
4.7 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[633],{33356:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/users/add-user",function(){return n(28043)}])},78513:function(e,t,n){"use strict";n.d(t,{Z:function(){return u}});var r=n(85893),s=n(77827),o=n(94495),a=n(60),i=n(5606),l=n(25808),c=n(67294),d=n(79265);function u(e){var t,n,u,h;let{new_deployment_user:f}=e,{newUser:p,setNewUser:m,loading:w,setLoading:y,isPasswordConfirmed:g,setIsPasswordConfirmed:j,pageProps:x}=function(e){let{new_deployment_user:t}=e,{pageProps:n}=(0,c.useContext)(i.AppContext),[r,s]=(0,c.useState)({}),{loading:o,setLoading:a}=(0,l.Z)(),[d,u]=(0,c.useState)(!1);return{newUser:r,setNewUser:s,loading:o,setLoading:a,isPasswordConfirmed:d,setIsPasswordConfirmed:u,pageProps:n}}({new_deployment_user:f}),v=!!(g&&(null===(t=p.password)||void 0===t?void 0:t.match(/./))&&(null===(n=p.confirmed_password)||void 0===n?void 0:n.match(/./)));return(0,r.jsx)("form",{onSubmit:e=>{e.preventDefault()},children:(0,r.jsxs)(a.Z,{className:"w-full items-stretch gap-6",children:[(0,r.jsx)(s.Z,{placeholder:"Eg. John",title:"First Name",changeHandler:e=>{m(t=>({...t,first_name:e}))},required:!0,showLabel:!0}),(0,r.jsx)(s.Z,{placeholder:"Eg. Doe",title:"Last Name",changeHandler:e=>{m(t=>({...t,last_name:e}))},showLabel:!0}),(0,r.jsx)(s.Z,{placeholder:"Email Address",title:"Email",type:"email",changeHandler:e=>{m(t=>({...t,email:e}))},required:!0,showLabel:!0}),x.user.id?(0,r.jsx)(s.Z,{placeholder:"Username",title:"Username",changeHandler:e=>{m(t=>({...t,username:e}))},validationRegex:/^[a-z0-9\-]{3,}$/,info:(0,r.jsxs)(r.Fragment,{children:["Allowed characters:"," ",(0,r.jsx)("code",{children:(0,r.jsx)("b",{children:"a-z, 0-9, -"})}),"."]}),wrapperWrapperProps:{className:"items-start!"},required:!0,showLabel:!0}):null,(0,r.jsx)(s.Z,{placeholder:"Password",title:"Password",type:"password",changeHandler:e=>{m(t=>({...t,password:e}))},validity:{isValid:!((null===(u=p.password)||void 0===u?void 0:u.match(/./))&&(null===(h=p.confirmed_password)||void 0===h?void 0:h.match(/./)))||v,msg:"Passwords don't match"},required:!0,showLabel:!0}),(0,r.jsx)(s.Z,{placeholder:"Confirm Password",title:"Confirm Password",type:"password",changeHandler:e=>{m(t=>({...t,confirmed_password:e})),j(e==p.password)},showLabel:!0}),(0,r.jsx)(o.Z,{title:"Login",onClick:()=>{v&&window.confirm("Create Super Admin Account?")&&(y(!0),(0,d.Z)("/api/auth/signup",{method:"POST",body:{new_user:p}}).then(e=>{console.log("res",e),e.success&&window.location.reload()}).finally(()=>{}))},loading:w,children:x.user.super_admin?"Add User":"Signup"})]})})}},28043:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSP:function(){return h},default:function(){return f}});var r=n(85893),s=n(67294),o=n(5606),a=n(60705),i=n(21147),l=n(78513),c=n(60);function d(){let{pageProps:e}=(0,s.useContext)(o.AppContext);return(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)(i.Z,{title:"Add New User"}),(0,r.jsx)(a.Z,{}),(0,r.jsx)(c.Z,{className:"grid-cell-content max-w-[600px]",children:(0,r.jsx)(l.Z,{})})]})}var u=n(89350),h=!0;function f(){return(0,r.jsx)(u.Z,{children:(0,r.jsx)(d,{})})}},79265:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(96486),s=n.n(r),o={stringify:function(e,t,n){try{return JSON.stringify(e,t||void 0,n)}catch(e){return}}};async function a(e,t){let n;let r={"Content-Type":"application/json"};(null==t?void 0:t.csrfKey)&&t.csrfValue&&(r[t.csrfKey]=t.csrfValue);let a=e;if((null==t?void 0:t.query)&&(a+=function(e){let t="?";if("object"!=typeof e)return console.log("Invalid Query type"),t;if(Array.isArray(e))return console.log("Query is an Array. This is invalid."),t;if(!e)return console.log("No Query provided."),t;let n=Object.keys(e),r=[];return n.forEach(t=>{if(!t||!e[t])return;let n=e[t];if("object"==typeof n){let e=o.stringify(n);r.push("".concat(t,"=").concat(encodeURIComponent(String(e))))}else"string"==typeof n||"number"==typeof n?r.push("".concat(t,"=").concat(encodeURIComponent(n))):r.push("".concat(t,"=").concat(String(n)))}),t+=r.join("&")}(t.query)),"string"==typeof t)try{n="post"===t?(await fetch(a,{method:t,headers:r})).json():(await fetch(a)).json()}catch(e){console.log("FetchAPI error #1:",e.message),n=null}else if("object"==typeof t)try{let e;if(t.body&&"object"==typeof t.body){let e=s().cloneDeep(t.body);t.body=JSON.stringify(e)}if(t.headers){t.headers=s().merge(t.headers,r);let n={...t};e=await fetch(a,n)}else{let n={...t,headers:r};e=await fetch(a,n)}n=e.json()}catch(e){console.log("FetchAPI error #2:",e.message),n=null}else try{let e=await fetch(a);n=await e.json()}catch(e){console.log("FetchAPI error #3:",e.message),n=null}return n}}},function(e){e.O(0,[662,75,664,433,7,827,242,888,774,179],function(){return e(e.s=33356)}),_N_E=e.O()}]);