import{b as g,a as v,h as F,kj as k,r as C,j as r,I as A,ec as T,Q as w,K as x,kk as S,jm as h,kl as D}from"./index-60a3c753.js";import{u as E,C as P}from"./index.esm-c494934a.js";import{c as q,b as d}from"./index.esm-62d6b2f7.js";import{o as N}from"./yup-92678dde.js";import"./componentStyles-7753bbb9.js";import{F as B}from"./FormInput-74e2c4d2.js";/* empty css                   */import"./ScrollableList-1962b023.js";import{D as L,a as $}from"./DialogContent-89e21f2e.js";import{D as z}from"./DialogTitle-fe69da5c.js";import{D as K}from"./DialogContentText-6688bd59.js";import{I as O,F as U}from"./InputLabel-71dfc9d4.js";import{O as V}from"./OutlinedInput-3a884178.js";import{D as G}from"./DialogActions-e754942c.js";const nr=({modal:p,closeModal:n,mastersName:j,edit_Id:a,mastersValue:H,updateData:I})=>{const m=g(),{tax:{selectedData:e,pageParams:c},system:{userAccessList:Q}}=v(t=>({system:F(t),tax:k(t)})),b=q().shape({name:d().required("Please enter your tax name").trim().matches(/^[a-zA-Z0-9 ]*$/,"tax name should not contain special characters"),tax:d().required("Please enter your tax number")});C.useEffect(()=>{p?l({name:(e==null?void 0:e.name)||"",tax:(e==null?void 0:e.tax)||""}):l()},[p,e]);const{control:u,handleSubmit:y,reset:l}=E({resolver:N(b),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(a==null||a==0){const s={obj:{name:t.name,tax:t.tax},pageParams:c,clearDataFn:()=>{},navigate:i=>{}};m(S(s)),n(),m(h({})),l()}else{const s={obj:{id:a,name:t.name,tax:t.tax},pageParams:c,clearDataFn:()=>{},navigate:i=>{}};m(D(s)),n(),m(h({})),l()}};return r.jsx(r.Fragment,{children:r.jsxs(L,{open:p,onClose:n,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[r.jsxs(z,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[a==null||a==0?"Add ":"Update ",j,r.jsx(A,{onClick:n,children:r.jsx(T,{color:"white"})})]}),r.jsx($,{sx:{px:"24px",pt:"12px !important",pb:0},children:r.jsx(K,{id:"alert-dialog-description",sx:{width:500},children:r.jsxs("form",{style:{width:"100%"},onSubmit:y(f),children:[r.jsx(B,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Name here...",control:u}),r.jsx(w,{size:{xs:12,md:4},mt:2,children:r.jsx(P,{name:"tax",control:u,defaultValue:"",render:({field:t,fieldState:o})=>{var s;return r.jsxs(r.Fragment,{children:[r.jsx(O,{htmlFor:"tax",style:{fontWeight:"medium"},required:!0,error:o.error!=null,children:"Tax Number"}),r.jsx(V,{id:"tax",...t,type:"text",placeholder:"Enter Tax Number",sx:{width:"100%",mt:1},error:o.error!=null,inputProps:{style:{padding:"10px 12px"},onKeyDown:i=>{!/[0-9]/.test(i.key)&&i.key!=="Backspace"&&i.preventDefault()}}}),((s=o.error)==null?void 0:s.message)&&r.jsx(U,{error:o.error!=null,children:"Please enter tax number"})]})}})}),r.jsxs(G,{sx:{p:2},children:[r.jsx(x,{onClick:n,variant:"outlined",color:"secondary",children:"Cancel"}),a==null||a==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{nr as A};
