import{j as e,S as g,p,a7 as f,M as h}from"./vendor-mui-CBBEb17G.js";import{u as y,S as V}from"./index-I6KWyfSh.js";import{a as r}from"./vendor-react-BBazpZul.js";import{cn as N,a0 as B,e as z,b4 as O,aX as H,f2 as $,f3 as E,j5 as G,z as W,b9 as F,aH as K,f4 as M,f5 as U,be as b,w as q}from"./index-DdWwwZXu.js";import"./vendor-utils-BveVE6Uf.js";import{B as J}from"./index-DQbmBtLN.js";import{S as X}from"./index-CDArk_1r.js";import"./vendor-charts-tGnAgELZ.js";const C=r.createContext(void 0),L=({children:o})=>{const[t,a]=r.useState(new Date),[i,l]=r.useState(new Date),c=r.useRef(),m={fromDateValue:t,setFromDateValue:a,toDateValue:i,setToDateValue:l,SecretaryComponentRef:c};return e.jsx(C.Provider,{value:m,children:o})},j=()=>r.useContext(C),Q=()=>{const{SecretaryComponentRef:o}=j(),t=N.useReactToPrint({contentRef:o,pageStyle:`@media print {
      @page {  size: portrait !important;}
    }`}),{selectedSecretary:a}=y();return e.jsx(g,{direction:"row",columnGap:1,children:e.jsxs(g,{justifyContent:"center",alignItems:"center",className:"cursor-pointer",onClick:()=>t(),children:[e.jsx(B,{color:a?"primary":"disabled",fontSize:"large"}),e.jsx("span",{className:`text-[11px] ${a?"opacity-100":"opacity-50"}`,children:"گزارش"})]})})},Y=()=>{const{loading:o,selectedSecretary:t}=y(),{fromDateValue:a,toDateValue:i,SecretaryComponentRef:l}=j(),{getSecretaryRollCallReportById:c}=K(),{officeId:m,clinicId:n,doctorId:S}=z(s=>s.doctorData),[u,P]=r.useState({dailyWorkingHours:0,totalWorkingHours:"",days:[]}),[w,D]=r.useState(""),{getOfficeByIdAsync:A}=M(),{getClinicByIdAsync:I}=U(),v=async()=>{try{if(m){const{data:s}=await A(m);s&&D(s.title)}else if(n){const{data:s}=await I(n);s&&D(s.name)}}finally{}},T=async()=>{try{const{data:s}=await c({secretaryId:t==null?void 0:t.userId,From:a,UpTo:i,ClinicId:n||null,OfficeId:m||null});if(s){const d={...s,days:s.days.reverse()};P(d)}}finally{}};r.useEffect(()=>{t&&(T(),v())},[t,a,i]);const R=[{key:"num",render:(s,d,x)=>W(x+1),width:50,align:"center",title:"ردیف"},{title:"تاریخ",dataIndex:"date",key:"date",width:70,align:"center",render:(s,d,x)=>F(s)},{title:"ساعت ورود",dataIndex:"loginTime",key:"loginTime",width:70,align:"center",render:(s,d,x)=>s?s.split(".")[0]:"-"},{title:"ساعت خروج",dataIndex:"logOutTime",key:"logOutTime",width:70,align:"center",render:(s,d,x)=>s?s.split(".")[0]:"-"},{title:"ساعت کارکرد",dataIndex:"workTime",key:"workTime",width:100,align:"center",render:(s,d,x)=>d.loginTime&&!d.logOutTime?"خروج ناقص":s}],k=O();return e.jsxs(g,{className:"!h-[70dvh]",children:[e.jsx(H,{loading:o,rowKey:"id",columns:R||[],data:t?u.days:[]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{mt:1,children:[e.jsx(f,{component:"span",fontSize:"0.8rem",mr:2,children:"کل ساعات کارکرد منشی:"}),e.jsx(f,{component:"span",fontSize:"0.8rem",children:u.totalWorkingHours})]}),e.jsxs(p,{mt:1,children:[e.jsx(f,{component:"span",fontSize:"0.8rem",mr:2,children:"میزان ساعت کارکرد موظف:"}),e.jsx(f,{component:"span",fontSize:"0.8rem",children:u.dailyWorkingHours})]})]}),e.jsx($,{ref:l,children:e.jsx(E,{centerData:k,title:"لیست کارکرد منشی",subTitle:w,children:e.jsx(G,{secretaryReportData:u,fromDate:a,toDate:i,name:`${t==null?void 0:t.firstName} ${t==null?void 0:t.lastName}`})})})]})},Z=()=>{const{fromDateValue:o,toDateValue:t,setFromDateValue:a,setToDateValue:i}=j(),{selectedSecretary:l}=y();return e.jsxs(p,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},columnGap:"5px",marginBottom:"10px",gap:2},children:[e.jsx(p,{children:e.jsx(b,{disablePast:!1,onChange:c=>a(c),disabled:!l,value:o,label:"از تاریخ"})}),e.jsx(p,{children:e.jsx(b,{disablePast:!1,onChange:c=>i(c),disabled:!l,value:t,label:"تا تاریخ"})})]})},_=()=>{const{GetSecretariesAsyncReq:o,secretarires:t,setSelectedSecretary:a}=y(),[i,l]=r.useState({value:"",label:""}),c=t.map(n=>({value:`${n.userId}`,label:`${n.firstName} ${n.lastName}`})),m=n=>{if(l(n),!n){a(void 0);return}const S=t.find(u=>u.userId===+n.value);a(S)};return r.useEffect(()=>{o()},[]),e.jsxs(X,{className:"!space-y-3 !py-2 !px-4 bg-white",children:[e.jsx(J,{prevRoutes:[{path:"/",title:"داشبورد"}],currentRoute:"لیست کارکرد"}),e.jsxs(h,{container:!0,xs:12,columnSpacing:2,children:[e.jsx(h,{item:!0,xs:12,sm:6,md:5,lg:2,children:e.jsx(q,{label:"منشی ها",value:i,selectOption:c,onChange:m})}),e.jsx(h,{item:!0,xs:12,sm:6,md:7,lg:10,children:e.jsx(Z,{})})]}),e.jsx(Q,{}),e.jsx(Y,{})]})},ce=()=>e.jsx(V,{children:e.jsx(L,{children:e.jsx(_,{})})});export{ce as default};
