import{al as g,aG as C,an as N,bJ as S,u as y,bi as v,aD as w,aE as B,r as D,s as E,j as e,B as s,gP as K,y as P,b5 as I,au as o,C as i,aR as L,aS as q,b6 as z,b as J,b4 as m}from"./index-C1DmWO_C.js";import{i as R}from"./index-CxmfBMSc.js";const V=g().shape({subjectName:C.required().label("Kafka name"),schema:N().required().label("Schema")}),F=()=>{const l=S(),{id:d}=y(),{state:a={}}=v(),{register:x,control:u,formState:{errors:h},handleSubmit:b}=w({resolver:B(V),defaultValues:{subjectName:(a==null?void 0:a.subjectName)??"",schema:"[]"}}),[j,{isLoading:p,isError:f,error:r}]=R(),c=D.useCallback(()=>l(E.project.settings.kafka.view),[l]),k=async({subjectName:t,schema:n})=>{await j({id:d,subjectName:t,data:{schema:n}}).unwrap(),c()};return e.jsxs(s,{flexDirection:"column",children:[e.jsx(K,{mr:"auto",mode:"highlight",onClick:c,children:"<- back to all Kafka Topics"}),e.jsx(P,{my:"20px",title:"Create a new Kafka schema",children:e.jsxs(s,{flexDirection:"column",sx:{gap:"20px"},children:[e.jsx(I,{label:"Name",placeholder:"kafka schema name",disabled:!!(a!=null&&a.subjectName),labelAction:e.jsx(o,{size:"xs",ml:"8px",icon:i.info_block}),...x("subjectName"),...L("subjectName",h)}),e.jsx(s,{mb:"20px",children:e.jsx(q,{name:"schema",control:u,render:({field:{value:t,onChange:n}})=>e.jsx(z,{height:"300px",mode:"json",label:"avro schema",value:t,readOnly:!1,onChange:n})})}),f&&e.jsxs(s,{mt:"-10px",flexDirection:"row",alignItems:"center",children:[e.jsx(o,{mr:"5px",size:"sm",color:"labels.red",icon:i.error}),e.jsx(J,{color:"labels.red",children:r==null?void 0:r.response.data.message})]}),e.jsxs(s,{justifyContent:"flex-end",children:[e.jsx(m,{mr:"8px",intent:"secondary",onClick:c,children:"Back"}),e.jsx(m,{disabled:p,onClick:b(k),children:"Create Schema"})]})]})})]})};export{F as default};
