1import{r as c,j as r}from"./react-vendor--USIJqk3.js";import{R as w,q as C,r as S,u as M,i,h as T,l as E,v as R,d as f,e as _}from"./heroui-DeOWmPA8.js";import{u as k}from"./app-CYXrZS1A.js";import{r as P}from"./inertia-CrBlEYtk.js";import{B as q}from"./building-2-BUXeWfPi.js";import"./react-aria-BesmotQ5.js";import"./framer-motion-CUTLOtO_.js";import"./date-fns-CRNnpkn3.js";function K({isOpen:x,onClose:m,plans:h}){const v=k(e=>e.csrfToken),[a,u]=c.useState({team_name:"",owner_email:"",max_seats:"",seat_price:"",plan_id:""}),[l,p]=c.useState(!1),[t,d]=c.useState({}),y=h.filter(e=>e.name==="enterprise"),n=(e,o)=>{u(s=>({...s,[e]:o})),t[e]&&d(s=>{const{[e]:I,...N}=s;return N})},b=()=>{u({team_name:"",owner_email:"",max_seats:"",seat_price:"",plan_id:""}),d({})},j=async e=>{e.preventDefault(),p(!0),d({});try{const o=await fetch(route("admin.teams.store"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-CSRF-TOKEN":v},body:JSON.stringify({team_name:a.team_name,owner_email:a.owner_email,max_seats:Number(a.max_seats),seat_price:Number(a.seat_price),plan_id:Number(a.plan_id)})});if(!o.ok){const s=await o.json();if(s.errors){d(s.errors);return}throw new Error("Failed to create team")}_({title:"Team Created",description:"The team has been created successfully.",color:"success"}),b(),m(),P.reload()}catch{_({title:"Error",description:"Failed to create team. Please try again.",color:"danger"})}finally{p(!1)}},g=()=>{b(),m()};return r.jsx(w,{isOpen:x,onClose:g,size:"md",backdrop:"blur",placement:"center",scrollBehavior:"inside",classNames:{backdrop:"bg-background/90 backdrop-blur-sm",base:"bg-card max-h-[90vh]",wrapper:"items-center"},children:r.jsxs(C,{children:[r.jsxs(S,{className:"flex items-center gap-3 text-foreground",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-md",children:r.jsx(q,{className:"text-primary",size:20})}),r.jsx("span",{children:"Create Team"})]}),r.jsx(M,{children:r.jsxs("form",{id:"create-team-form",onSubmit:j,className:"space-y-4",children:[r.jsx(i,{variant:"bordered",label:"Team Name",placeholder:"Enter team name",isRequired:!0,value:a.team_name,onValueChange:e=>n("team_name",e),isInvalid:!!t.team_name,errorMessage:t.team_name,classNames:{input:"bg-muted !text-foreground border-none focus:border-none active:border-none focus:ring-0 placeholder:text-muted-foreground",inputWrapper:"bg-muted border-none border-opacity-30 focus:border-none active:border-none focus:ring-0",label:"!text-foreground pb-1",errorMessage:"!text-destructive"}}),r.jsx(i,{variant:"bordered",label:"Owner Email",placeholder:"Enter owner email",type:"email",isRequired:!0,value:a.owner_email,onValueChange:e=>n("owner_email",e),isInvalid:!!t.owner_email,errorMessage:t.owner_email,classNames:{input:"bg-muted !text-foreground border-none focus:border-none active:border-none focus:ring-0 placeholder:text-muted-foreground",inputWrapper:"bg-muted border-none border-opacity-30 focus:border-none active:border-none focus:ring-0",label:"!text-foreground pb-1",errorMessage:"!text-destructive"}}),r.jsx(i,{variant:"bordered",label:"Max Seats",placeholder:"Enter max seats",type:"number",isRequired:!0,value:a.max_seats,onValueChange:e=>n("max_seats",e),isInvalid:!!t.max_seats,errorMessage:t.max_seats,classNames:{input:"bg-muted !text-foreground border-none focus:border-none active:border-none focus:ring-0 placeholder:text-muted-foreground",inputWrapper:"bg-muted border-none border-opacity-30 focus:border-none active:border-none focus:ring-0",label:"!text-foreground pb-1",errorMessage:"!text-destructive"}}),r.jsx(i,{variant:"bordered",label:"Seat Price",placeholder:"Enter seat price",type:"number",isRequired:!0,value:a.seat_price,onValueChange:e=>n("seat_price",e),isInvalid:!!t.seat_price,errorMessage:t.seat_price,classNames:{input:"bg-muted !text-foreground border-none focus:border-none active:border-none focus:ring-0 placeholder:text-muted-foreground",inputWrapper:"bg-muted border-none border-opacity-30 focus:border-none active:border-none focus:ring-0",label:"!text-foreground pb-1",errorMessage:"!text-destructive"}}),r.jsx(T,{variant:"bordered",label:"Plan",placeholder:"Select an enterprise plan",isRequired:!0,selectedKeys:a.plan_id?[a.plan_id]:[],onSelectionChange:e=>{const o=Array.from(e)[0];n("plan_id",o||"")},isInvalid:!!t.plan_id,errorMessage:t.plan_id,classNames:{trigger:"bg-muted border-none border-opacity-30 focus:border-none active:border-none focus:ring-0",label:"!text-foreground pb-1",value:"!text-foreground",popoverContent:"bg-muted border-border",errorMessage:"!text-destructive"},children:y.map(e=>r.jsx(E,{classNames:{base:"!text-foreground hover:bg-muted data-[hover=true]:!bg-muted data-[selected=true]:!bg-muted !border-none
1!outline-none capitalize"},children:e.name},String(e.id)))})]})}),r.jsxs(R,{children:[r.jsx(f,{variant:"light",onPress:g,className:"!rounded-md text-foreground",isDisabled:l,children:"Cancel"}),r.jsx(f,{className:"!rounded-md bg-primary text-primary-foreground",type:"submit",form:"create-team-form",isLoading:l,isDisabled:l||!a.team_name.trim()||!a.owner_email.trim()||!a.max_seats||!a.seat_price||!a.plan_id,children:"Create Team"})]})]})})}export{K as default};
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.