import{aA as m,j as e,G as p,az as x,ax as f,a9 as u,aT as F,k as h,l as j,E as y}from"./app-BgLa5dit.js";import{M as b}from"./DwzYo0zp.chunk.js";import{F as S}from"./DKIaDplE.chunk.js";function T({closePopup:a,onSubmit:t,showSpinner:l}){const n=Object.values(S),d=m.object().shape({fieldName:m.string().matches(/^[a-z0-9]+(_[a-z0-9]+)*$/,"Field name must be in lower_snake_case format").required("Field name is required"),fieldType:m.string().required("Field type is required")});return e.jsx(p,{initialValues:{fieldName:"",fieldType:""},validationSchema:d,onSubmit:i=>{const s=[{name:i.fieldName,type:i.fieldType}];t(s)},children:({values:i,handleChange:s,handleBlur:r,handleSubmit:c})=>e.jsxs(x,{onSubmit:c,children:[e.jsxs("div",{children:[e.jsx("div",{className:"mb-3",children:e.jsx(f,{name:"fieldName",label:"Field Name",type:"text",placeholder:"Field Name",value:i.fieldName,onChange:s,onBlur:r})}),e.jsx("div",{className:"mb-3",children:e.jsxs(f,{name:"fieldType",label:"Field Type",as:"select",value:i.fieldType,onChange:s,onBlur:r,children:[e.jsx("option",{value:"",disabled:!0,children:"Select Field Type"}),n.map(o=>e.jsx("option",{value:o,children:o},o))]})})]}),e.jsxs(u,{className:"mt-2",children:[e.jsx(u.Cancel,{onClick:a}),e.jsx(u.Submit,{showSpinner:l,variant:"dark",text:"Create field",disabled:l})]})]})})}function k({catalogName:a,closePopup:t,region:l}){const[n,d]=F.useState(!1),i=h(),s=j();async function r(c){d(!0),i(b.createField(a,c,l)).then(()=>s.success(`Successfully created fields for: ${a}`)).catch(()=>s.error(`Failed to create fields for: ${a}. Please try again.`)).finally(t)}return e.jsx(y,{title:"Create Field",closePopup:t,backdrop:"static",children:e.jsx(T,{closePopup:t,onSubmit:r,showSpinner:n})})}export{k as CreateFieldView};
//# sourceMappingURL=Bvojwvkj.chunk.js.map
