import{aA as n,j as e,G as p,az as x,ax as g,a9 as d,aT as h,k as j,l as b,E as C}from"./app-BgLa5dit.js";import{M as f}from"./DwzYo0zp.chunk.js";import{F as S}from"./DKIaDplE.chunk.js";import{M as N}from"./DJkz-8BP.chunk.js";function q({closePopup:r,onSubmit:l,showSpinner:s}){const c=n.object().shape({region:n.string().required("Region is required"),catalogName:n.string().matches(/^[a-z0-9]+(_[a-z0-9]+)*$/,"Catalog name must be in lower snake case format.").required("Catalog name is required"),catalogDescription:n.string().required("Catalog name must be in lower_snake_case format")}),i=N.getAllRegions();return e.jsx(p,{initialValues:{catalogName:"",catalogDescription:"",region:""},validationSchema:c,onSubmit:a=>{const t={name:a.catalogName,description:a.catalogDescription,fields:[{name:"id",type:S.Text}]};l(t,a.region)},children:({values:a,handleChange:t,handleBlur:o,handleSubmit:u})=>e.jsxs(x,{onSubmit:u,children:[e.jsxs("div",{children:[e.jsx("div",{className:"mb-3",children:e.jsxs(g,{name:"region",label:"Region",as:"select",value:a.region,onChange:t,onBlur:o,showRequiredStar:!a.region,children:[e.jsx("option",{disabled:!0,value:"",children:"Select Region"}),i.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))]})}),e.jsx("div",{className:"mb-3",children:e.jsx(g,{name:"catalogName",label:"Catalog Name",type:"text",placeholder:"Enter the catalog name",value:a.catalogName,onChange:t,onBlur:o,showRequiredStar:!a.catalogName})}),e.jsx("div",{className:"mb-3",children:e.jsx(g,{name:"catalogDescription",label:"Catalog Description",as:"textarea",placeholder:"Enter catalog description",value:a.catalogDescription,onChange:t,onBlur:o,showRequiredStar:!a.catalogDescription})})]}),e.jsxs(d,{className:"mt-2",children:[e.jsx(d.Cancel,{onClick:r}),e.jsx(d.Submit,{showSpinner:s,variant:"dark",text:"Create catalog",disabled:s})]})]})})}function w({closePopup:r}){const[l,s]=h.useState(!1),c=j(),i=b();async function a(t,o){s(!0),c(f.createCatalog(t,o)).then(()=>i.success(`Successfully created catalog: ${t.name}`)).catch(()=>i.error(`Failed to create catalog: ${t.name}. Please try again.`)).finally(r)}return e.jsx(C,{title:"Create Catalog",closePopup:r,backdrop:"static",children:e.jsx(q,{closePopup:r,onSubmit:a,showSpinner:l})})}export{w as CreateCatalogView};
//# sourceMappingURL=C-h7qdF9.chunk.js.map
