import{j as e,S as x,M as u,o as k,b3 as A}from"./vendor-mui-CBBEb17G.js";import{B as R}from"./index-DQbmBtLN.js";import{a as l}from"./vendor-react-BBazpZul.js";import{fp as z,e as H,iP as F,be as p,aA as g,bf as f,gl as j,b2 as S,w as L,ao as B,I as v,aX as E,a_ as b,z as K}from"./index-DdWwwZXu.js";import{S as O}from"./index-CDArk_1r.js";import"./vendor-utils-BveVE6Uf.js";import"./vendor-charts-tGnAgELZ.js";const P=l.createContext(void 0),M=({children:n})=>{const{getAttendanceReportAsync:a}=F(),{GetCenterUsers:c}=z(),{clinicId:i,officeId:m}=H(d=>d.doctorData),[o,r]=l.useState({PageNumber:0,PageSize:25}),[t,s]=l.useState(!1),[N,C]=l.useState(null),[w,I]=l.useState([]),h=async()=>{try{s(!0);const{data:d}=await a({...o,PageNumber:o.PageNumber+1});C(d)}finally{s(!1)}},D=async()=>{const{data:d}=await c(i,m);d&&I(d)};l.useEffect(()=>{D()},[]),l.useEffect(()=>{h()},[o.PageNumber,o.PageSize]);const U={searchParams:o,data:N,loading:t,userList:w,fetchData:h,setSearchParams:r};return e.jsx(P.Provider,{value:U,children:n})},T=()=>l.useContext(P),y=()=>{const{loading:n,searchParams:a,userList:c,setSearchParams:i,fetchData:m}=T(),o=[{id:0,fullName:"همه"},...c],r=o==null?void 0:o.map(t=>({value:`${t.id}`,label:`${t.fullName}`}));return e.jsxs(x,{spacing:2,className:"relative h-full overflow-y-auto overflow-x-hidden p-3 rounded-lg bg-gray-50",children:[e.jsx(p,{label:"از تاریخ",value:a.From?new Date(a.From):void 0,onChange:t=>i(s=>({...s,From:g(t)}))}),e.jsx(f,{label:"از ساعت",value:S(a.FromTime??"00:00:00","HH:mm:ss"),onChange:t=>i(s=>({...s,FromTime:t?j(t):void 0}))}),e.jsx(p,{label:"تا تاریخ",value:a.UpTo?new Date(a.UpTo):void 0,onChange:t=>i(s=>({...s,UpTo:g(t)}))}),e.jsx(f,{label:"تا ساعت",value:S(a.UpToTime??"23:59:59","HH:mm:ss"),onChange:t=>i(s=>({...s,UpToTime:t?j(t):void 0}))}),e.jsx(L,{label:"انتخاب کاربر",selectOption:r,value:r.find(t=>t.value===(a.UserId??0).toString())||null,onChange:t=>i(s=>({...s,UserId:t!=null&&t.value?+t.value:void 0}))}),e.jsx(x,{className:"sticky bottom-0 z-10",direction:"row",justifyContent:"center",children:e.jsx(B,{fullWidth:!0,color:"primary",startIcon:e.jsx(v.SearchIcon,{}),loading:n,onClick:m,children:"جستجو"})})]})},G=()=>{var o;const{data:n,loading:a,searchParams:c,setSearchParams:i}=T(),m=[{title:"نام کاربر",key:"fullName",dataIndex:"fullName",width:200},{title:"نوع حساب کاربری",key:"userTypeName",dataIndex:"userTypeName",width:150},{title:"زمان شروع شیفت",key:"startDateTime",dataIndex:"startDateTime",width:150,render:r=>b(r,"date-time")},{title:"زمان پایان شیفت",key:"endDateTime",dataIndex:"endDateTime",width:150,render:r=>r?b(r,"date-time"):"---"},{title:"جمع ساعت کار",key:"totalHour",dataIndex:"totalHour",width:100,render:r=>K(r)}];return e.jsx(E,{columns:m,data:(n==null?void 0:n.list)||[],rowKey:"id",loading:a,totalCount:((o=n==null?void 0:n.pagination)==null?void 0:o.totalCount)??0,pageNumber:c.PageNumber,pageSize:c.PageSize,onPaginationLoad:(r,t)=>i(s=>({...s,PageNumber:r,PageSize:t}))})},Q=()=>{const[n,a]=l.useState(!1);return e.jsxs(u,{container:!0,xs:12,spacing:1,className:"!h-[88vh]",children:[e.jsx(u,{item:!0,xs:12,display:{xs:"block",md:"none"},className:"!h-fit",children:e.jsx(k,{color:"info",size:"small",onClick:()=>a(!0),children:e.jsx(v.SearchIcon,{})})}),e.jsx(u,{item:!0,xs:0,md:3,display:{xs:"none",md:"block"},children:e.jsx(y,{})}),e.jsx(u,{item:!0,xs:12,md:9,className:"!h-[76dvh] mobile:!h-[82dvh]",children:e.jsx(G,{})}),e.jsx(x,{display:{xs:"flex",md:"none"},children:e.jsx(A,{anchor:"right",open:n,onClose:()=>a(!1),onOpen:()=>a(!0),children:e.jsx(x,{pt:9,children:e.jsx(y,{})})})})]})},Y=()=>e.jsxs(O,{className:"!space-y-3 !px-4 !py-2 bg-white",children:[e.jsx(R,{prevRoutes:[{path:"/",title:"داشبورد"}],currentRoute:"گزارش حضور و غیاب"}),e.jsx(M,{children:e.jsx(Q,{})})]});export{Y as default};
