import{b as g,a as v,h as F,k7 as C,r as k,j as r,I as A,ec as T,Q as w,K as x,k8 as S,ja as h,k9 as D}from"./index-76d4793e.js";import{u as E,C as P}from"./index.esm-3adfd9f7.js";import{c as q,b as d}from"./index.esm-ad8a7c9f.js";import{o as N}from"./yup-688ec4f6.js";import"./componentStyles-0803b39e.js";import{F as B}from"./FormInput-8f40ded1.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import{D as L,a as $}from"./DialogContent-7bd8dd8f.js";import{D as z}from"./DialogTitle-71dd5b3a.js";import{D as K}from"./DialogContentText-7642f81f.js";import{I as O,F as U}from"./InputLabel-5ed57f0e.js";import{O as V}from"./OutlinedInput-ac933786.js";import{D as G}from"./DialogActions-5a5e1db9.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:C(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")});k.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};
