import{j as e,S as u,M as i}from"./vendor-mui-CBBEb17G.js";import{B as I}from"./index-DQbmBtLN.js";import{a as r}from"./vendor-react-BBazpZul.js";import{cF as v,aX as k,z as E,gE as N,al as T,e as w,c$ as J,aP as R,ao as p,I as m}from"./index-DdWwwZXu.js";import{T as D}from"./index-DwtyCRac.js";import"./vendor-utils-BveVE6Uf.js";import"./vendor-charts-tGnAgELZ.js";const P=()=>e.jsx(u,{direction:"row",spacing:2,className:"mx-auto",my:.5}),f=r.createContext(void 0),B=({children:t})=>{const[a,s]=r.useState(!1),[o,c]=r.useState(),[n,l]=r.useState(0),{data:x,isSuccess:d}=v(),b=async(h=void 0)=>{try{s(!0),d&&c(x)}catch{}finally{s(!1)}},g=h=>{const y=o==null?void 0:o.filter(C=>C.title.includes(h));c(y)};r.useEffect(()=>{d&&c(x)},[d]);const S={loading:a,search:g,fetchData:b,setSelectedId:l,data:o};return e.jsx(f.Provider,{value:S,children:t})},j=()=>r.useContext(f),F=[{title:"کد",dataIndex:"id",key:"id",width:50,render:(t,a,s)=>E(t)},{title:"عنوان ",dataIndex:"title",key:"title",render:(t,a,s)=>N(t)}],G=()=>{const{loading:t,setSelectedId:a,data:s,fetchData:o}=j();r.useEffect(()=>{o()},[]);const c=n=>{a(n.id)};return e.jsx(k,{rowKey:"id",loading:t,boxProps:{sx:{height:"80vh"}},columns:F||[],data:s||[],onClick:n=>c(n)})},K=T(i)`
  box-shadow: 0 3px 20px rgb(0 0 0 / 4%);
  background-color: rgb(255, 255, 255);
  padding: 10px 20px 10px;
  min-height: 100vh;

  .MuiDataGrid-cell {
    cursor: pointer !important;
  }
`,L=()=>{const{userType:t}=w(l=>l.user),{search:a}=j(),[s,o]=r.useState(""),c=()=>{a(s)},n=()=>{o(""),a("")};return e.jsxs(u,{className:"h-full overflow-y-auto p-2 pb-10 border-l",spacing:1,children:[e.jsx(D,{className:+t===J.accountant?"!bg-[#b0d8e7]":"",children:"نام"}),e.jsx(R,{placeholder:"...",value:s,onChange:o}),e.jsxs(u,{component:"form",direction:"row",justifyContent:"center",gap:1,children:[e.jsx(p,{fullWidth:!0,startIcon:e.jsx(m.SearchIcon,{}),onClick:c,children:"جستجو"}),e.jsx(p,{fullWidth:!0,startIcon:e.jsx(m.RefreshIcon,{}),onClick:n,children:"بازنشانی"})]})]})},z=()=>e.jsxs(K,{className:"!px-4 !py-2",children:[e.jsx(I,{prevRoutes:[{path:"/",title:"داشبورد"}],currentRoute:"مشاغل"}),e.jsx(B,{children:e.jsxs(i,{container:!0,xs:12,spacing:1,className:"!h-full",children:[e.jsx(i,{item:!0,xs:12,sm:2,children:e.jsx(L,{})}),e.jsxs(i,{item:!0,xs:12,sm:10,spacing:1,children:[e.jsx(P,{}),e.jsx(G,{})]})]})})]});export{z as default};
