import{j as e,G as g,az as S,ax as x,a9 as u,aT as C,l as k,k as F,o as y,E}from"./app-BgLa5dit.js";import{M as m}from"./DwzYo0zp.chunk.js";function B(t,s){return t==="number"?Number(s):t==="boolean"?!!s:String(s)}function A({name:t,type:s,currentValue:a,showSpinner:o,closePopup:n,onSubmit:c}){return e.jsx(g,{initialValues:{[t]:a||""},onSubmit:l=>c(B(s,l[t])),children:({values:l,handleChange:r,handleBlur:i})=>e.jsxs(S,{className:"tw-d-flex tw-flex-column tw-gap-2 tw-w-full",children:[s==="boolean"?e.jsx(x,{id:t,name:t,label:t,type:"checkbox",checked:!!l[t],onChange:r,onBlur:i,className:"w-100"}):e.jsx(x,{id:t,name:t,label:t,type:s,value:String(l[t]),onChange:r,onBlur:i,placeholder:s,className:"w-100"}),e.jsxs("p",{className:"mt-2",children:["Are you sure you want to update the cell at column ",e.jsx("b",{children:t})," with value ",e.jsx("b",{className:"text-break",children:a})]}),e.jsx("p",{children:"This will update the catalog and cannot be undone."}),e.jsxs(u,{children:[e.jsx(u.Cancel,{onClick:n}),e.jsx(u.Submit,{showSpinner:o,variant:"dark",text:"Update",disabled:o})]})]})})}function I({catalogName:t,currentValue:s,closePopup:a,region:o,fieldName:n,fieldType:c,id:l}){const[r,i]=C.useState(!1),d=k(),p=F(),b=y(m.getCatalogItems(t,o)).data;async function j(w){i(!0);const h=b.find(f=>f.id===l);h[n]=w,p(m.updateCatalog(t,o,[h])).then(()=>d.success(`Successfully updated the cell at ${n}`)).catch(()=>d.error(`Something went wrong while updating the cell at ${n}. Please try again.`)).finally(a)}return e.jsx(E,{title:"Edit Cell",closePopup:a,children:e.jsx(A,{name:n,type:c,currentValue:s,showSpinner:r,closePopup:a,onSubmit:j})})}export{I as EditCatalogView};
//# sourceMappingURL=CELxv-xZ.chunk.js.map
