import{a7 as g,ai as C,a9 as N,b1 as S,u as y,c9 as K,am as v,an as w,r as D,e as E,j as e,a as s,hp as L,K as P,aG as V,af as l,Z as i,ax as q,ay as z,cV as B,f as I,aT as m}from"./index-d6499a22.js";import{i as T}from"./index-0e1d5e0b.js";const Z=g().shape({subjectName:C.required().label("Kafka name"),schema:N().required().label("Schema")}),G=()=>{const o=S(),{id:d}=y(),{state:a={}}=K(),{register:x,control:h,formState:{errors:u},handleSubmit:j}=v({resolver:w(Z),defaultValues:{subjectName:(a==null?void 0:a.subjectName)??"",schema:"[]"}}),[f,{isLoading:b,isError:p,error:r}]=T(),c=D.useCallback(()=>o(E.project.settings.kafka.view),[o]),k=async({subjectName:t,schema:n})=>{await f({id:d,subjectName:t,data:{schema:n}}).unwrap(),c()};return e.jsxs(s,{flexDirection:"column",children:[e.jsx(L,{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(V,{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"),...q("subjectName",u)}),e.jsx(s,{mb:"20px",children:e.jsx(z,{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})})}),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(I,{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:b,onClick:j(k),children:"Create Schema"})]})]})})]})};export{G as default};
