| Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/ |
| Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/Topbar-B5bd8XQJ.js |
import{c as be,j as e,a as D,Y as ye,r as u,f as ve,g as Ce,h as Se,v as ke,e as Pe,l as Ee,Q as re,w as _e,Z as Me,$ as K,x as E,B as _,T as b,y as t,J as Ae,P as T,a0 as Fe,S as Le,E as I,M as X,a1 as Oe,O as ze,H as Ie,C as Ne}from"./index-f5FVPPWf.js";import{a as Be,u as $e,b as De}from"./HasPermission-D75jcuOi.js";import{u as ne,b as ee,A as se,I as R,c as We}from"./index-B8iLT9XL.js";import{F as Re,a as Ue,b as oe,c as Te}from"./index-D-rZ_zLU.js";import{u as Ve,R as He}from"./index-DF-qEIee.js";import{u as V,M as ie,b as le,a as ce,c as Ye,g as qe,d as de,F as M,L as Ge,e as Qe,f as $,h as Ze,S as Je}from"./index.esm-CxKpqEdJ.js";import{B as ae,a as Ke,b as Xe}from"./index-BKMb1XXn.js";import{u as es,a as ss}from"./SettingData-HUsgVeqA.js";import{M as me,a as ue,b as he,c as N}from"./menu-list-UQBnhbZh.js";import{D as xe}from"./use-clickable-DJbYv-Vn.js";import{u as pe}from"./useMutation-DWP0Ot2c.js";import{F as os}from"./ForgetPassword-C59i2kT5.js";import{c as as,d as A,F,I as S}from"./input-aKY8cD2r.js";import{I as L}from"./input-group-BHnguFbm.js";import{I as te,a as B}from"./input-element-BYMpvziJ.js";import{i as W}from"./image-DDwLQVjO.js";import{V as ts}from"./v-stack-BQpqK5ry.js";const[rs,ns]=be({name:"AvatarStylesContext",hookName:"useAvatarStyles",providerName:"<Avatar/>"});function is(a){const s=a.trim().split(" "),o=s[0]??"",n=s.length>1?s[s.length-1]:"";return o&&n?`${o.charAt(0)}${n.charAt(0)}`:o.charAt(0)}function fe(a){const{name:s,getInitials:o,...n}=a,h=ns();return e.jsx(D.div,{role:"img","aria-label":s,...n,__css:h.label,children:s?o==null?void 0:o(s):null})}fe.displayName="AvatarName";const je=a=>e.jsxs(D.svg,{viewBox:"0 0 128 128",color:"#fff",width:"100%",height:"100%",className:"chakra-avatar__svg",...a,children:[e.jsx("path",{fill:"currentColor",d:"M103,102.1388 C93.094,111.92 79.3504,118 64.1638,118 C48.8056,118 34.9294,111.768 25,101.7892 L25,95.2 C25,86.8096 31.981,80 40.6,80 L87.4,80 C96.019,80 103,86.8096 103,95.2 L103,102.1388 Z"}),e.jsx("path",{fill:"currentColor",d:"M63.9961647,24 C51.2938136,24 41,34.2938136 41,46.9961647 C41,59.7061864 51.2938136,70 63.9961647,70 C76.6985159,70 87,59.7061864 87,46.9961647 C87,34.2938136 76.6985159,24 63.9961647,24"})]});function ge(a){const{src:s,srcSet:o,onError:n,onLoad:h,getInitials:d,name:c,borderRadius:f,loading:m,iconLabel:i,icon:p=e.jsx(je,{}),ignoreFallback:r,referrerPolicy:j,crossOrigin:x}=a,g=ye({src:s,onError:n,crossOrigin:x,ignoreFallback:r})==="loaded";return!s||!g?c?e.jsx(fe,{className:"chakra-avatar__initials",getInitials:d,name:c}):u.cloneElement(p,{role:"img","aria-label":i}):e.jsx(D.img,{src:s,srcSet:o,alt:c??i,onLoad:h,referrerPolicy:j,crossOrigin:x??void 0,className:"chakra-avatar__img",loading:m,__css:{width:"100%",height:"100%",objectFit:"cover",borderRadius:f}})}ge.displayName="AvatarImage";const ls=ke({display:"inline-flex",alignItems:"center",justifyContent:"center",textAlign:"center",textTransform:"uppercase",fontWeight:"medium",position:"relative",flexShrink:0}),U=ve((a,s)=>{const o=Ce("Avatar",a),[n,h]=u.useState(!1),{src:d,srcSet:c,name:f,showBorder:m,borderRadius:i="full",onError:p,onLoad:r,getInitials:j=is,icon:x=e.jsx(je,{}),iconLabel:y=" avatar",loading:g,children:k,borderColor:v,ignoreFallback:C,crossOrigin:l,referrerPolicy:w,...z}=Se(a),O={borderRadius:i,borderWidth:m?"2px":void 0,...ls,...o.container};return v&&(O.borderColor=v),e.jsx(D.span,{ref:s,...z,className:Ee("chakra-avatar",a.className),"data-loaded":Pe(n),__css:O,children:e.jsxs(rs,{value:o,children:[e.jsx(ge,{src:d,srcSet:c,loading:g,onLoad:as(r,()=>{h(!0)}),onError:p,getInitials:j,name:f,borderRadius:i,icon:x,iconLabel:y,ignoreFallback:C,crossOrigin:l,referrerPolicy:w}),k]})})});U.displayName="Avatar";const cs=async()=>{let a=t.role.name==="Doctor"?`get_doctor_notification/doctor/${t.id}`:"get_doctor_notification";return(await Ae(t.token,a)).data};function ds(){const[a,s]=u.useState(!1),[o,n]=u.useState(!1),h=V(),d=re(),c="/admin/",f=new Audio(`${c}/notification.mp3`),m=_e();u.useEffect(()=>{const r=Me(K,j=>{f.play().catch(g=>console.error("Error playing sound:",g)),s(!0),m.invalidateQueries(["doctor-notification"]);const{title:x,body:y}=j.notification;return h({title:x,description:y,status:"info",duration:5e3,isClosable:!0,position:"top"})});return()=>r()},[K]);const{data:i,isLoading:p}=es({queryFn:cs,queryKey:["doctor-notification"]});return e.jsxs(me,{isOpen:o,onClose:()=>n(!1),children:[e.jsxs(ue,{as:E,variant:"ghost",colorScheme:"black",pos:"relative",onClick:()=>{s(!1),n(!0)},children:[e.jsx(Be,{fontSize:"18px"}),a&&e.jsx(_,{bg:"blue.500",borderRadius:"full",position:"absolute",top:"2",right:"3",w:2,h:2})]}),e.jsxs(he,{minW:"600px",maxH:"60vh",overflow:"hide",overflowY:"scroll",pt:0,children:[e.jsx(b,{p:2,fontSize:18,fontWeight:600,textAlign:"center",children:"Notifications"}),e.jsx(xe,{}),p?e.jsx(b,{p:4,children:"Loading"}):i==null?void 0:i.slice(0,20).map(r=>e.jsxs(_,{p:4,m:2,borderWidth:"1px",borderRadius:"lg",boxShadow:"sm",_hover:{boxShadow:"md"},maxW:"600px",cursor:"pointer",onClick:()=>{n(!1),r.file_id?d(`appointment/${r.appointment_id}`):r.prescription_id?d(`appointment/${r.appointment_id}`):r.appointment_id?d(`appointment/${r.appointment_id}`):d(`appointment/${r.appointment_id}`)},children:[e.jsx(b,{fontSize:"md",fontWeight:"bold",children:r.title}),e.jsx(b,{fontSize:"sm",color:"gray.500",children:r.body})]},r.id)),(i==null?void 0:i.length)===0&&e.jsx(_,{p:4,m:2,borderWidth:"1px",borderRadius:"lg",boxShadow:"sm",children:e.jsx(b,{children:"No notifications"})})]})]})}const ms=async a=>{let s={email:t.email,password:a};return(await T(t.token,"login",s)).status},us=async a=>{let s={user_id:t.id,password:a};const o=await T(t.token,"update_password",s);if(o.response!==200)throw new Error(o.message);return o};function hs({isOpen:a,onClose:s}){const[o,n]=u.useState(!1),[h,d]=u.useState(!1),[c,f]=u.useState(""),[m,i]=u.useState(""),[p,r]=u.useState(""),j=V(),{isOpen:x,onOpen:y,onClose:g}=ne(),k=l=>{l(w=>!w)},v=()=>c?m?p?p!==m?"Password Does not match!":null:"Confirm Password":"New Password":"Old Password",C=pe({mutationFn:async()=>{const l=v();if(l)throw new Error(`Please Enter ${l}`);const w=await ms(c);if(w===!1||!w||w!==!0)throw new Error("Incorrect Old password");await us(m)},onError:l=>{$(j,"error",l.message)},onSuccess:()=>{i(),f(),r(),$(j,"success","Success"),s()}});return e.jsxs(e.Fragment,{children:[" ",e.jsxs(ie,{isOpen:a,onClose:s,isCentered:!0,children:[e.jsx(le,{}),e.jsxs(ce,{children:[e.jsx(Ye,{children:"Update Password"}),e.jsx(qe,{}),e.jsxs(de,{children:[e.jsxs(A,{mb:4,children:[e.jsxs(F,{alignItems:"start",justifyContent:"space-between",children:[" ",e.jsx(M,{children:"Old Password"}),e.jsx(Ge,{fontSize:12,color:"blue.500",onClick:y,textDecor:"underline",children:"Forget password?"})]}),e.jsxs(L,{children:[e.jsx(S,{type:o?"text":"password",placeholder:"Enter Old password",value:c,onChange:l=>f(l.target.value)}),e.jsx(te,{width:"4.5rem",children:e.jsx(E,{h:"1.75rem",size:"sm",onClick:()=>k(n),children:o?e.jsx(ee,{}):e.jsx(se,{})})})]})]}),e.jsxs(A,{mb:4,children:[e.jsx(M,{children:"New Password"}),e.jsxs(L,{children:[e.jsx(S,{type:h?"text":"password",placeholder:"Enter new password",value:m,onChange:l=>i(l.target.value)}),e.jsx(te,{width:"4.5rem",children:e.jsx(E,{h:"1.75rem",size:"sm",onClick:()=>k(d),children:h?e.jsx(ee,{}):e.jsx(se,{})})})]})]}),e.jsxs(A,{mb:4,children:[e.jsx(M,{children:"Confirm New Password"}),e.jsx(S,{type:"text",placeholder:"Confirm new password",value:p,onChange:l=>r(l.target.value)})]})]}),e.jsxs(Qe,{children:[e.jsx(E,{variant:"ghost",onClick:s,children:"Close"}),e.jsx(E,{colorScheme:"blue",mr:3,onClick:C.mutate,isLoading:C.isPending,children:"Update Password"})]})]})]}),e.jsx(os,{isOpen:x,onClose:g})]})}const xs=async a=>{const s=await T(t.token,"update_user",a);if(s.response!==200)throw new Error(s.message);return s};function Os(){var z,O,H,Y,q,G,Q,Z,J;const[a,s]=u.useState(!1),{colorMode:o,toggleColorMode:n}=Fe(),d=Le().pathname.split("/")[1],{register:c,handleSubmit:f}=Ze(),[m]=Ve("(max-width: 600px)"),{isOpen:i,onOpen:p,onClose:r}=ne(),j=re(),{settingsData:x}=ss(),{hasPermission:y}=$e(),g=V(),k=()=>s(!0),v=()=>s(!1);u.useEffect(()=>{o==="dark"?document.body.classList.add("dark"):document.body.classList.remove("dark")},[o]);const C=x==null?void 0:x.find(P=>P.id_name==="logo"),l=pe({mutationFn:async P=>{await xs(P)},onError:P=>{$(g,"error",P.message)},onSuccess:()=>{$(g,"success","updated!"),v()}}),w=P=>{const we={...P,id:t.id};l.mutate(we)};return e.jsxs(F,{as:"header",align:"center",justify:"space-between",px:"4",py:"2",bg:I("white","gray.800"),boxShadow:"none",zIndex:"sticky",top:"0",position:"sticky",borderBottom:"1px solid",borderColor:I("gray.200","gray.600"),children:[e.jsxs(_,{display:"flex",alignItems:"center",gap:5,children:[" ",e.jsx(X,{w:12,src:`${W}/${C==null?void 0:C.value}`,fallbackSrc:"/logo.png"}),e.jsx(b,{fontSize:"xl",fontWeight:"500",mb:0,textTransform:"capitalize",children:d||"Dashboard"})]}),e.jsxs(F,{children:[e.jsx(ds,{}),e.jsx(R,{"aria-label":"Toggle color mode",icon:o==="light"?e.jsx(Re,{}):e.jsx(Ue,{}),onClick:()=>{n(),o==="light"?document.body.classList.add("dark"):document.body.classList.remove("dark")},variant:"ghost",colorScheme:"black"})," ",e.jsxs(me,{children:[e.jsx(ue,{as:R,variant:"ghost",colorScheme:"black",icon:e.jsx(oe,{})}),e.jsxs(he,{children:[e.jsxs(_,{p:2,w:300,children:[e.jsx(F,{justify:"center",children:e.jsx(U,{src:`${W}/${t.image}`,fallbackSrc:"/admin/profile.png",w:16})}),e.jsxs(b,{textAlign:"center",mt:2,fontSize:"lg",children:[t.f_name," ",t.l_name]}),e.jsx(b,{textAlign:"center",fontSize:"md",fontWeight:600,children:t.role.name})]}),e.jsx(xe,{mb:3}),e.jsx(N,{onClick:k,icon:e.jsx(oe,{}),children:"Account"}),e.jsx(N,{onClick:p,icon:e.jsx(He,{}),children:"Change Password"}),y("SETTING_VIEW")&&e.jsx(N,{onClick:()=>{j("/settings")},icon:e.jsx(We,{}),children:"Settings"}),e.jsx(N,{icon:e.jsx(Te,{}),onClick:()=>{Oe()},children:"Logout"})]})]})]}),e.jsxs(ie,{isOpen:a,onClose:v,isCentered:!0,scrollBehavior:m?"outside":"inside",size:"xl",children:[e.jsx(le,{}),e.jsxs(ce,{p:0,m:2,bg:"transparent",children:[" ",e.jsxs(de,{p:0,sx:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none",msOverflowStyle:"none"},as:"form",onSubmit:f(w),children:[" ",e.jsx(ze,{py:0,width:"100%",minHeight:!m&&"80vh",children:e.jsxs(_,{maxW:"100%",w:"full",bg:I("white","gray.800"),boxShadow:"2xl",rounded:"md",overflow:"hidden",children:[e.jsx(X,{h:"120px",w:"full",src:"https://images.unsplash.com/photo-1612865547334-09cb8cb455da?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80",objectFit:"cover",alt:"#"}),e.jsxs(F,{justify:"center",mt:-12,pos:"relative",children:[e.jsx(U,{size:"xl",name:`${(z=t)==null?void 0:z.f_name} ${(O=t)==null?void 0:O.l_name}`,src:`${W}/${t.image}`,fallbackSrc:"/vite.svg"}),e.jsx(ps,{})]}),e.jsxs(_,{p:6,children:[e.jsxs(Je,{spacing:0,align:"center",mb:5,children:[e.jsxs(Ie,{fontSize:"lg",fontWeight:500,fontFamily:"body",children:[(H=t)==null?void 0:H.f_name," ",(Y=t)==null?void 0:Y.l_name]}),e.jsxs(b,{color:"gray.500",fontSize:"xs",children:["Member Since"," ",Ne((q=t)==null?void 0:q.created_at).format("MMM DD YYYY")]})]}),e.jsxs(ts,{direction:"row",justify:"center",spacing:6,children:[e.jsxs(F,{gap:4,children:[" ",e.jsxs(A,{id:"name",children:[e.jsx(M,{children:"First Name"}),e.jsxs(L,{borderColor:"#E0E1E7",children:[e.jsx(B,{pointerEvents:"none",children:e.jsx(ae,{color:"gray.800"})}),e.jsx(S,{type:"text",size:"md",defaultValue:(G=t)==null?void 0:G.f_name,...c("f_name",{required:!0})})]})]})," ",e.jsxs(A,{id:"name",children:[e.jsx(M,{children:"Name"}),e.jsxs(L,{borderColor:"#E0E1E7",children:[e.jsx(B,{pointerEvents:"none",children:e.jsx(ae,{color:"gray.800"})}),e.jsx(S,{type:"text",size:"md",defaultValue:(Q=t)==null?void 0:Q.l_name,...c("l_name",{required:!0})})]})]})]}),e.jsxs(A,{id:"email",children:[e.jsx(M,{children:"Email"}),e.jsxs(L,{borderColor:"#E0E1E7",children:[e.jsx(B,{pointerEvents:"none",children:e.jsx(Ke,{color:"gray.800"})}),e.jsx(S,{type:"email",size:"md",defaultValue:(Z=t)==null?void 0:Z.email,...c("email",{required:!1,pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$"})})]})]}),e.jsxs(A,{id:"Phone",children:[e.jsx(M,{children:"Phone"}),e.jsxs(L,{borderColor:"#E0E1E7",children:[e.jsx(B,{pointerEvents:"none",children:e.jsx(Xe,{color:"gray.800"})}),e.jsx(S,{isDisabled:!0,type:"tel",size:"md",value:(J=t)==null?void 0:J.phone})]})]})]}),e.jsx(E,{size:"sm",w:"full",mt:8,colorScheme:"blue",color:"white",rounded:"md",_hover:{transform:"translateY(-2px)",boxShadow:"lg"},type:"submit",isLoading:l.isPending,children:"Update"}),e.jsx(E,{mt:2,size:"sm",w:"full",bg:I("gray.600","gray.600"),color:"white",rounded:"md",_hover:{transform:"translateY(-2px)",boxShadow:"lg"},onClick:v,children:"Close"})]})]})})]})]})]}),e.jsx(hs,{isOpen:i,onClose:r})]})}const ps=()=>{const a=u.useRef(null),s=()=>{a.current.click()},o=n=>{n.target.files[0]};return e.jsxs(e.Fragment,{children:[e.jsx(R,{icon:e.jsx(De,{fontSize:16}),colorScheme:"blue",onClick:s,size:"sm"}),e.jsx(S,{type:"file",ref:a,display:"none",onChange:o})]})};export{Os as default};