import{b as g,a as v,g as F,k7 as C,r as k,j as r,I as A,ef as T,P as w,J as x,k8 as P,jf as h,k9 as S}from"./index-d2b25495.js";import{u as D,C as E}from"./index.esm-ce3c2c20.js";import{c as q,b as d}from"./index.esm-3043d6d4.js";import{o as N}from"./yup-267e586f.js";import"./componentStyles-0e851d91.js";import{F as B}from"./FormInput-d202e905.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import{D as L,a as $}from"./DialogContent-cded694d.js";import{D as z}from"./DialogTitle-a145b392.js";import{D as O}from"./DialogContentText-43575e44.js";import{I as U,F as V}from"./InputLabel-bb6ab40e.js";import{O as G}from"./OutlinedInput-86f3ec98.js";import{D as H}from"./DialogActions-7c802cc8.js";const nr=({modal:p,closeModal:n,mastersName:j,edit_Id:a,mastersValue:I,updateData:J})=>{const m=g(),{tax:{selectedData:e,pageParams:c},system:{userAccessList:K}}=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}=D({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(P(s)),n(),m(h({})),l()}else{const s={obj:{id:a,name:t.name,tax:t.tax},pageParams:c,clearDataFn:()=>{},navigate:i=>{}};m(S(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(O,{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(E,{name:"tax",control:u,defaultValue:"",render:({field:t,fieldState:o})=>{var s;return r.jsxs(r.Fragment,{children:[r.jsx(U,{htmlFor:"tax",style:{fontWeight:"medium"},required:!0,error:o.error!=null,children:"Tax Number"}),r.jsx(G,{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(V,{error:o.error!=null,children:"Please enter tax number"})]})}})}),r.jsxs(H,{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};
