import{ae as g,ax as C,ag as N,bg as S,u as v,aY as w,au as y,av as D,r as E,q as K,j as e,d as s,f_ as V,Q as q,aR as P,an as l,T as i,aE as T,aF as z,aX as B,p as F,b6 as m}from"./index-CK33qGU_.js";import{i as I}from"./index-CBcuRugC.js";const L=g().shape({subjectName:C.required().label("Kafka name"),schema:N().required().label("Schema")}),_=()=>{const o=S(),{id:d}=v(),{state:a={}}=w(),{register:x,control:u,formState:{errors:h},handleSubmit:j}=y({resolver:D(L),defaultValues:{subjectName:(a==null?void 0:a.subjectName)??"",schema:"[]"}}),[b,{isLoading:p,isError:f,error:r}]=I(),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(V,{mr:"auto",mode:"highlight",onClick:c,children:"<- back to all Kafka Topics"}),e.jsx(q,{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"),...T("subjectName",h)}),e.jsx(s,{mb:"20px",children:e.jsx(z,{name:"schema",control:u,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(F,{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{_ as default};
