import{aj as C,aC as g,al as N,bL as S,u as v,bq as w,az as y,aA as B,r as E,s as K,j as e,B as s,aX as q,m as z,aM as D,as as o,Z as i,b8 as L,b9 as V,aJ as $,Q as A,aG as m}from"./index-dP1W1_bd.js";import{i as I}from"./index-D4-3j93o.js";const M=C().shape({subjectName:g.required().label("Kafka name"),schema:N().required().label("Schema")}),Z=()=>{const n=S(),{id:d}=v(),{state:a={}}=w(),{register:x,control:u,formState:{errors:h},handleSubmit:j}=y({resolver:B(M),defaultValues:{subjectName:(a==null?void 0:a.subjectName)??"",schema:"[]"}}),[b,{isLoading:p,isError:f,error:r}]=I(),c=E.useCallback(()=>n(K.project.settings.kafka.view),[n]),k=async({subjectName:t,schema:l})=>{await b({id:d,subjectName:t,data:{schema:l}}).unwrap(),c()};return e.jsxs(s,{flexDirection:"column",children:[e.jsx(q,{mr:"auto",mode:"highlight",onClick:c,children:"<- back to all Kafka Topics"}),e.jsx(z,{my:"20px",title:"Create a new Kafka schema",children:e.jsxs(s,{flexDirection:"column",sx:{gap:"20px"},children:[e.jsx(D,{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(V,{name:"schema",control:u,render:({field:{value:t,onChange:l}})=>e.jsx($,{height:"300px",mode:"json",label:"avro schema",value:t,readOnly:!1,onChange:l})})}),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(A,{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{Z as default};
