1import{o as i,n as m,b as u,y as d,a2 as p,j as e,B as h,L as x,ac as g}from"./index-BNSlZW3b.js";import{b as j,F as w,a as v,c as N}from"./field-ChXsvxn4.js";import{u as b}from"./form-CxHDHTlK.js";import{A as f}from"./arrow-left-C9Dss__s.js";import"./form-submit-button-QNy0gx7W.js";import"./useForm-DCj-pjeq.js";import"./loading-button-CdiLx1vU.js";function z(){const c=i(),{data:l}=m(),[n,r]=u.useState(null),s=b({defaultValues:{name:""},onSubmit:async({value:a})=>{r(null);try{const t=a.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),{error:o}=await d.organization.create({name:a.name,slug:`${t}-${Date.now()}`});if(o){r(o.message||"Failed to create workspace");return}await p(),c({to:"/inbox/{-$conversationId}"})}catch{r("An unexpected error occurred")}}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"-ml-2",children:e.jsxs(x,{to:"/",children:[e.jsx(f,{className:"size-4"}),"Back"]})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Create a new workspace"}),e.jsxs("p",{className:"text-muted-foreground",children:["Create a new workspace with"," ",e.jsx("span",{className:"font-medium text-foreground",children:l?.user?.email})]})]}),e.jsx(s.AppForm,{children:e.jsxs("form",{onSubmit:a=>{a.preventDefault(),a.stopPropagation(),s.handleSubmit()},className:"space-y-5",children:[e.jsx(j,{children:e.jsx(s.Field,{name:"name",children:a=>e.jsxs(w,{children:[e.jsx(v,{htmlFor:a.name,children:"Company name"}),e.jsx(g,{id:a.name,name:a.name,placeholder:"Acme Corp",value:a.state.value,onBlur:a.handleBlur,onChange:t=>a.handleChange(t.target.value),className:"bg-card h-11"}),a.state.meta.errors?.length?e.jsx(N,{children:a.state.meta.errors.join(", ")}):null]})})}),n&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:n}),e.jsx(s.FormSubmitButton,{size:"lg",className:"w-full rounded-full",children:"Create workspace"})]})})]})}export{z as component};
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.