import{d as g,a as v,b as F,oT as C,r as T,j as r,I as k,aK as w,R as x,oU as A,n1 as d,oV as S}from"./index-5ae5cc5e.js";import{c as D,b as h,u as E,C as P}from"./index.esm-bd37e938.js";import{o as q}from"./yup-86a48159.js";import"./GenericThumbnailView-fac7773c.js";import{F as N}from"./FormInput-77541d96.js";import"./componentStyles-7d84c389.js";import"./ScrollableList-2ee889f8.js";import"./TextArea-20f097f8.js";import{D as B,a as L}from"./DialogContent-e2578cbd.js";import{D as U}from"./DialogTitle-4a5aec12.js";import{D as V}from"./DialogContentText-bc10bf8d.js";import{G}from"./Grid2-48c222cb.js";import{I as K,a as O}from"./TextField-013fef4f.js";import{O as R}from"./Select-6f375e89.js";import{D as $}from"./DialogActions-ad26e3d6.js";const ir=({modal:l,closeModal:s,mastersName:b,edit_Id:o,mastersValue:z,updateData:H})=>{const m=g(),{tax:{selectedData:e,pageParams:c},system:{userAccessList:I}}=v(t=>({system:F(t),tax:C(t)})),j=D().shape({name:h().required("Please enter your tax name").trim(),tax:h().required("Please enter your tax number")});T.useEffect(()=>{l?p({name:(e==null?void 0:e.name)||"",tax:(e==null?void 0:e.tax)||""}):p()},[l,e]);const{control:u,handleSubmit:y,reset:p}=E({resolver:q(j),values:{name:e!=null&&e.name?e==null?void 0:e.name:"",tax:e!=null&&e.tax?e==null?void 0:e.tax:""}}),f=t=>{if(o==null||o==0){const n={obj:{name:t.name,tax:t.tax},pageParams:c,clearDataFn:()=>{},navigate:i=>{}};m(A(n)),s(),m(d({})),p()}else{const n={obj:{id:o,name:t.name,tax:t.tax},pageParams:c,clearDataFn:()=>{},navigate:i=>{}};m(S(n)),s(),m(d({})),p()}};return r.jsx(r.Fragment,{children:r.jsxs(B,{open:l,onClose:(t,a)=>{a!=="backdropClick"&&s()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[r.jsxs(U,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[o==null||o==0?"Add ":"Update ",b,r.jsx(k,{onClick:s,children:r.jsx(w,{color:"white"})})]}),r.jsx(L,{sx:{px:"24px",pt:"12px !important",pb:0},children:r.jsx(V,{id:"alert-dialog-description",sx:{width:500},children:r.jsxs("form",{style:{width:"100%"},onSubmit:y(f),children:[r.jsx(N,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Name here...",control:u}),r.jsx(G,{size:{xs:12,md:4},mt:2,children:r.jsx(P,{name:"tax",control:u,defaultValue:"",render:({field:t,fieldState:a})=>{var n;return r.jsxs(r.Fragment,{children:[r.jsx(K,{htmlFor:"tax",style:{fontWeight:"medium"},required:!0,error:a.error!=null,children:"Tax Number"}),r.jsx(R,{id:"tax",...t,type:"text",placeholder:"Enter Tax Number",sx:{width:"100%",mt:1},error:a.error!=null,inputProps:{style:{padding:"10px 12px"},onKeyDown:i=>{!/[0-9]/.test(i.key)&&i.key!=="Backspace"&&i.preventDefault()}}}),((n=a.error)==null?void 0:n.message)&&r.jsx(O,{error:a.error!=null,children:"Please enter tax number"})]})}})}),r.jsxs($,{sx:{p:2},children:[r.jsx(x,{onClick:s,variant:"outlined",color:"secondary",children:"Cancel"}),o==null||o==0?r.jsx(x,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):r.jsx(x,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{ir as A};
