import{j as e,p as C,c as S,S as p,M as f}from"./vendor-mui-CBBEb17G.js";import{a as x,u as b}from"./vendor-react-BBazpZul.js";import{aO as v,v as w,by as c,aP as d,x as N,J as T,gG as k,R as m,I as u}from"./index-IP_FWtso.js";import"./vendor-utils-BveVE6Uf.js";import"./vendor-charts-tGnAgELZ.js";const A=({icon:r,onClick:i,title:s})=>e.jsxs(C,{className:"flex items-center gap-2 p-4 w-full rounded-lg !bg-slate-300 shadow-2xl shadow-slate-700 cursor-pointer hover:-translate-y-1 ease-in-out",onClick:i,children:[r,s]}),K=({onClose:r})=>{const{TaxUpdateInfoAsync:i,GetTaxInfoAsync:s}=k(),{control:a,handleSubmit:o,reset:y,formState:{errors:n}}=v({defaultValues:{memoryId:"",economyCode:"",privateKey:"",certificate:""}}),[j,l]=x.useState(!1),h=async()=>{try{l(!0);const{data:t}=await s();t&&y({memoryId:t.memoryId??"",economyCode:t.economyCode??"",privateKey:t.privateKey??"",certificate:t.certificate??""})}finally{l(!1)}},g=async t=>{try{if(l(!0),!t)return;const{message:I}=await i(t);T.success(I),r()}finally{l(!1)}};return x.useEffect(()=>{h()},[]),e.jsxs(w,{onClose:r,title:"اطلاعات مالیاتی مرکز",maxWidth:"xs",isFixWidth:!0,children:[e.jsx(S,{className:"m-1 !p-2",children:e.jsxs(p,{spacing:2,p:1,component:"form",children:[e.jsx(c,{name:"memoryId",control:a,rules:{required:!0},render:({field:t})=>e.jsx(d,{...t,label:"شناسه حافظه مالیاتی",fullWidth:!0,error:!!n.memoryId})}),e.jsx(c,{name:"economyCode",control:a,rules:{required:!0},render:({field:t})=>e.jsx(d,{...t,label:"کد اقتصادی",fullWidth:!0,error:!!n.economyCode})}),e.jsx(c,{name:"privateKey",control:a,rules:{required:!0},render:({field:t})=>e.jsx(d,{...t,label:"کلید خصوصی",fullWidth:!0,error:!!n.privateKey})}),e.jsx(c,{name:"certificate",control:a,rules:{required:!0},render:({field:t})=>e.jsx(d,{...t,label:"گواهی امضاء",fullWidth:!0,error:!!n.certificate})})]})}),e.jsx(N,{onClose:r,onSubmit:o(g),loading:j})]})},M=()=>{const r=b(),[i,s]=x.useState(!1),a=[{id:1,title:"لیست مالیات",icon:e.jsx(u.List,{color:"primary"}),onClick:()=>r(`/${m.tax.TaxList}`)},{id:2,title:"اطلاعات مالیاتی مرکز",icon:e.jsx(u.InfoIcon,{color:"primary"}),onClick:()=>s(!0)},{id:3,title:"ارسال فاکتور به سامانه مودیان",icon:e.jsx(u.Send,{color:"primary"}),onClick:()=>r(`/${m.tax.SendInvoice}`)},{id:4,title:"اقلام مالیاتی",icon:e.jsx(u.MedicalServices,{color:"primary"}),onClick:()=>r(`/${m.tax.TaxProducts}`)}];return e.jsxs(p,{spacing:2,className:"h-full p-2 px-4 bg-white",children:[e.jsx("h1",{className:"flex justify-center items-center w-full p-2 py-10 text-2xl  text-slate-50 bg-[#056586] shadow-2xl rounded-lg",children:"مدیریت امور مالیاتی مرکز"}),e.jsx(f,{container:!0,spacing:2,className:"h-full overflow-auto",children:a.map(o=>e.jsx(f,{item:!0,xs:12,sm:6,md:3,children:e.jsx(A,{title:o.title,icon:o.icon,onClick:o.onClick})},o.id))}),i&&e.jsx(K,{onClose:()=>s(!1)})]})};export{M as default};
