import{a7 as g,aj as C,a9 as N,b2 as S,u as y,ca as z,an as v,ao as w,r as E,b as K,j as e,Q as s,hp as D,E as I,aH as P,ag as l,z as i,ay as V,az as q,cY as B,g as H,aU as m}from"./index-ea7817a2.js";import{i as L}from"./index-b96fda11.js";const Q=g().shape({subjectName:C.required().label("Kafka name"),schema:N().required().label("Schema")}),M=()=>{const o=S(),{id:d}=y(),{state:a={}}=z(),{register:x,control:h,formState:{errors:u},handleSubmit:j}=v({resolver:w(Q),defaultValues:{subjectName:(a==null?void 0:a.subjectName)??"",schema:"[]"}}),[b,{isLoading:p,isError:f,error:r}]=L(),c=E.useCallback(()=>o(K.project.settings.kafka.view),[o]),k=async({subjectName:t,schema:n})=>{await b({id:d,subjectName:t,data:{schema:n}}).unwrap(),c()};return e.jsxs(s,{flexDirection:"column",children:[e.jsx(D,{mr:"auto",mode:"highlight",onClick:c,children:"<- back to all Kafka Topics"}),e.jsx(I,{my:"20px",title:"Create a new Kafka schema",children:e.jsxs(s,{flexDirection:"column",sx:{gap:"20px"},children:[e.jsx(P,{label:"Name",placeholder:"kafka schema name",disabled:!!(a!=null&&a.subjectName),labelAction:e.jsx(l,{size:"xs",ml:"8px",icon:i.info_block}),...x("subjectName"),...V("subjectName",u)}),e.jsx(s,{mb:"20px",children:e.jsx(q,{name:"schema",control:h,render:({field:{value:t,onChange:n}})=>e.jsx(B,{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(l,{mr:"5px",size:"sm",color:"labels.red",icon:i.error}),e.jsx(H,{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:j(k),children:"Create Schema"})]})]})})]})};export{M as default};
