import{d as g,a as v,b as F,nM as C,r as T,j as r,I as k,ax as w,z as x,nN as A,lO as d,nO as S}from"./index-d895656a.js";import{c as D,b as h,u as E,C as N}from"./index.esm-1087b2f3.js";import{o as P}from"./yup-9573aa79.js";import"./GenericThumbnailView-532ea2d7.js";import{F as q}from"./FormInput-9b5da280.js";import"./componentStyles-866300fe.js";import"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{D as O,a as B}from"./DialogContent-4ce43512.js";import{D as L}from"./DialogTitle-738ca272.js";import{D as z}from"./DialogContentText-8b9b0e0c.js";import{G}from"./Grid2-5bd460ea.js";import{I as U,a as V}from"./TextField-6f73e19a.js";import{O as $}from"./Select-6d425a72.js";import{D as H}from"./DialogActions-7b82f6f6.js";const ir=({modal:p,closeModal:s,mastersName:b,edit_Id:o,mastersValue:I,updateData:K})=>{const m=g(),{tax:{selectedData:e,pageParams:c},system:{userAccessList:R}}=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(()=>{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:P(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({})),l()}else{const n={obj:{id:o,name:t.name,tax:t.tax},pageParams:c,clearDataFn:()=>{},navigate:i=>{}};m(S(n)),s(),m(d({})),l()}};return r.jsx(r.Fragment,{children:r.jsxs(O,{open:p,onClose:(t,a)=>{a!=="backdropClick"&&s()},"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:s,children:r.jsx(w,{color:"white"})})]}),r.jsx(B,{sx:{px:"24px",pt:"12px !important",pb:0},children:r.jsx(z,{id:"alert-dialog-description",sx:{width:500},children:r.jsxs("form",{style:{width:"100%"},onSubmit:y(f),children:[r.jsx(q,{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(N,{name:"tax",control:u,defaultValue:"",render:({field:t,fieldState:a})=>{var n;return r.jsxs(r.Fragment,{children:[r.jsx(U,{htmlFor:"tax",style:{fontWeight:"medium"},required:!0,error:a.error!=null,children:"Tax Number"}),r.jsx($,{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(V,{error:a.error!=null,children:"Please enter tax number"})]})}})}),r.jsxs(H,{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};
