import{g as m,E as f,k as j,l as e,J as N,v as g,y as v,z as w,A as C,w as b,B as h,j as y}from"./index-BmXZZy9z.js";import{I as i}from"./input-DH23RnbD.js";import{L as l}from"./label-BYInJiQO.js";import{U as u}from"./user-plus-XWauJPoD.js";const D=()=>{const[s,n]=m.useState({email:"",password:"",firstName:"",lastName:""}),[d,c]=m.useState(!1),x=f(),{toast:o}=j(),p=async t=>{t.preventDefault(),c(!0);try{const a=await y.adminManageUsers("create",{userData:s});if(a.error)throw new Error(a.error);if(a.data.success)o({title:"Success",description:`Admin user created successfully for ${a.data.email}`}),n({email:"",password:"",firstName:"",lastName:""});else throw new Error(a.data.error||"Failed to create admin user")}catch(a){o({title:"Error",description:a instanceof Error?a.message:"Failed to create admin user",variant:"destructive"})}finally{c(!1)}},r=t=>{n({...s,[t.target.name]:t.target.value})};return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"container mx-auto p-6 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center justify-center mb-8",children:[e.jsx("div",{className:"bg-gradient-to-r from-flashcore-purple to-flashcore-green p-3 rounded-full",children:e.jsx(N,{className:"w-8 h-8 text-white"})}),e.jsx("h1",{className:"ml-4 text-3xl font-bold bg-gradient-to-r from-flashcore-purple via-flashcore-green to-flashcore-orange bg-clip-text text-transparent",children:"FlashCore Admin"})]}),e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsxs(w,{className:"flex items-center",children:[e.jsx(u,{className:"w-5 h-5 mr-2"}),"Create Administrator"]}),e.jsx(C,{children:"Create a new administrator account with full system access"})]}),e.jsx(b,{children:e.jsxs("form",{onSubmit:p,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"firstName",children:"First Name"}),e.jsx(i,{id:"firstName",name:"firstName",value:s.firstName,onChange:r,placeholder:"Admin",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"lastName",children:"Last Name"}),e.jsx(i,{id:"lastName",name:"lastName",value:s.lastName,onChange:r,placeholder:"User",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"email",children:"Email Address"}),e.jsx(i,{id:"email",name:"email",type:"email",value:s.email,onChange:r,placeholder:"admin@flashcore.com",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"password",children:"Password"}),e.jsx(i,{id:"password",name:"password",type:"password",value:s.password,onChange:r,placeholder:"Secure password",required:!0})]}),e.jsxs("div",{className:"flex items-center space-x-4 pt-4",children:[e.jsx(h,{type:"submit",disabled:d,className:"flex-1",children:d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-t-transparent border-white rounded-full animate-spin mr-2"}),"Creating Admin..."]}):e.jsxs(e.Fragment,{children:[e.jsx(u,{className:"w-4 h-4 mr-2"}),"Create Administrator"]})}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>x("/admin"),children:"Back to Dashboard"})]})]})})]})]})})};export{D as default};
