1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[102],{2910:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/users/new",function(){return a(1401)}])},1401:function(e,t,a){"use strict";a.r(t),a.d(t,{__N_SSP:function(){return m},default:function(){return p}});var s=a(5893),n=a(7294),r=a(1163),l=a(9152),i=a(9547),o=a.n(i);let c=["amber","brisk","canyon","delta","ember","forest","harbor","jasmine","linen","marble","nectar","orbit","pine","quartz","river","sunset","timber","violet","willow","zephyr"],u=["!","@","#","$"],d=e=>e[Math.floor(Math.random()*e.length)],h=()=>{let e=d(c),t=d(c);for(;t===e;)t=d(c);let a=String(Math.floor(90*Math.random())+10),s=d(u);return"".concat(e,"-").concat(t).concat(a).concat(s)};var m=!0;function p(e){let{user:t}=e,a=(0,r.useRouter)(),[i,c]=(0,n.useState)(""),[u,d]=(0,n.useState)(""),[m,p]=(0,n.useState)("sales_user"),[x,b]=(0,n.useState)(""),[j,f]=(0,n.useState)(!1),[w,N]=(0,n.useState)(!0),[v,y]=(0,n.useState)(""),[g,_]=(0,n.useState)(!1),[S,C]=(0,n.useState)(""),k=async()=>{if(x)try{await navigator.clipboard.writeText(x),C("Password copied.")}catch(e){C("Could not copy password.")}},P=async e=>{e.preventDefault(),y(""),_(!0);try{let e=await fetch("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i,email:u,role:m,password:x,isActive:w})}),t=await e.json().catch(()=>({}));if(!e.ok){y(t.error||"Failed to create user."),_(!1);return}a.push("/admin/users")}catch(e){y("Failed to create user. Please try again."),_(!1)}};return(0,s.jsx)(l.L3,{user:t,title:"New User",children:(0,s.jsxs)("form",{className:o().form,onSubmit:P,children:[v&&(0,s.jsx)("p",{className:o().error,children:v}),(0,s.jsxs)("div",{className:o().field,children:[(0,s.jsx)("label",{htmlFor:"name",children:"Name"}),(0,s.jsx)("input",{id:"name",value:i,onChange:e=>c(e.target.value),required:!0})]}),(0,s.jsxs)("div",{className:o().field,children:[(0,s.jsx)("label",{htmlFor:"email",children:"Email"}),(0,s.jsx)("input",{id:"email",type:"email",value:u,onChange:e=>d(e.target.value),required:!0})]}),(0,s.jsxs)("div",{className:o().field,children:[(0,s.jsx)("label",{htmlFor:"role",children:"Role"}),(0,s.jsxs)("select",{id:"role",value:m,onChange:e=>p(e.target.value),children:[(0,s.jsx)("option",{value:"admin",children:"admin"}),(0,s.jsx)("option",{value:"sales_user",children:"sales_user"})]})]}),(0,s.jsxs)("div",{className:o().field,children:[(0,s.jsx)("label",{htmlFor:"password",children:"Initial Password"}),(0,s.jsx)("input",{id:"password",type:j?"text":"password",value:x,onChange:e=>{b(e.target.value),C("")},required:!0,minLength:10}),(0,s.jsxs)("div",{className:o().inlineActions,children:[(0,s.jsx)("button",{className:o().secondaryButton,type:"button",onClick:()=>{b(h()),f(!0),C("")},children:"Generate Easy Password"}),(0,s.jsx)("button",{className:o().ghostButton,type:"button",onClick:()=>f(e=>!e),children:j?"Hide":"Show"}),(0,s.jsx)("button",{className:o().ghostButton,type:"button",onClick:k,disabled:!x,children:"Copy"})]}),(0,s.jsx)("p",{className:o().helper,children:"Minimum 10 characters."}),S?(0,s.jsx)("p",{className:o().helper,children:S}):null]}),(0,s.jsxs)("label",{className:o().checkboxRow,children:[(0,s.jsx)("input",{type:"checkbox",checked:w,onChange:e=>N(e.target.checked)}),(0,s.jsx)("span",{children:"Active"})]}),(0,s.jsx)("button",{className:o().button,type:"submit",disabled:g,children:g?"Creating...":"Create User"})]})})}p.noLayout=!0}},function(e){e.O(0,[774,888,179],function(){return e(e.s=2910)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.