turboci-admin/dist/web/server/pages/auth/signup.js
2026-03-12 14:56:39 +01:00

1 line
9.3 KiB
JavaScript

"use strict";(()=>{var e={};e.id=613,e.ids=[613],e.modules={1068:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.r(t),a.d(t,{config:()=>f,default:()=>u,getServerSideProps:()=>m,getStaticPaths:()=>p,getStaticProps:()=>h,reportWebVitals:()=>w,routeModule:()=>b,unstable_getServerProps:()=>j,unstable_getServerSideProps:()=>Z,unstable_getStaticParams:()=>y,unstable_getStaticPaths:()=>x,unstable_getStaticProps:()=>g});var s=a(7093),n=a(5244),l=a(1323),i=a(1070),c=a(3893),o=a(1560),d=e([c,o]);[c,o]=d.then?(await d)():d;let u=(0,l.l)(o,"default"),h=(0,l.l)(o,"getStaticProps"),p=(0,l.l)(o,"getStaticPaths"),m=(0,l.l)(o,"getServerSideProps"),f=(0,l.l)(o,"config"),w=(0,l.l)(o,"reportWebVitals"),g=(0,l.l)(o,"unstable_getStaticProps"),x=(0,l.l)(o,"unstable_getStaticPaths"),y=(0,l.l)(o,"unstable_getStaticParams"),j=(0,l.l)(o,"unstable_getServerProps"),Z=(0,l.l)(o,"unstable_getServerSideProps"),b=new s.PagesRouteModule({definition:{kind:n.x.PAGES,page:"/auth/signup",pathname:"/auth/signup",bundlePath:"",filename:""},components:{App:c.default,Document:i.default},userland:o});r()}catch(e){r(e)}})},7831:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>c});var s=a(3893),n=a(975),l=a(6689),i=e([s]);function c({new_deployment_user:e,existing_user:t}){let{pageProps:a}=(0,l.useContext)(s.AppContext),[r,i]=(0,l.useState)(t||{}),{loading:c,setLoading:o}=(0,n.Z)(),[d,u]=(0,l.useState)(!1);return{newUser:r,setNewUser:i,loading:c,setLoading:o,isPasswordConfirmed:d,setIsPasswordConfirmed:u,pageProps:a}}s=(i.then?(await i)():i)[0],r()}catch(e){r(e)}})},7586:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>i});var s=a(997),n=a(6248),l=e([n]);function i({isPasswordConfirmed:e,newUser:t,setNewUser:a,setIsPasswordConfirmed:r}){let l=!!(e&&t.password?.match(/./)&&t.confirmed_password?.match(/./));return(0,s.jsxs)(s.Fragment,{children:[s.jsx(n.Z,{placeholder:"Password",title:"Password",type:"password",changeHandler:e=>{a(t=>({...t,password:e}))},validity:{isValid:!(t.password?.match(/./)&&t.confirmed_password?.match(/./))||l,msg:"Passwords don't match"},required:!0,showLabel:!0}),s.jsx(n.Z,{placeholder:"Confirm Password",title:"Confirm Password",type:"password",changeHandler:e=>{a(t=>({...t,confirmed_password:e})),r(e==t.password)},showLabel:!0})]})}n=(l.then?(await l)():l)[0],r()}catch(e){r(e)}})},5711:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>p});var s=a(997),n=a(6248),l=a(8006),i=a(3216),c=a(7831),o=a(7344),d=a(8097),u=a(7586),h=e([n,l,i,c,d,u]);function p({new_deployment_user:e,existing_user:t}){let a=(0,c.Z)({new_deployment_user:e,existing_user:t}),{newUser:r,setNewUser:h,loading:p,setLoading:m,isPasswordConfirmed:f,setIsPasswordConfirmed:w,pageProps:g}=a,x=!!(f&&r.password?.match(/./)&&r.confirmed_password?.match(/./));return s.jsx("form",{onSubmit:e=>{e.preventDefault()},children:(0,s.jsxs)(i.Z,{className:"w-full items-stretch gap-6",children:[s.jsx(n.Z,{placeholder:"Eg. John",title:"First Name",defaultValue:t?.first_name,changeHandler:e=>{h(t=>({...t,first_name:e}))},required:!0,showLabel:!0}),s.jsx(n.Z,{placeholder:"Eg. Doe",title:"Last Name",defaultValue:t?.last_name,changeHandler:e=>{h(t=>({...t,last_name:e}))},showLabel:!0}),s.jsx(n.Z,{placeholder:"Email Address",title:"Email",type:"email",defaultValue:t?.email,changeHandler:e=>{h(t=>({...t,email:e}))},required:!0,showLabel:!0}),g.user?.id&&!t?.is_super_admin?s.jsx(n.Z,{placeholder:"Username",title:"Username",defaultValue:t?.username,changeHandler:e=>{h(t=>({...t,username:e}))},validationRegex:/^[a-z0-9\-]{3,}$/,info:(0,s.jsxs)(s.Fragment,{children:["Allowed characters:"," ",s.jsx("code",{children:s.jsx("b",{children:"a-z, 0-9, -"})}),"."]}),wrapperWrapperProps:{className:(0,d.twMerge)("items-start!",t?.username?"opacity-70 pointer-events-none":"")},disabled:!!t?.username,required:!0,showLabel:!0}):null,t?.id?null:s.jsx(u.Z,{...a}),s.jsx(l.Z,{title:"Login",onClick:()=>{if(!x)return;let e=g.user?.id?"Add New User?":"Create Super Admin Account?";window.confirm(e)&&(m(!0),(0,o.Z)(t?.id?"/api/admin/edit-user":"/api/auth/signup",{method:"POST",body:{new_user:r,user_id:t?.id}}).then(e=>{e.success?g.user?.id?window.location.pathname="/admin/users":window.location.reload():(window.alert(e.msg||e.error||"New User Creation Failed!"),console.log("res",e))}).finally(()=>{setTimeout(()=>{m(!1)},5e3)}))},loading:p,children:t?.id?"Edit User":g.user?.super_admin?"Add User":"Signup"})]})})}[n,l,i,c,d,u]=h.then?(await h)():h,r()}catch(e){r(e)}})},8194:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>o});var s=a(997),n=a(1309),l=a(3216),i=a(5711),c=e([n,l,i]);function o(){return(0,s.jsxs)(l.Z,{className:"w-full items-center max-w-lg",children:[s.jsx(n.Z,{children:"Create Super Admin Account"}),s.jsx(i.Z,{})]})}[n,l,i]=c.then?(await c)():c,r()}catch(e){r(e)}})},9177:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>f});var s=a(997),n=a(1817),l=a(1048),i=a(5808),c=a(2984),o=a(4519),d=a(9705),u=a(736),h=a(6245),p=a(3216),m=e([l,i,c,o,d,u,h,p]);function f({children:e}){return s.jsx(o.Z,{className:"w-screen h-screen overflow-hidden",children:s.jsx(u.Z,{className:"w-full h-full",children:s.jsx(i.Z,{className:"grid-frame grid-cols-1 h-full",children:(0,s.jsxs)(p.Z,{className:"w-full justify-between h-full grid-cell",children:[(0,s.jsxs)(p.Z,{className:"gap-0",children:[(0,s.jsxs)(d.Z,{children:[s.jsx(d.Z,{className:"p-6",children:s.jsx(n.Z,{})}),s.jsx(c.Z,{vertical:!0})]}),s.jsx(c.Z,{})]}),s.jsx(l.Z,{className:"p-10",children:e}),(0,s.jsxs)(p.Z,{children:[s.jsx(c.Z,{}),s.jsx(h.Z,{className:"h-20 w-full"})]})]})})})})}[l,i,c,o,d,u,h,p]=m.then?(await m)():m,r()}catch(e){r(e)}})},1560:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.r(t),a.d(t,{default:()=>d,getServerSideProps:()=>u});var s=a(997),n=a(8194),l=a(9177),i=a(8804),c=a.n(i),o=e([n,l]);function d(){return s.jsx(l.Z,{children:s.jsx(n.Z,{})})}[n,l]=o.then?(await o)():o;let u=async e=>{let t=await c().select({table:"users"});return t.payload?.[0]?{redirect:{destination:"/auth/login",statusCode:307}}:{props:{}}};r()}catch(e){r(e)}})},1048:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>i});var s=a(997),n=a(8097),l=e([n]);function i({...e}){return s.jsx("div",{...e,className:(0,n.twMerge)("flex flex-col items-center justify-center gap-4 p-2 w-full","h-full twui-center",e.className),children:e.children})}n=(l.then?(await l)():l)[0],r()}catch(e){r(e)}})},5808:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>i});var s=a(997),n=a(8097),l=e([n]);function i({...e}){return s.jsx("div",{...e,className:(0,n.twMerge)("flex w-full max-w-container gap-4 justify-between","flex-wrap flex-col xl:flex-row items-start xl:items-center","twui-container",e.className),children:e.children})}n=(l.then?(await l)():l)[0],r()}catch(e){r(e)}})},1309:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>i});var s=a(997),n=a(8097),l=e([n]);function i({...e}){return s.jsx("h2",{...e,className:(0,n.twMerge)("text-2xl md:text-3xl mb-4","twui-headings twui-heading","twui-h2",e.className),children:e.children})}n=(l.then?(await l)():l)[0],r()}catch(e){r(e)}})},736:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>i});var s=a(997),n=a(8097),l=e([n]);function i({...e}){return s.jsx("section",{...e,className:(0,n.twMerge)("flex flex-col items-center w-full","px-4 sm:px-10 py-10","twui-section",e.className),children:e.children})}n=(l.then?(await l)():l)[0],r()}catch(e){r(e)}})},6245:(e,t,a)=>{a.a(e,async(e,r)=>{try{a.d(t,{Z:()=>i});var s=a(997),n=a(8097),l=e([n]);function i({horizontal:e,...t}){return s.jsx("div",{...t,className:(0,n.twMerge)("",e?"w-10":"w-full h-10","twui-spacer",t.className),children:t.children})}n=(l.then?(await l)():l)[0],r()}catch(e){r(e)}})},7344:(e,t,a)=>{a.d(t,{Z:()=>l});var r=a(6517),s=a.n(r);let n={stringify:function(e,t,a){try{return JSON.stringify(e,t||void 0,a)}catch(e){return}}};async function l(e,t){let a;let r={"Content-Type":"application/json"};t?.csrfKey&&t.csrfValue&&(r[t.csrfKey]=t.csrfValue);let l=e;if(t?.query&&(l+=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 a=Object.keys(e),r=[];return a.forEach(t=>{if(!t||!e[t])return;let a=e[t];if("object"==typeof a){let e=n.stringify(a);r.push(`${t}=${encodeURIComponent(String(e))}`)}else"string"==typeof a||"number"==typeof a?r.push(`${t}=${encodeURIComponent(a)}`):r.push(`${t}=${String(a)}`)}),t+=r.join("&")}(t.query)),"string"==typeof t)try{a="post"===t?(await fetch(l,{method:t,headers:r})).json():(await fetch(l)).json()}catch(e){console.log("FetchAPI error #1:",e.message),a=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 a={...t};e=await fetch(l,a)}else{let a={...t,headers:r};e=await fetch(l,a)}a=e.json()}catch(e){console.log("FetchAPI error #2:",e.message),a=null}else try{let e=await fetch(l);a=await e.json()}catch(e){console.log("FetchAPI error #3:",e.message),a=null}return a}},8804:e=>{e.exports=require("@moduletrace/nsqlite")},6517:e=>{e.exports=require("lodash")},2423:e=>{e.exports=require("lucide-react")},2785:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},6689:e=>{e.exports=require("react")},6405:e=>{e.exports=require("react-dom")},997:e=>{e.exports=require("react/jsx-runtime")},5315:e=>{e.exports=require("path")},8097:e=>{e.exports=import("tailwind-merge")}};var t=require("../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),r=t.X(0,[859,330,752,248],()=>a(1068));module.exports=r})();