(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[613],{12120:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/auth/signup",function(){return t(10505)}])},48150:function(e,n,t){"use strict";t.d(n,{Z:function(){return h}});var r=t(85893),l=t(77827),s=t(94495),i=t(60),a=t(5606),o=t(25808),c=t(67294),u=t(79265),d=t(98388);function f(e){var n,t,s,i;let{isPasswordConfirmed:a,newUser:o,setNewUser:c,setIsPasswordConfirmed:u}=e,d=!!(a&&(null===(n=o.password)||void 0===n?void 0:n.match(/./))&&(null===(t=o.confirmed_password)||void 0===t?void 0:t.match(/./)));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.Z,{placeholder:"Password",title:"Password",type:"password",changeHandler:e=>{c(n=>({...n,password:e}))},validity:{isValid:!((null===(s=o.password)||void 0===s?void 0:s.match(/./))&&(null===(i=o.confirmed_password)||void 0===i?void 0:i.match(/./)))||d,msg:"Passwords don't match"},required:!0,showLabel:!0}),(0,r.jsx)(l.Z,{placeholder:"Confirm Password",title:"Confirm Password",type:"password",changeHandler:e=>{c(n=>({...n,confirmed_password:e})),u(e==o.password)},showLabel:!0})]})}function h(e){var n,t,h,m;let{new_deployment_user:p,existing_user:w}=e,v=function(e){let{new_deployment_user:n,existing_user:t}=e,{pageProps:r}=(0,c.useContext)(a.AppContext),[l,s]=(0,c.useState)(t||{}),{loading:i,setLoading:u}=(0,o.Z)(),[d,f]=(0,c.useState)(!1);return{newUser:l,setNewUser:s,loading:i,setLoading:u,isPasswordConfirmed:d,setIsPasswordConfirmed:f,pageProps:r}}({new_deployment_user:p,existing_user:w}),{newUser:x,setNewUser:j,loading:g,setLoading:y,isPasswordConfirmed:N,setIsPasswordConfirmed:Z,pageProps:_}=v,b=!!(N&&(null===(n=x.password)||void 0===n?void 0:n.match(/./))&&(null===(t=x.confirmed_password)||void 0===t?void 0:t.match(/./)));return(0,r.jsx)("form",{onSubmit:e=>{e.preventDefault()},children:(0,r.jsxs)(i.Z,{className:"w-full items-stretch gap-6",children:[(0,r.jsx)(l.Z,{placeholder:"Eg. John",title:"First Name",defaultValue:null==w?void 0:w.first_name,changeHandler:e=>{j(n=>({...n,first_name:e}))},required:!0,showLabel:!0}),(0,r.jsx)(l.Z,{placeholder:"Eg. Doe",title:"Last Name",defaultValue:null==w?void 0:w.last_name,changeHandler:e=>{j(n=>({...n,last_name:e}))},showLabel:!0}),(0,r.jsx)(l.Z,{placeholder:"Email Address",title:"Email",type:"email",defaultValue:null==w?void 0:w.email,changeHandler:e=>{j(n=>({...n,email:e}))},required:!0,showLabel:!0}),(null===(h=_.user)||void 0===h?void 0:h.id)&&!(null==w?void 0:w.is_super_admin)?(0,r.jsx)(l.Z,{placeholder:"Username",title:"Username",defaultValue:null==w?void 0:w.username,changeHandler:e=>{j(n=>({...n,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:(0,d.m6)("items-start!",(null==w?void 0:w.username)?"opacity-70 pointer-events-none":"")},disabled:!!(null==w?void 0:w.username),required:!0,showLabel:!0}):null,(null==w?void 0:w.id)?null:(0,r.jsx)(f,{...v}),(0,r.jsx)(s.Z,{title:"Login",onClick:()=>{var e;if(!b)return;let n=(null===(e=_.user)||void 0===e?void 0:e.id)?"Add New User?":"Create Super Admin Account?";window.confirm(n)&&(y(!0),(0,u.Z)((null==w?void 0:w.id)?"/api/admin/edit-user":"/api/auth/signup",{method:"POST",body:{new_user:x,user_id:null==w?void 0:w.id}}).then(e=>{if(e.success){var n;(null===(n=_.user)||void 0===n?void 0:n.id)?window.location.pathname="/admin/users":window.location.reload()}else window.alert(e.msg||e.error||"New User Creation Failed!"),console.log("res",e)}).finally(()=>{setTimeout(()=>{y(!1)},5e3)}))},loading:g,children:(null==w?void 0:w.id)?"Edit User":(null===(m=_.user)||void 0===m?void 0:m.super_admin)?"Add User":"Signup"})]})})}},44306:function(e,n,t){"use strict";t.d(n,{Z:function(){return m}});var r=t(85893),l=t(51833),s=t(57493),i=t(83772),a=t(60705),o=t(80600),c=t(94655),u=t(89028),d=t(98388);function f(e){let{horizontal:n,...t}=e;return(0,r.jsx)("div",{...t,className:(0,d.m6)("",n?"w-10":"w-full h-10","twui-spacer",t.className),children:t.children})}var h=t(60);function m(e){let{children:n}=e;return(0,r.jsx)(o.Z,{className:"w-screen h-screen overflow-hidden",children:(0,r.jsx)(u.Z,{className:"w-full h-full",children:(0,r.jsx)(i.Z,{className:"grid-frame grid-cols-1 h-full",children:(0,r.jsxs)(h.Z,{className:"w-full justify-between h-full grid-cell",children:[(0,r.jsxs)(h.Z,{className:"gap-0",children:[(0,r.jsxs)(c.Z,{children:[(0,r.jsx)(c.Z,{className:"p-6",children:(0,r.jsx)(l.Z,{})}),(0,r.jsx)(a.Z,{vertical:!0})]}),(0,r.jsx)(a.Z,{})]}),(0,r.jsx)(s.Z,{className:"p-10",children:n}),(0,r.jsxs)(h.Z,{children:[(0,r.jsx)(a.Z,{}),(0,r.jsx)(f,{className:"h-20 w-full"})]})]})})})})}},10505:function(e,n,t){"use strict";t.r(n),t.d(n,{__N_SSP:function(){return c},default:function(){return u}});var r=t(85893),l=t(56211),s=t(60),i=t(48150);function a(){return(0,r.jsxs)(s.Z,{className:"w-full items-center max-w-lg",children:[(0,r.jsx)(l.Z,{children:"Create Super Admin Account"}),(0,r.jsx)(i.Z,{})]})}var o=t(44306),c=!0;function u(){return(0,r.jsx)(o.Z,{children:(0,r.jsx)(a,{})})}},57493:function(e,n,t){"use strict";t.d(n,{Z:function(){return s}});var r=t(85893),l=t(98388);function s(e){let{...n}=e;return(0,r.jsx)("div",{...n,className:(0,l.m6)("flex flex-col items-center justify-center gap-4 p-2 w-full","h-full twui-center",n.className),children:n.children})}},83772:function(e,n,t){"use strict";t.d(n,{Z:function(){return s}});var r=t(85893),l=t(98388);function s(e){let{...n}=e;return(0,r.jsx)("div",{...n,className:(0,l.m6)("flex w-full max-w-container gap-4 justify-between","flex-wrap flex-col xl:flex-row items-start xl:items-center","twui-container",n.className),children:n.children})}},56211:function(e,n,t){"use strict";t.d(n,{Z:function(){return s}});var r=t(85893),l=t(98388);function s(e){let{...n}=e;return(0,r.jsx)("h2",{...n,className:(0,l.m6)("text-2xl md:text-3xl mb-4","twui-headings twui-heading","twui-h2",n.className),children:n.children})}},89028:function(e,n,t){"use strict";t.d(n,{Z:function(){return s}});var r=t(85893),l=t(98388);function s(e){let{...n}=e;return(0,r.jsx)("section",{...n,className:(0,l.m6)("flex flex-col items-center w-full","px-4 sm:px-10 py-10","twui-section",n.className),children:n.children})}},79265:function(e,n,t){"use strict";t.d(n,{Z:function(){return i}});var r=t(96486),l=t.n(r),s={stringify:function(e,n,t){try{return JSON.stringify(e,n||void 0,t)}catch(e){return}}};async function i(e,n){let t;let r={"Content-Type":"application/json"};(null==n?void 0:n.csrfKey)&&n.csrfValue&&(r[n.csrfKey]=n.csrfValue);let i=e;if((null==n?void 0:n.query)&&(i+=function(e){let n="?";if("object"!=typeof e)return console.log("Invalid Query type"),n;if(Array.isArray(e))return console.log("Query is an Array. This is invalid."),n;if(!e)return console.log("No Query provided."),n;let t=Object.keys(e),r=[];return t.forEach(n=>{if(!n||!e[n])return;let t=e[n];if("object"==typeof t){let e=s.stringify(t);r.push("".concat(n,"=").concat(encodeURIComponent(String(e))))}else"string"==typeof t||"number"==typeof t?r.push("".concat(n,"=").concat(encodeURIComponent(t))):r.push("".concat(n,"=").concat(String(t)))}),n+=r.join("&")}(n.query)),"string"==typeof n)try{t="post"===n?(await fetch(i,{method:n,headers:r})).json():(await fetch(i)).json()}catch(e){console.log("FetchAPI error #1:",e.message),t=null}else if("object"==typeof n)try{let e;if(n.body&&"object"==typeof n.body){let e=l().cloneDeep(n.body);n.body=JSON.stringify(e)}if(n.headers){n.headers=l().merge(n.headers,r);let t={...n};e=await fetch(i,t)}else{let t={...n,headers:r};e=await fetch(i,t)}t=e.json()}catch(e){console.log("FetchAPI error #2:",e.message),t=null}else try{let e=await fetch(i);t=await e.json()}catch(e){console.log("FetchAPI error #3:",e.message),t=null}return t}}},function(e){e.O(0,[662,75,664,433,7,827,888,774,179],function(){return e(e.s=12120)}),_N_E=e.O()}]);