| Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/ |
| Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/Index-DrWRMA-s.js |
import{r as y,w as A,j as e,x as k,D as $,y as C,Q as Y,B as g,F as O,aB as E,J as G}from"./index-C50MwByD.js";import{F as V}from"./index-DHZdk_rm.js";import{e as K}from"./index-DRh_GsH6.js";import{u as X}from"./SettingData-DaA8YzRn.js";import{u as z}from"./useMutation-DiBhxv_U.js";import{A as Z,a as ee,N as se,S as c,D as te}from"./Dashboard-BGHL639E.js";import{u as w,b as oe,c as re,d as ie,e as ne,f as u}from"./index.esm-BgKkBPdO.js";import{u as v}from"./HasPermission-BP0YFq1v.js";import{g as ae}from"./configs-DhawEOn8.js";import{F as S,I as ce,d as F}from"./input-BS5AKlHW.js";import{u as le,I as T}from"./index-Ntz7vSIm.js";import{S as I}from"./switch-DqdMLTJN.js";import"./image-Bvdr-O-Y.js";import"./tr-DxO73Jya.js";import"./use-clickable-BAx6nmpu.js";import"./visually-hidden.style-C5P7rhbc.js";function de({isOpen:l,onClose:n,data:t}){const r=w(),i=y.useRef(),h=A(),[p,s]=y.useState(),a=async()=>{let m={id:t.id};try{s(!0);const o=await $(C.token,"delete_specialization",m);s(!1),o.response===200?(u(r,"success","Doctor Deleted!"),h.invalidateQueries("doctors"),n()):u(r,"error",o.message)}catch(o){s(!1),u(r,"error",JSON.stringify(o))}};return e.jsx(Z,{isOpen:l,onClose:n,leastDestructiveRef:i,isCentered:!0,children:e.jsx(oe,{children:e.jsxs(ee,{children:[e.jsxs(re,{fontSize:"lg",fontWeight:"semi-bold",children:["Delete Doctor ("," ",e.jsxs("b",{children:[t==null?void 0:t.id," , ",t==null?void 0:t.f_name," ",t==null?void 0:t.l_name]})," ",")"]}),e.jsx(ie,{children:"Are you sure? You can not undo this action afterwards."}),e.jsxs(ne,{children:[e.jsx(k,{ref:i,onClick:n,colorScheme:"gray",size:"sm",children:"Cancel"}),e.jsx(k,{colorScheme:"red",onClick:a,ml:3,size:"sm",isLoading:p,children:"Delete Doctor"})]})]})})})}function Te(){const{hasPermission:l}=v(),[n,t]=y.useState(),[r,i]=y.useState(),{isOpen:h,onClose:p}=le(),s=Y(),a=w(),m="Errortoast",o=async()=>{await ae();const d=await G(C.token,"get_doctor");return d==null?void 0:d.data.map(f=>{const{id:j,user_id:x,image:D,f_name:U,l_name:N,phone:L,email:q,specialization:M,department_name:J,active:H,stop_booking:W}=f;return{id:j,UserID:x,image:D,Name:`${U} ${N}`,phone:L,email:q,specialization:M,dept:J,active:e.jsx(me,{id:x,isActive:H}),"Stop Booking":e.jsx(he,{id:x,isStop_booking:W})}})},P=d=>{t(d)},{isLoading:Q,data:_,error:R}=X({queryKey:["doctors"],queryFn:o});R&&(a.isActive(m)||a({id:m,title:"oops!.",description:"Something bad happens.",status:"error",duration:2e3,isClosable:!0,position:"top"}));function B(d,b=""){return b?d.filter(f=>{var j;for(const x in f){const D=(j=f[x])==null?void 0:j.toString().toLowerCase();if(D&&D.includes(b.toLowerCase()))return!0}return!1}):d}return l("DOCTOR_VIEW")?e.jsxs(g,{children:[Q||!_?e.jsxs(g,{children:[e.jsxs(S,{mb:5,justify:"space-between",children:[e.jsx(c,{w:400,h:8}),e.jsx(c,{w:200,h:8})]}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2}),e.jsx(c,{h:10,w:"100%",mt:2})]}):e.jsxs(g,{children:[e.jsxs(S,{mb:5,justify:"space-between",align:"center",children:[e.jsx(ce,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:d=>{i(d.target.value)}}),e.jsx(g,{children:e.jsx(k,{isDisabled:!l("DOCTOR_ADD"),size:"sm",colorScheme:"blue",onClick:()=>{s("/doctors/add")},children:"Add New"})})]}),e.jsx(te,{data:B(_,r),onActionClick:e.jsx(ue,{onClick:P,navigate:s})})]}),e.jsx(de,{isOpen:h,onClose:p,data:n})]}):e.jsx(se,{})}const ue=({onClick:l,rowData:n,DeleteonOpen:t,navigate:r})=>{const{hasPermission:i}=v();return e.jsxs(S,{justify:"center",children:[e.jsx(T,{isDisabled:!i("DOCTOR_UPDATE"),size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{l(n),r(`/doctor/update/${n.UserID}`)},icon:e.jsx(K,{fontSize:18,color:O.colors.blue[500]})}),e.jsx(T,{isDisabled:!i("DOCTOR_UPDATE"),size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{l(n),t()},icon:e.jsx(V,{fontSize:18,color:O.colors.red[500]})})]})},me=({id:l,isActive:n})=>{const{hasPermission:t}=v(),r=w(),i=A(),h=async(s,a)=>{let m={id:s,active:a};try{const o=await E(C.token,"update_doctor",m);o.response===200?(u(r,"success","Doctor Updated!"),i.invalidateQueries("doctors"),i.invalidateQueries(["doctors","dashboard"]),i.invalidateQueries(["doctor",s])):u(r,"error",o.message)}catch(o){u(r,"error",JSON.stringify(o))}},p=z({mutationFn:async s=>{await h(s.id,s.active)}});return e.jsx(F,{display:"flex",alignItems:"center",children:e.jsx(I,{isDisabled:!t("DOCTOR_UPDATE"),defaultChecked:n===1,size:"sm",onChange:s=>{let a=s.target.checked?1:0;p.mutate({id:l,active:a})}})})},he=({id:l,isStop_booking:n})=>{const{hasPermission:t}=v(),r=w(),i=A(),h=async(s,a)=>{let m={id:s,stop_booking:a};try{const o=await E(C.token,"update_doctor",m);o.response===200?(u(r,"success","Doctor Updated!"),i.invalidateQueries("doctors"),i.invalidateQueries(["doctors","dashboard"]),i.invalidateQueries(["doctor",s])):u(r,"error",o.message)}catch(o){u(r,"error",JSON.stringify(o))}},p=z({mutationFn:async s=>{await h(s.id,s.stop_booking)}});return e.jsx(F,{display:"flex",alignItems:"center",children:e.jsx(I,{isDisabled:!t("DOCTOR_UPDATE"),defaultChecked:n===1,size:"sm",onChange:s=>{let a=s.target.checked?1:0;p.mutate({id:l,stop_booking:a})}})})};export{me as IsActive,he as StopBooking,Te as default};