import{b as x,a as h,b0 as b,j as t,ec as f,ed as g}from"./index-d2b25495.js";import{o as j}from"./yup-267e586f.js";import{T as A}from"./TextArea-7e39a6e1.js";import{C as I}from"./Modal-ad83750a.js";import{u as S}from"./index.esm-ce3c2c20.js";import{c as v,b as T}from"./index.esm-3043d6d4.js";const P=({isOpen:n,hide:o})=>{const s=x(),{selectedData:e,pageParams:r,loading:i}=h(a=>b(a)),d=v().shape({name:T().trim().required("Please enter your name").min(1,"Name cannot be just spaces")}),{control:c,handleSubmit:p,reset:l}=S({resolver:j(d),values:{name:e.name}}),u=a=>{const m={name:a.name};e.id?s(g({id:e.id,data:m,params:r,hide:o})):s(f({data:m,params:r,hide:o})),l()};return t.jsx(t.Fragment,{children:t.jsx(I,{isOpen:n,title:(e==null?void 0:e.id)==null?"Add Item":"Edit Item",onClose:()=>{o()},onOK:p(u,a=>{console.log("errors",a)}),okText:"Save",closeText:"",loading:i,showFooter:!0,children:t.jsx("form",{style:{width:"100%"},children:t.jsx(A,{control:c,label:"",name:"name",maxRows:0,placeholder:"Enter item description here...",containerSx:{display:"grid",gap:1}})})})})};export{P as A};
