import{b as x,a as h,b0 as b,j as t,e9 as f,ea as g}from"./index-def636a4.js";import{o as j}from"./yup-c8535458.js";import{T as A}from"./TextArea-6c103c50.js";import{C as I}from"./Modal-db9e186b.js";import{u as S}from"./index.esm-7d9d1491.js";import{c as v,b as T}from"./index.esm-eec4f448.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};
