import{j as e,M as w,S as h,r as Ue,Q as Re,R as Te,p as z,aF as Y,B as se,c as ne,a4 as ke,aH as Fe,aq as Oe}from"./vendor-mui-CBBEb17G.js";import{a as r,c as pe}from"./vendor-react-BBazpZul.js";import{e as B,aP as F,be as ae,al as be,Y as Me,cm as Le,Z as fe,aO as Z,n as _,A as ce,c8 as _e,c$ as je,I as W,cO as Be,eS as Se,aQ as K,b3 as $,dD as ye,aU as re,aV as ie,aW as Q,dj as ge,et as Ne,J as V,eT as Ge,s as ze,U as We,v as le,r as $e,x as Ve,eU as Je,dP as we,w as X,ao as de,eV as qe,aA as me,eW as De,aX as He,a_ as Ye,eX as ue,eY as Ke,eZ as Qe,av as Xe,e_ as Ze,db as et,e$ as tt}from"./index-DdWwwZXu.js";import{g as st}from"./vendor-utils-BveVE6Uf.js";import{A as oe}from"./index-hw_Y664s.js";import{r as nt}from"./vendor-charts-tGnAgELZ.js";import{T as at,a as rt,P as it,D as lt,b as ot,c as ct,d as dt,e as mt,f as ut}from"./index-B9jIT5HI.js";import{W as xt}from"./workPlaceItem-DByuY88U.js";import{u as Ie}from"./index-CzGLZRaS.js";import{A as ht,a as pt}from"./assistantService-sLLNbnUL.js";import"./index-C-7ipyrW.js";import"./index-Bye5xs9z.js";import"./index-DaOpUtQS.js";import"./index-DJIYDN8m.js";import"./searchBox-Co5H16aC.js";import"./drugSearchedList-Bt-I1bz8.js";import"./paraClinicSearchedList-B54AhY_5.js";import"./CenterServicesTableD-Cx8WWhJW.js";const bt=[{label:"نام",name:"firstName",type:"text"},{label:"نام خانوادگی",name:"lastName",type:"text"},{label:"کدملی",name:"nationalCode",type:"text"},{label:"تخصص",name:"expertise",type:"text"},{label:"شماره نظام پزشکی",name:"medicalSystemCode",type:"text",edit:!0},{label:"تلفن همراه",name:"mobile",type:"text"},{label:"تلفن ضروری",name:"phoneNumber",type:"text",edit:!0},{label:"جنسیت",name:"gender",type:"text"},{label:"ایمیل",name:"email",type:"text"},{label:"نام پدر",name:"fatherName",type:"text"},{label:"تاریخ تولد",name:"birthDate",type:"date"},{label:"وب سایت",name:"webSite",type:"text",edit:!0}],ft=({doctorData:a,editMode:l,editStates:p,setEditStates:b,useForm:{register:o,setValue:x}})=>{B(i=>i.user.userInfo);const[n,S]=r.useState(!1),[I,u]=r.useState(null);return r.useEffect(()=>{const{firstName:i,lastName:t,email:A,expertise:f,phoneNumber:C,fatherName:E,birthDate:N,nationalCode:j,gender:m,mobile:v,webSite:y,medicalSystemCode:O}=a;u(N);const P={firstName:i,lastName:t,email:A,expertise:f,phoneNumber:C,nationalCode:j,fatherName:E,birthDate:N,gender:m==1?"مرد":"زن",mobile:v,webSite:y,medicalSystemCode:O};a&&Object.entries(P).forEach(([R,d])=>{x(R,d)})},[a]),e.jsx(e.Fragment,{children:e.jsx(w,{component:"form",container:!0,rowSpacing:4,columnSpacing:3,className:"!mt-0 min-h-[400px]",children:bt.map(i=>e.jsxs(w,{item:!0,xs:12,lg:6,children:[(i==null?void 0:i.type)==="text"&&e.jsx(F,{name:i==null?void 0:i.name,label:i==null?void 0:i.label,register:o,disabled:i!=null&&i.edit?!l:!0}),(i==null?void 0:i.type)==="date"&&e.jsx(ae,{value:new Date(I),onChange:()=>{},disabled:!0,label:i.label,name:i==null?void 0:i.name})]},i==null?void 0:i.name))})})},Ce=be.section`
  box-shadow: 0 3px 20px rgb(0 0 0 / 4%);
  border-radius: 0.375rem;
  border-color: transparent;
  background-color: #fff;
  padding: 1.25rem;
  width: 70%;
  min-height: 580px;

  @media only screen and (max-width: 630px) {
    width: 85%;
  }
  @media only screen and (max-width: 576px) {
    width: 100%;
  }
`,U=[{label:"نام کاربری",name:"userName",type:"text"},{label:"نام کاربری ",name:"salamatUsername",type:"text",edit:!0},{label:"رمز عبور ",name:"salamatPassword",type:"text",edit:!0},{label:"نام کاربری",name:"automationUsername",type:"text",edit:!0},{label:"رمز عبور",name:"automationPassword",type:"text",edit:!0},{label:"کد سمت ",name:"automationEmployeeJobId",type:"text",edit:!0},{label:"نام کاربری ",name:"taminServiceDeliveryUsername",type:"text",edit:!0},{label:"رمز عبور ",name:"taminServiceDeliveryPassword",type:"text",edit:!0}],jt=({doctorData:a,editMode:l,editStates:p,setEditStates:b,useForm:{register:o,setValue:x}})=>(r.useEffect(()=>{const{userName:n,salamatUsername:S,salamatPassword:I,automationUsername:u,automationPassword:i,automationEmployeeJobId:t}=a;a&&Object.entries({userName:n,salamatUsername:S,salamatPassword:I,automationUsername:u,automationPassword:i,automationEmployeeJobId:t}).forEach(([f,C])=>{x(f,C)})},[a]),e.jsx(e.Fragment,{children:e.jsxs(h,{component:"form",gap:3,className:"!mt-0 min-h-[400px]",children:[e.jsx(h,{width:"46%",children:e.jsx(F,{name:U[0].name,label:U[0].label,register:o,disabled:U[0].edit?!l:!0})}),e.jsxs(h,{direction:"row",flexWrap:"wrap",columnGap:2,rowGap:2,children:[e.jsx(h,{width:"100%",className:"text-slate-700 text-[0.9rem]",children:"اطلاعات کاربری بیمه سلامت"}),e.jsx(h,{width:"46%",children:e.jsx(F,{name:U[1].name,label:U[1].label,register:o,disabled:!l})}),e.jsx(h,{width:"46%",children:e.jsx(F,{name:U[2].name,label:U[2].label,register:o,disabled:!l})})]}),e.jsxs(h,{direction:"row",flexWrap:"wrap",columnGap:2,rowGap:2,children:[e.jsx(h,{width:"100%",className:"text-slate-700 text-[0.9rem]",children:"اطلاعات کاربری نسخه پیچی تامین اجتماعی"}),e.jsx(h,{width:"46%",children:e.jsx(F,{name:U[6].name,label:U[6].label,register:o,disabled:!l})}),e.jsx(h,{width:"46%",children:e.jsx(F,{name:U[7].name,label:U[7].label,register:o,disabled:!l})})]}),e.jsxs(h,{direction:"row",flexWrap:"wrap",columnGap:2,rowGap:2,children:[e.jsx(h,{width:"100%",className:"text-slate-700 text-[0.9rem]",children:"اطلاعات کاربری اتوماسیون اداری"}),e.jsx(h,{width:"46%",children:e.jsx(F,{name:U[3].name,label:U[3].label,register:o,disabled:!l})}),e.jsx(h,{width:"46%",children:e.jsx(F,{name:U[4].name,label:U[4].label,register:o,disabled:!l})}),e.jsx(h,{width:"46%",children:e.jsx(F,{name:U[5].name,label:U[5].label,register:o,disabled:!l})})]})]})}));var H={},xe;function St(){if(xe)return H;xe=1;var a=nt();Object.defineProperty(H,"__esModule",{value:!0}),H.default=void 0;var l=a(Me()),p=Ue(),b=(0,l.default)((0,p.jsx)("path",{d:"M19.94 9.06C19.5 5.73 16.57 3 13 3 9.47 3 6.57 5.61 6.08 9l-1.93 3.48c-.41.66.07 1.52.85 1.52h1v2c0 1.1.9 2 2 2h1v3h7v-4.68c2.62-1.25 4.35-4.08 3.94-7.26zM12.5 14c-.41 0-.74-.33-.74-.74s.33-.73.74-.73.73.32.73.73-.31.74-.73.74zm1.76-4.32c-.44.65-.86.85-1.09 1.27-.09.17-.13.28-.13.82h-1.06c0-.29-.04-.75.18-1.16.28-.51.83-.81 1.14-1.26.33-.47.15-1.36-.8-1.36-.62 0-.92.47-1.05.86l-.96-.4c.27-.78.97-1.45 2.01-1.45.86 0 1.45.39 1.75.88.26.43.41 1.22.01 1.8z"}),"PsychologyAlt");return H.default=b,H}var yt=St();const gt=st(yt),Nt=()=>{const{doctorId:a}=B(s=>s.doctorData),{GetDoctorByIdAsync:l,editDoctorAsync:p}=Le(),{isModuleAccessible:b,isInRole:o,userType:x}=fe(),{register:n,setValue:S,handleSubmit:I}=Z(),[u,i]=r.useState("1"),[t,A]=r.useState(null),[f,C]=r.useState(""),[E,N]=r.useState(!1),[j,m]=r.useState(!1),[v,y]=r.useState({reasonReferral:!1,drugInteractions:!1,prescribeGroup:!1,doctorSetting:!1,textLaboratory:!1}),[O,P]=pe.useState(null),R=!!O,[d,T]=r.useState({medicalSystemCode:"",phoneNumber:"",webSite:"",salamatUsername:"",salamatPassword:"",automationUsername:"",automationPassword:"",automationEmployeeJobId:"",taminServiceDeliveryUsername:"",taminServiceDeliveryPassword:""}),M=[{title:"علت مراجعه",icon:e.jsx(gt,{}),onClick:()=>y(s=>({...s,reasonReferral:!0})),show:o([+x],[_.DoctorReasonForReference])},{title:"تداخل دارویی",icon:e.jsx(_e,{}),onClick:()=>y(s=>({...s,drugInteractions:!0})),show:o([+x],[_.DoctorDrugInterference])&&b(ce.DrugInterference)},{title:"گروه تجویز",icon:e.jsx(W.EditRoad,{}),onClick:()=>y(s=>({...s,prescribeGroup:!0})),show:+x===je.doctor},{title:"آزمایش ها",icon:e.jsx(Be,{}),onClick:()=>y(s=>({...s,textLaboratory:!0})),show:o([+x],[_.DoctorTextLaboratory])&&b(ce.TextLaboratory)},{title:"تنظیمات",icon:e.jsx(Se,{}),onClick:()=>y(s=>({...s,doctorSetting:!0})),show:o([+x],[_.DoctorSetting])}],J=s=>{P(s.currentTarget)},q=()=>{P(null)},D=e.jsxs(e.Fragment,{children:[e.jsx(h,{className:"!hidden sm:!flex !flex-row !items-center !justify-between lg:!justify-center lg:!gap-8",children:M.map((s,g)=>e.jsxs(h,{justifyContent:"center",alignItems:"center",className:`cursor-pointer ${s.show?"!visible":"!hidden"}`,onClick:()=>{s.onClick()},children:[e.jsx(K,{size:"small",children:s.icon}),e.jsx("span",{className:"text-[11px]",children:s.title})]},$()))}),e.jsxs(h,{className:"!flex !flex-row sm:!hidden !justify-between !items-start",children:[M.slice(0,2).map((s,g)=>e.jsxs(h,{justifyContent:"center",alignItems:"center",className:`cursor-pointer ${s.show?"!visible":"!hidden"}`,onClick:()=>{s.onClick()},children:[e.jsx(K,{size:"small",children:s.icon}),e.jsx("span",{className:"text-[11px]",children:s.title})]},$())),e.jsx(ye,{onClick:J,children:e.jsx(W.MoreHorizIcon,{color:"primary"})}),e.jsx(Re,{anchorEl:O,open:R,onClose:q,children:M.slice(2).map((s,g)=>e.jsxs(e.Fragment,{children:[e.jsxs(Te,{onClick:s.onClick,className:"!w-[150px]",children:[e.jsx(K,{size:"small",children:s.icon}),e.jsx("p",{className:"mr-2",children:s.title})]},s.title),g!==M.length-3&&e.jsx("hr",{})]}))})]})]}),c=(s,g)=>{i(g)};r.useEffect(()=>{t&&S("bio",t.bio)},[t]);const L=async s=>{if(!j){m(!0);return}const g={doctor:{expertiseId:t==null?void 0:t.expertiseId,medicalSystemCode:s.medicalSystemCode?s.medicalSystemCode:t==null?void 0:t.medicalSystemCode,salamatPassword:s.salamatPassword?s.salamatPassword:t==null?void 0:t.salamatPassword,salamatUsername:s.salamatUsername?s.salamatUsername:t==null?void 0:t.salamatUsername,taminServiceDeliveryPassword:s.taminServiceDeliveryPassword?s.taminServiceDeliveryPassword:t==null?void 0:t.taminServiceDeliveryPassword,taminServiceDeliveryUsername:s.taminServiceDeliveryUsername?s.taminServiceDeliveryUsername:t==null?void 0:t.taminServiceDeliveryUsername,id:t==null?void 0:t.id,userId:t==null?void 0:t.userId,persentOfCooperation:t==null?void 0:t.persentOfCooperation,automationUsername:s.automationUsername?s.automationUsername:t==null?void 0:t.automationUsername,automationPassword:s.automationPassword?s.automationPassword:t==null?void 0:t.automationPassword,automationEmployeeJobId:s.automationEmployeeJobId?s.automationEmployeeJobId:t==null?void 0:t.automationEmployeeJobId,bio:s.bio?s.bio:t==null?void 0:t.bio,durationOfVisit:t==null?void 0:t.durationOfVisit,overFifteenYearsExperience:t==null?void 0:t.overFifteenYearsExperience},user:{id:t==null?void 0:t.userId,birthDate:(t==null?void 0:t.birthDate)??"",comment:t==null?void 0:t.comment,email:t!=null&&t.email?t==null?void 0:t.email:"",fatherName:t==null?void 0:t.fatherName,firstName:t==null?void 0:t.firstName,gender:t==null?void 0:t.gender,lastName:t==null?void 0:t.lastName,mobile:t==null?void 0:t.mobile,nationalCode:t==null?void 0:t.nationalCode,password:"",phoneNumber:s.phoneNumber?s.phoneNumber:t==null?void 0:t.phoneNumber,picture:(f==null?void 0:f.replace("data:image/png;base64,",""))||"",userName:t==null?void 0:t.userName,userType:+x,webSite:s.webSite?s.webSite:t==null?void 0:t.email}};try{N(!0),await p(g,(t==null?void 0:t.id)+""),V.success("اطلاعات پروفایل با موفقیت تغییر کرد")}finally{N(!1)}};return r.useEffect(()=>{(async()=>{const{data:s}=await l(a);A(s),C(s==null?void 0:s.picture)})()},[]),e.jsxs(e.Fragment,{children:[e.jsx(Ce,{children:e.jsxs(w,{container:!0,spacing:1.5,height:"100%",children:[e.jsx(w,{item:!0,xs:12,children:D}),e.jsx(w,{item:!0,xs:12,md:3,height:"500px",order:{xs:1,md:2},children:t&&e.jsx(h,{justifyContent:"space-evenly",height:"100%",gap:1.5,children:e.jsx(oe,{picture:f,setPicture:C})})}),e.jsxs(w,{item:!0,xs:12,md:9,order:{xs:2,md:1},children:[e.jsx(h,{children:e.jsxs(re,{value:u,children:[e.jsx(z,{sx:{borderBottom:1,borderColor:"divider"},children:e.jsxs(ie,{onChange:c,"aria-label":"lab API tabs example",children:[e.jsx(Y,{classes:{root:""},label:"بیوگرافی",value:"1"}),e.jsx(Y,{classes:{root:""},label:"اطلاعات شخصی",value:"2"}),e.jsx(Y,{classes:{root:""},label:"اطلاعات کاربری",value:"3"})]})}),e.jsx(Q,{value:"1",children:e.jsx(h,{className:"min-h-[400px]",children:t?e.jsx(F,{multiline:!0,rows:10,name:"bio",label:"متن",disabled:!j,register:n}):null})}),e.jsx(Q,{value:"2",children:t&&e.jsx(ft,{editMode:j,doctorData:t,editStates:d,setEditStates:T,useForm:{register:n,setValue:S}})}),e.jsx(Q,{value:"3",children:t&&e.jsx(jt,{editMode:j,doctorData:t,editStates:d,setEditStates:T,useForm:{register:n,setValue:S}})})]})}),e.jsx(h,{alignItems:"center",children:e.jsx(se,{variant:"contained",className:"!w-[100px]",startIcon:j?e.jsx(ge,{}):e.jsx(Ne,{}),onClick:I(L),disabled:E,children:j?"ثبت":"ویرایش"})})]})]})}),v.textLaboratory&&e.jsx(at,{children:e.jsx(rt,{doctorId:a,handleClose:()=>y(s=>({...s,textLaboratory:!1}))})}),v.prescribeGroup&&e.jsx(it,{doctorId:a,onClose:()=>y(s=>({...s,prescribeGroup:!1}))}),v.doctorSetting&&e.jsx(lt,{children:e.jsx(ot,{doctorId:a,onClose:()=>y(s=>({...s,doctorSetting:!1}))})}),v.reasonReferral&&e.jsx(ct,{children:e.jsx(dt,{doctorId:a,onClose:()=>y(s=>({...s,reasonReferral:!1}))})}),v.drugInteractions&&e.jsx(mt,{children:e.jsx(ut,{doctorId:a,onClose:()=>y(s=>({...s,drugInteractions:!1}))})})]})},wt=[{label:"نام",name:"firstName",type:"text",edit:!0},{label:"نام خانوادگی",name:"lastName",type:"text",edit:!0},{label:"نام کاربری",name:"userName",type:"text",edit:!0},{label:"کدملی",name:"nationalCode",type:"text"},{label:"تلفن همراه",name:"mobile",type:"text",edit:!0},{label:"تلفن ضروری",name:"phoneNumber",type:"text",edit:!0},{label:"جنسیت",name:"gender",type:"text"},{label:"نام پدر",name:"fatherName",type:"text",edit:!0},{label:"تاریخ تولد",name:"birthDate",type:"date",edit:!0},{label:"ایمیل",name:"email",type:"text",edit:!0},{label:"وب سایت",name:"webSite",type:"text",edit:!0},{label:"توضیحات",name:"comment",type:"text",edit:!0}],It=({secretaryData:a,editMode:l,useForm:{register:p,setValue:b},birthDate:o,setBirthDate:x})=>(r.useEffect(()=>{const{firstName:n,lastName:S,email:I,phoneNumber:u,fatherName:i,birthDate:t,nationalCode:A,gender:f,mobile:C,webSite:E,userName:N}=a;a&&Object.entries({firstName:n,lastName:S,email:I,phoneNumber:u,nationalCode:A,fatherName:i,birthDate:t,gender:f===1?"مرد":"زن",mobile:C,webSite:E,userName:N}).forEach(([m,v])=>{b(m,v)})},[a]),e.jsx(e.Fragment,{children:e.jsx(w,{component:"form",container:!0,rowSpacing:4,columnSpacing:3,className:"!mt-0 min-h-[400px]",children:wt.map(n=>e.jsxs(w,{item:!0,xs:12,lg:6,children:[(n==null?void 0:n.type)==="text"&&e.jsx(F,{name:n==null?void 0:n.name,label:n==null?void 0:n.label,register:p,disabled:n!=null&&n.edit?!l:!0}),(n==null?void 0:n.type)==="date"&&e.jsx(ae,{className:"widthFixed",value:o,onChange:S=>x(S),disabled:n!=null&&n.edit?!l:!0,disablePast:!1,label:n.label,name:"birthDate"})]},n==null?void 0:n.name))})})),ve=r.createContext(void 0),Ct=({children:a})=>{const[l,p]=r.useState("0.9"),b=Ge(),{updateUiSettingAsync:o,getUiSettingAsync:x}=We(),n=async()=>{const u={browserAppearanceSetting:{fontSize:Number(l)},quickAccessLinks:""},{message:i}=await o(u);V.success(i),b(ze(Number(l)))},S=async()=>{const{data:u}=await x();if(!u)return;const{fontSize:i}=JSON.parse(u==null?void 0:u.browserAppearanceSetting);p(i)};r.useEffect(()=>{S()},[]);const I={onSubmit:n,fontSize:l,setFontSize:p};return e.jsx(ve.Provider,{value:I,children:a})},vt=()=>r.useContext(ve),Pt=({onClose:a})=>{const{onSubmit:l,setFontSize:p,fontSize:b}=vt(),{handleSubmit:o}=Z(),[x,n]=r.useState(!1),S=async()=>{try{n(!0),await l(),a()}finally{n(!1)}};return e.jsxs(le,{title:"تنظیمات ظاهری",onClose:a,dialogProps:{className:"cenerSetting"},maxWidth:"xs",children:[e.jsx(ne,{className:"!pr-6 !p-2 m-2 border rounded-lg",children:e.jsxs("form",{children:[e.jsx(ke,{children:e.jsx(Fe,{id:"demo-row-radio-buttons-group-label ",children:"سایز متن"})}),e.jsx($e,{label:"سایز متن",onchange:p,value:b,items:[{value:"0.9",label:"14px"},{value:"1",label:"16px"},{value:"1.1",label:"18px"},{value:"1.2",label:"20px"},{value:"1.3",label:"22px"},{value:"1.4",label:"23px"}]})]})}),e.jsx(Ve,{onClose:a,onSubmit:o(S),loading:x})]})},At=()=>{const[a,l]=r.useState(!1),{userInfo:p,userType:b}=B(d=>d.user),{GetSecretaryByIdAsync:o,EditSecretaryAsync:x}=Je(),{register:n,setValue:S,handleSubmit:I}=Z(),[u,i]=r.useState("1"),[t,A]=r.useState(null),[f,C]=r.useState(""),[E,N]=r.useState(!1),[j,m]=r.useState(!1),[v,y]=r.useState(new Date),O=(d,T)=>{i(T)},P=()=>{l(!1)},R=async d=>{if(!j){m(!0);return}const T={id:t==null?void 0:t.userId,firstName:d.firstName?d.firstName:t==null?void 0:t.firstName,lastName:d.lastName?d.lastName:t==null?void 0:t.lastName,nationalCode:t==null?void 0:t.nationalCode,phoneNumber:d.phoneNumber?d.phoneNumber:t==null?void 0:t.phoneNumber,mobile:d.mobile?d.mobile:t==null?void 0:t.mobile,userName:d.userName?d.userName:t==null?void 0:t.userName,picture:(f==null?void 0:f.replace("data:image/png;base64,",""))||"",birthDate:(t==null?void 0:t.birthDate)??"",fatherName:t==null?void 0:t.fatherName,email:d.email?d.email:t==null?void 0:t.email,webSite:d.webSite?d.webSite:t==null?void 0:t.email,gender:t==null?void 0:t.gender,comment:t==null?void 0:t.comment,userType:+b};try{N(!0),await x(T),V.success("اطلاعات پروفایل با موفقیت تغییر کرد")}finally{N(!1)}};return r.useEffect(()=>{(async()=>{const{data:d}=await o(p==null?void 0:p.id);A(d),C(d==null?void 0:d.picture),y(d!=null&&d.birthDate?d==null?void 0:d.birthDate:new Date)})()},[]),e.jsxs(Ce,{children:[e.jsxs("div",{className:"p-5",children:[e.jsx("button",{className:"uiSettingButton",children:e.jsx(Se,{onClick:()=>l(!0)})}),a&&e.jsx(Ct,{children:e.jsx(Pt,{onClose:P})})]}),e.jsxs(w,{container:!0,spacing:1.5,height:"100%",children:[e.jsxs(w,{item:!0,md:9,children:[e.jsx(h,{children:e.jsxs(re,{value:u,children:[e.jsx(z,{sx:{borderBottom:1,borderColor:"divider"},children:e.jsx(ie,{onChange:O,"aria-label":"lab API tabs example",children:e.jsx(Y,{classes:{root:""},label:"اطلاعات منشی",value:"1"})})}),e.jsx(Q,{value:"1",children:t&&e.jsx(It,{editMode:j,secretaryData:t,useForm:{register:n,setValue:S},birthDate:v,setBirthDate:y})})]})}),e.jsx(h,{alignItems:"center",children:e.jsx(se,{variant:"contained",className:"!w-[100px]",startIcon:j?e.jsx(ge,{}):e.jsx(Ne,{}),onClick:I(R),disabled:E,children:j?"ثبت":"ویرایش"})})]}),e.jsx(w,{item:!0,md:3,height:"500px",children:e.jsx(h,{justifyContent:"space-evenly",height:"100%",gap:1.5,children:e.jsx(oe,{picture:f,setPicture:C})})})]})]})},Et=[{label:"نام کاربری",name:"userName",type:"text"},{label:"نام",name:"firstName",type:"text"},{label:"نام خانوادگی",name:"lastName",type:"text"},{label:"کدملی",name:"nationalCode",type:"text"},{label:"تلفن همراه",name:"mobile",type:"text"},{label:"تلفن ضروری",name:"phoneNumber",type:"text",edit:!0},{label:"جنسیت",name:"gender",type:"text"},{label:"نام پدر",name:"fatherName",type:"text"},{label:"تاریخ تولد",name:"birthDate",type:"date"},{label:"مدت زمان ارائه خدمت به دقیقه",name:"serviceDeliveryDurationInMinutes",type:"text",edit:!0},{label:"وب سایت",name:"webSite",type:"text",edit:!0},{label:"ایمیل",name:"email",type:"text",edit:!0}],Ut=({assistantData:a,editMode:l,editStates:p,setEditStates:b,useForm:{register:o,setValue:x}})=>(r.useEffect(()=>{const{userName:n,firstName:S,lastName:I,nationalCode:u,mobile:i,phoneNumber:t,serviceDeliveryDurationInMinutes:A,email:f,fatherName:C,gender:E,birthDate:N,webSite:j}=a;a&&Object.entries({userName:n,firstName:S,lastName:I,nationalCode:u,mobile:i,phoneNumber:t,serviceDeliveryDurationInMinutes:A,email:f,fatherName:C,gender:E===1?"مرد":"زن",birthDate:N,webSite:j}).forEach(([v,y])=>{x(v,y)})},[a]),e.jsx(e.Fragment,{children:e.jsx(w,{component:"form",container:!0,rowSpacing:4,columnSpacing:3,className:"!mt-0 min-h-[400px]",children:Et.map(n=>e.jsxs(w,{item:!0,xs:12,lg:6,children:[(n==null?void 0:n.type)==="text"&&e.jsx(F,{name:n==null?void 0:n.name,label:n==null?void 0:n.label,register:o,disabled:n!=null&&n.edit?!l:!0}),(n==null?void 0:n.type)==="date"&&e.jsx(ae,{value:new Date(a.birthDate),onChange:()=>{},disabled:!0,label:n.label,name:n==null?void 0:n.name})]},n==null?void 0:n.name))})})),Rt=be.section`
  box-shadow: 0 3px 20px rgb(0 0 0 / 4%);
  border-radius: 0.375rem;
  border-color: transparent;
  background-color: #fff;
  padding: 1.25rem;
  width: 70%;
  min-height: 580px;

  @media only screen and (max-width: 630px) {
    width: 85%;
  }
  @media only screen and (max-width: 576px) {
    width: 100%;
  }
`,Tt=({onClose:a})=>{var L;const[l,p]=r.useState(0),[b,o]=r.useState(!1),[x,n]=r.useState(null),[S,I]=r.useState([]),[u,i]=r.useState(null),[t,A]=r.useState(null),[f,C]=r.useState(null),[{userInfo:E,availableCenters:N},{clinicId:j,officeId:m}]=B(s=>[s.user,s.doctorData]),{addAssistantDepartmentAsync:v,getAssistantDepartmentAsync:y,deleteAssistantDepartmentAsync:O}=Ie(),P=E==null?void 0:E.userTypes[0].assistantId,R=async()=>{try{if(!P)return;p(g=>g+=1);const{data:s}=await y({assistantId:P});if(!s)return;n(s)}finally{p(s=>s-=1)}},d=async()=>{try{if(p(s=>s+=1),m){const s=N==null?void 0:N.flatMap(g=>g.centers).filter(g=>g.isOffice).find(g=>g.id===m);s&&i([{uuid:$(),centerId:s.id,centerName:s.name,departments:s.departments}]);return}if(j){const s=N==null?void 0:N.flatMap(g=>g.centers).filter(g=>g.isClinic).find(g=>g.id===j);s&&i([{uuid:$(),centerId:s.id,centerName:s.name,departments:s.departments}]);return}}finally{p(s=>s-=1)}},T=async()=>{try{if(o(!0),!f||!t||!P)return;const{message:s}=await v({departmentId:+f.value,assistantId:P});V.success(s),R()}catch(s){console.log("ERROR_IN_ADD_WORK_PLACE",s)}finally{o(!1)}},M=async s=>{try{if(!x)return;o(!0);const g=x.find(G=>G.departmentId===s);if(!g)return;const{message:k}=await O(g.id);if(!k)return;V.success(k),R()}finally{o(!1)}},J=()=>{a()};r.useMemo(()=>{if(!x||!u)return;p(k=>k+=1);const s=u.filter(k=>k.departments.some(G=>x.some(ee=>ee.departmentId===G.id))),g=[];for(let k of x){const G=s.flat().find(ee=>ee.departments.some(Ee=>Ee.id===k.departmentId));G&&g.push({id:k.id,centerUuid:G.uuid,centerName:G.centerName,departmentId:k.departmentId,departmentName:k.departmentName})}I(g),p(k=>k-=1)},[x,u]),r.useEffect(()=>{R(),d()},[]);const q=(u==null?void 0:u.map(s=>({label:s.centerName,value:s.uuid})))||[],D=((L=u==null?void 0:u.find(s=>s.uuid===(t==null?void 0:t.value)))==null?void 0:L.departments.map(s=>({label:s.title,value:s.id.toString()})))||[],c=r.useMemo(()=>l>0,[l]);return e.jsxs(le,{title:"انتخاب محل کار",onClose:J,children:[e.jsxs(ne,{className:"!py-4 !min-h-[400px]",children:[c&&e.jsx(we,{}),e.jsxs(w,{container:!0,spacing:1,children:[e.jsx(w,{item:!0,xs:12,sm:4,children:e.jsx(X,{disabled:b,label:"مرکز",selectOption:q,value:t,onChange:s=>A(s),loading:c})}),e.jsx(w,{item:!0,xs:12,sm:4,children:e.jsx(X,{disabled:b,label:"بخش",selectOption:D,value:f,onChange:s=>C(s),loading:c})}),e.jsx(w,{item:!0,xs:12,sm:4,children:e.jsx(de,{disabled:!f||b,onClick:T,fullWidth:!0,children:"افزودن به لیست"})})]}),e.jsx(Oe,{className:"!mt-4 !mb-4"}),e.jsx(h,{spacing:1,className:"!h-[200px] !overflow-y-auto",children:S.length>0?e.jsx(e.Fragment,{children:S.map(s=>e.jsx(xt,{disabled:b,info:s,onDelete:()=>M(s.id)},s.departmentId))}):e.jsx("h4",{className:"w-full text-center !p-4 border border-blue-400 rounded-xl",children:"محل کاری مشخص نشده است"})})]}),e.jsx(h,{direction:"row",justifyContent:"center",alignItems:"center",p:1,children:e.jsx(de,{color:"primary",onClick:()=>a(),children:"بستن"})})]})},Pe=r.createContext(null),he=new Date().toLocaleDateString("fa-IR-u-nu-latn").split("/"),kt=({children:a})=>{const[l,p]=r.useState(null),[b,o]=r.useState(!1),[x,n]=r.useState(null),[S,I]=r.useState(null),[u,i]=r.useState(+he[0]),[t,A]=r.useState(+he[1]),[f,C]=r.useState([]),{GetAssistantShiftsAsync:E}=De(),{getAssistantDepartmentAsync:N}=Ie(),{userInfo:j}=B(P=>P.user),m=j==null?void 0:j.userTypes[0].assistantId,v=async P=>{var R,d;try{if(!P||!x)return;o(!0);const T={AssistantId:P,DepartmentId:+x.value,From:me((R=[...f].shift())==null?void 0:R.date),UpTo:me((d=[...f].pop())==null?void 0:d.date)},{data:M}=await E(T);if(!M)return;p(M)}catch{console.log("ERROR_IN_GET_DOCTOR_SHIFT")}finally{o(!1)}},y=async()=>{try{if(!m)return;o(!0);const{data:P}=await N({assistantId:m});if(!P)return;I(P)}finally{o(!1)}};r.useMemo(async()=>{try{if(o(!0),t!==0){const P=await qe(u,t);C(P)}}finally{o(!1)}},[t,u]);const O={states:{loading:b,assistantShiftList:l,department:x,centers:S,selectedYear:u,selectedMonth:t},handlers:{setDepartment:n,setSelectedYear:i,setSelectedMonth:A},functions:{getAssistantShift:v,fetchCenter:y}};return e.jsx(Pe.Provider,{value:O,children:a})},Ae=()=>r.useContext(Pe),Ft=[{key:"date",dataIndex:"date",title:"تاریخ",render:a=>Ye(a)??"-"},{key:"startTime",dataIndex:"startTime",title:"از ساعت",render:a=>ue(a)??"-"},{key:"endTime",dataIndex:"endTime",title:"تا ساعت",render:a=>ue(a)??"-"},{key:"dayName",dataIndex:"dayName",title:"روز",render:a=>a??"-"},{key:"shiftTypeName",dataIndex:"shiftTypeName",title:"زمان",render:a=>a??"-"}],Ot=()=>{const{states:{loading:a,assistantShiftList:l}}=Ae();return e.jsx(He,{rowKey:"id",loading:a,columns:Ft,data:l||[]})},Mt=()=>{const{states:{selectedMonth:a,selectedYear:l,department:p,centers:b,loading:o},handlers:{setSelectedMonth:x,setSelectedYear:n,setDepartment:S},functions:{getAssistantShift:I,fetchCenter:u}}=Ae(),{userInfo:i}=B(m=>m.user),t=i==null?void 0:i.userTypes[0].assistantId,{data:A,isSuccess:f}=Ke({year:l}),C=r.useMemo(()=>!A||!f?null:A.map(v=>({label:v.monthName,value:v.monthNumber.toString()})),[A,f]),E=Qe.map(m=>({label:m.title,value:m.numberOf.toString()})),N=()=>{t&&I(t)};r.useEffect(()=>{u()},[]);const j=(b==null?void 0:b.map(m=>({label:m.departmentName,value:m.departmentId.toString()})))??[];return e.jsxs(w,{container:!0,xs:12,spacing:1,children:[e.jsx(w,{item:!0,xs:12,sm:3,children:e.jsx(X,{selectOption:E,value:E.find(m=>+m.value===l)||null,onChange:m=>n(m?+m.value:0)})}),e.jsx(w,{item:!0,xs:12,sm:3,children:e.jsx(X,{selectOption:C||[],value:(C==null?void 0:C.find(m=>+m.value===a))||null,onChange:m=>x(m?+m.value:0)})}),e.jsx(w,{item:!0,xs:12,sm:3,children:e.jsx(X,{disabled:o,label:"دپارتمان",selectOption:j,value:p,onChange:m=>S(m)})}),e.jsx(w,{item:!0,xs:3,children:e.jsx(ye,{disabled:o,onClick:N,children:e.jsx(W.SearchIcon,{})})})]})},Lt=({onClose:a,assistantName:l})=>e.jsx(le,{title:`شیفت‌های ${l}`,maxWidth:"md",onClose:a,children:e.jsx(ne,{className:"!py-4 !space-y-3",children:e.jsxs(kt,{children:[e.jsx(Mt,{}),e.jsx(Ot,{})]})})}),_t=()=>{const{userInfo:a}=B(c=>c.user),{getAssistantByIdAsync:l,editAssistantAsync:p}=Xe(),{isInRole:b}=fe(),{register:o,setValue:x,handleSubmit:n,formState:S}=Z(),I=a==null?void 0:a.userTypes[0].assistantId,[u,i]=r.useState("1"),[t,A]=r.useState(null),[f,C]=r.useState(""),[E,N]=r.useState(!1),[j,m]=r.useState(!1),[v,y]=r.useState({assistantCenter:!1,assistantServices:!1,assistantShift:!1}),[O,P]=pe.useState(null),[R,d]=r.useState({medicalSystemCode:"",phoneNumber:"",webSite:"",salamatUsername:"",salamatPassword:"",automationUsername:"",automationPassword:"",automationEmployeeJobId:"",taminServiceDeliveryUsername:"",taminServiceDeliveryPassword:""}),T=[{title:"مراکز",icon:e.jsx(Ze,{color:"primary",fontSize:"large"}),onClick:()=>y(c=>({...c,assistantCenter:!0})),show:b(void 0,[_.EditAssistant]),expectedRoles:_.EditAssistant},{title:"خدمات",icon:e.jsx(et,{color:"primary"}),onClick:()=>y(c=>({...c,assistantServices:!0})),show:b(void 0,[_.AssistantServices]),expectedRoles:_.AssistantServices},{title:"شیفت",icon:e.jsx(tt,{color:"primary",fontSize:"large"}),onClick:()=>y(c=>({...c,assistantShift:!0})),show:b(void 0,[_.AssistantServices]),expectedRoles:_.AssistantServices}],M=e.jsxs(e.Fragment,{children:[e.jsx(h,{className:"!hidden sm:!flex !flex-row !items-center !justify-between lg:!justify-center lg:!gap-8",children:T.map((c,L)=>e.jsxs(h,{justifyContent:"center",alignItems:"center",className:`cursor-pointer ${c.show?"!visible":"!hidden"}`,onClick:()=>{c.onClick()},children:[e.jsx(K,{size:"small",children:c.icon}),e.jsx("span",{className:"text-[11px]",children:c.title})]},$()))}),e.jsx(h,{className:"!flex !flex-row sm:!hidden !justify-between !items-start",children:T.map(c=>e.jsxs(h,{justifyContent:"center",alignItems:"center",className:`cursor-pointer ${c.show?"!visible":"!hidden"}`,onClick:()=>{c.onClick()},children:[e.jsx(K,{size:"small",children:c.icon}),e.jsx("span",{className:"text-[11px]",children:c.title})]},$()))})]}),J=(c,L)=>{i(L)},q=async()=>{try{if(!I)return;N(!0);const{data:c}=await l(I);if(!c)return;A(c),C(c.picture)}catch(c){console.log("ERROR_IN_GET_ASSISTANT_INFORMATION",c)}finally{N(!1)}},D=async c=>{try{if(!j)return m(!0);if(!I||!t)return;const L={id:I,userName:t.userName,firstName:t.firstName,lastName:t.lastName,nationalCode:t.nationalCode,mobile:t.mobile,fatherName:t.fatherName,gender:t.gender,birthDate:t.birthDate??void 0,phoneNumber:c.phoneNumber,serviceDeliveryDurationInMinutes:c.serviceDeliveryDurationInMinutes,email:c.email,webSite:c.webSite,picture:f};await p(L),console.log("API CALLED!!!"),V.success("اطلاعات پروفایل با موفقیت تغییر کرد")}catch(L){console.log("ERROR_IN_PROFILE_EDIT_SUBMITION",L)}};return r.useEffect(()=>{q()},[]),e.jsxs(e.Fragment,{children:[e.jsx(Rt,{children:E?e.jsx(we,{}):e.jsxs(w,{container:!0,spacing:1.5,height:"100%",children:[e.jsx(w,{item:!0,xs:12,children:M}),e.jsx(w,{item:!0,xs:12,md:3,height:"500px",order:{xs:1,md:2},children:t&&e.jsx(h,{justifyContent:"space-evenly",height:"100%",gap:1.5,children:e.jsx(oe,{disabled:!j||S.isSubmitting,picture:f,setPicture:C})})}),e.jsxs(w,{item:!0,xs:12,md:9,order:{xs:2,md:1},children:[e.jsx(h,{children:e.jsxs(re,{value:u,children:[e.jsx(z,{sx:{borderBottom:1,borderColor:"divider"},children:e.jsx(ie,{onChange:J,"aria-label":"lab API tabs example",children:e.jsx(Y,{classes:{root:""},label:"اطلاعات شخصی",value:"1"})})}),e.jsx(Q,{value:"1",children:t&&e.jsx(Ut,{editMode:j,assistantData:t,editStates:R,setEditStates:d,useForm:{register:o,setValue:x}})})]})}),e.jsx(h,{alignItems:"center",children:e.jsx(se,{variant:"contained",className:"!w-[100px]",startIcon:S.isSubmitting?e.jsx(e.Fragment,{}):j?e.jsx(W.Save,{}):e.jsx(W.EditIcon,{}),endIcon:S.isSubmitting?e.jsx(W.Loader,{className:"animate-spin"}):e.jsx(e.Fragment,{}),onClick:n(D),disabled:S.isSubmitting,children:j?"ثبت":"ویرایش"})})]})]})}),v.assistantCenter&&e.jsx(Tt,{onClose:()=>y(c=>({...c,assistantCenter:!1}))}),v.assistantServices&&e.jsx(ht,{children:e.jsx(pt,{onClose:()=>y(c=>({...c,assistantServices:!1})),assistantId:I,assistantName:`${t==null?void 0:t.firstName} ${t==null?void 0:t.lastName}`})}),v.assistantShift&&e.jsx(Lt,{onClose:()=>y(c=>({...c,assistantShift:!1})),assistantName:`${t==null?void 0:t.firstName} ${t==null?void 0:t.lastName}`})]})},te="sm:px-5 lg:px-10 flex justify-center items-center min-h-screen",Bt=()=>{const{userType:a}=B(o=>o.user),{doctor:l,secretary:p,assistant:b}=je;switch(+a){case l:return e.jsx(z,{component:"section",className:te,children:e.jsx(Nt,{})});case b:return e.jsx(z,{component:"section",className:te,children:e.jsx(_t,{})});case p:return e.jsx(z,{component:"section",className:te,children:e.jsx(At,{})});default:return e.jsx(e.Fragment,{})}},as=()=>e.jsx(Bt,{});export{as as default};
