import{b9 as g,u as C,bg as N,aC as S,aD as y,ar as v,r as w,t as D,j as e,a as s,gS as E,W as I,aH as K,aY as W,ap as l,d as i,aZ as q,aI as z,f as B,aJ as m,au as H,aE as J}from"./index-_eM6l4Nf.js";import{i as L}from"./index-CmVntchS.js";const P=v().shape({subjectName:J.required().label("Kafka name"),schema:H().required().label("Schema")}),$=()=>{const o=g(),{id:d}=C(),{state:a={}}=N(),{register:x,control:u,formState:{errors:h},handleSubmit:j}=S({resolver:y(P),defaultValues:{subjectName:(a==null?void 0:a.subjectName)??"",schema:"[]"}}),[b,{isLoading:f,isError:p,error:r}]=L(),c=w.useCallback(()=>o(D.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(E,{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(K,{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"),...W("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})})}),p&&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(B,{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:f,onClick:j(k),children:"Create Schema"})]})]})})]})};export{$ as default};
