import{d as g,a as v,b as F,oR as C,r as T,j as r,I as k,aK as w,R as x,oS as A,m$ as d,oT as S}from"./index-e6164346.js";import{c as D,b as h,u as E,C as P}from"./index.esm-0a041314.js";import{o as q}from"./yup-5fd5d57b.js";import"./GenericThumbnailView-80c6fd98.js";import{F as N}from"./FormInput-859198ec.js";import"./componentStyles-00385170.js";import"./ScrollableList-5a17e8f4.js";import"./TextArea-f5c200de.js";import{D as B}from"./Dialog-2e8a8e2e.js";import{D as L}from"./DialogTitle-8757f50f.js";import{D as R}from"./DialogContent-f10d6731.js";import{D as $}from"./DialogContentText-027be15d.js";import{G}from"./Grid2-c9c87842.js";import{I as K,a as O}from"./TextField-db9cff08.js";import{O as U}from"./Select-9c2d8cd2.js";import{D as V}from"./DialogActions-31bec80e.js";const mr=({modal:l,closeModal:n,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 s={obj:{name:t.name,tax:t.tax},pageParams:c,clearDataFn:()=>{},navigate:i=>{}};m(A(s)),n(),m(d({})),p()}else{const s={obj:{id:o,name:t.name,tax:t.tax},pageParams:c,clearDataFn:()=>{},navigate:i=>{}};m(S(s)),n(),m(d({})),p()}};return r.jsx(r.Fragment,{children:r.jsxs(B,{open:l,onClose:(t,a)=>{a!=="backdropClick"&&n()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[r.jsxs(L,{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:n,children:r.jsx(w,{color:"white"})})]}),r.jsx(R,{sx:{px:"24px",pt:"12px !important",pb:0},children:r.jsx($,{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 s;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(U,{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()}}}),((s=a.error)==null?void 0:s.message)&&r.jsx(O,{error:a.error!=null,children:"Please enter tax number"})]})}})}),r.jsxs(V,{sx:{p:2},children:[r.jsx(x,{onClick:n,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{mr as A};
