| Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/ |
| Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/Index-C_s3t83f.js |
import{r as m,w as T,j as e,B as y,x as g,aB as fe,y as k,D as De,C as f,Q as ge,F as P,J as Ce,L as _e}from"./index-C50MwByD.js";import{u as H,i as q}from"./HasPermission-BP0YFq1v.js";import{F as ye}from"./index-DHZdk_rm.js";import{e as ke}from"./index-DRh_GsH6.js";import{u as be}from"./SettingData-DaA8YzRn.js";import{A as we,a as Se,u as Ee,N as Ye,S as o,i as Me,D as Ae,P as $e,n as ve}from"./Dashboard-BGHL639E.js";import{A as ze}from"./Add-Cfb4QKrh.js";import{h as Ie,u as $,M as Oe,b as Q,a as Re,c as U,g as Be,d as K,F as Y,e as V,f as D}from"./index.esm-BgKkBPdO.js";import{t as Fe}from"./today-D_vLUvRX.js";import{D as L}from"./use-clickable-BAx6nmpu.js";import{d as M,I as S,F as j}from"./input-BS5AKlHW.js";import{u as A,I as N}from"./index-Ntz7vSIm.js";import"./image-Bvdr-O-Y.js";import"./tr-DxO73Jya.js";import"./visually-hidden.style-C5P7rhbc.js";function Pe({isOpen:r,onClose:t,data:s}){const[n,i]=m.useState(),{register:h,handleSubmit:u,reset:p}=Ie(),x=T(),c=$(),l=async b=>{let E={...b,id:s.id};try{i(!0);const d=await fe(k.token,"update_appointment_checkin",E);i(!1),d.response===200?(D(c,"success","Updated!"),x.invalidateQueries("checkins"),p(),t()):D(c,"error",d.message)}catch(d){i(!1),D(c,"error",JSON.stringify(d))}};return e.jsxs(Oe,{isOpen:r,onClose:t,isCentered:!0,size:"lg",scrollBehavior:"inside",children:[e.jsx(Q,{}),e.jsxs(Re,{as:"form",onSubmit:u(l),children:[e.jsx(U,{fontSize:18,py:2,children:"Update Checkin"}),e.jsx(Be,{}),e.jsx(L,{}),e.jsxs(K,{children:[" ",e.jsxs(y,{pb:3,children:[e.jsxs(M,{isRequired:!0,children:[e.jsx(Y,{children:"Appointment ID"}),e.jsx(S,{size:"sm",defaultValue:s==null?void 0:s.appointment_id,placeholder:"Appointment ID",...h("appointment_id",{required:!0})})]}),e.jsxs(M,{isRequired:!0,mt:3,children:[e.jsx(Y,{children:"Date"}),e.jsx(S,{max:Fe(),defaultValue:s==null?void 0:s.date,size:"sm",type:"date",step:60,placeholder:"Date",...h("date",{required:!0}),isDisabled:!0})]}),e.jsxs(M,{isRequired:!0,mt:3,children:[e.jsx(Y,{children:"End Date"}),e.jsx(S,{defaultValue:s==null?void 0:s.time,size:"sm",type:"time",step:60,placeholder:"time",...h("time",{required:!0})})]})]})]}),e.jsx(L,{}),e.jsxs(V,{py:3,children:[e.jsx(g,{colorScheme:"gray",mr:3,onClick:t,size:"sm",children:"Close"}),e.jsx(g,{variant:"solid",size:"sm",colorScheme:"blue",type:"submit",isLoading:n,children:"Update Checkin"})]})]})]})}function qe({isOpen:r,onClose:t,data:s}){const n=$(),i=m.useRef(),h=T(),[u,p]=m.useState(),x=async()=>{let c={id:s.id};try{p(!0);const l=await De(k.token,"delete_appointment_checkin",c);p(!1),l.response===200?(D(n,"success","Deleted!"),h.invalidateQueries("checkins"),t()):D(n,"error",l.message)}catch(l){p(!1),D(n,"error",JSON.stringify(l))}};return e.jsx(we,{isOpen:r,onClose:t,leastDestructiveRef:i,isCentered:!0,children:e.jsx(Q,{children:e.jsxs(Se,{children:[e.jsxs(U,{fontSize:"lg",fontWeight:"semi-bold",children:["Delete Checkin ("," ",e.jsxs("b",{children:[s==null?void 0:s.id," , ",s==null?void 0:s.time," ",s==null?void 0:s.date]})," ",")"]}),e.jsx(K,{children:"Are you sure? You can not undo this action afterwards."}),e.jsxs(V,{children:[e.jsx(g,{ref:i,onClick:t,colorScheme:"gray",size:"sm",children:"Cancel"}),e.jsx(g,{colorScheme:"red",onClick:x,ml:3,size:"sm",isLoading:u,children:"Delete"})]})]})})})}const Le=f().subtract(ve,"days").format("YYYY-MM-DD"),Ne=f().format("YYYY-MM-DD"),Te=(r,t)=>{const s=(r-1)*t;let n=s+t-1;return{startIndex:s,endIndex:n}};function as(){const{hasPermission:r}=H(),[t,s]=m.useState(),{isOpen:n,onOpen:i,onClose:h}=A(),[u,p]=m.useState(1),{startIndex:x,endIndex:c}=Te(u,50),l=m.useRef(null),[b,E]=m.useState(""),d=Ee(b,1e3),[w,J]=m.useState({startDate:Le,endDate:Ne}),v=f(w.startDate).format("YYYY-MM-DD"),z=f(w.endDate).format("YYYY-MM-DD"),{isOpen:I,onOpen:W,onClose:G}=A(),{isOpen:O,onOpen:X,onClose:Z}=A(),ee=ge(),R=$(),B="Errortoast",se=async()=>{const a=k.role.name==="Doctor"?`get_appointment_check_in_page?start=${x}&end=${c}&search=${d}&start_date=${v}&end_date=${z}&doctor_id=${k.id}`:`get_appointment_check_in_page?start=${x}&end=${c}&search=${d}&start_date=${v}&end_date=${z}`,_=await Ce(k.token,a);return console.log(_),{data:_==null?void 0:_.data.map(ae=>{const{id:ce,appointment_id:F,time:le,date:de,created_at:me,updated_at:he,doct_f_name:ue,doct_l_name:pe,patient_f_name:xe,patient_l_name:je}=ae;return{id:ce,app_id:e.jsx(_e,{to:`/appointment/${F}`,children:e.jsxs(j,{gap:1,align:"center",children:[F," ",e.jsx(q,{})]})}),doctor:`${ue} ${pe}`,patient:`${xe} ${je}`,Date:f(de).format("DD MMM YYYY"),Time:f(le,"HH:mm:ss").format("hh:mm A"),created_at:me,updated_at:he}}),total_record:_.total_record}},te=a=>{s(a)},{isLoading:ne,data:C,error:oe}=be({queryKey:["checkins",u,d,w],queryFn:se}),re=a=>{p(a)},ie=Math.ceil((C==null?void 0:C.total_record)/50);return oe&&(R.isActive(B)||R({id:B,title:"oops!.",description:"Something bad happens.",status:"error",duration:2e3,isClosable:!0,position:"top"})),r("CHECKIN_VIEW")?e.jsxs(y,{ref:l,children:[ne||!C?e.jsxs(y,{children:[e.jsxs(j,{mb:5,justify:"space-between",children:[e.jsx(o,{w:400,h:8}),e.jsx(o,{w:200,h:8})]}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2}),e.jsx(o,{h:10,w:"100%",mt:2})]}):e.jsxs(y,{children:[e.jsxs(j,{mb:5,justify:"space-between",align:"center",children:[e.jsx(S,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:a=>E(a.target.value),value:b}),e.jsx(Me,{dateRange:w,setDateRange:J,size:"md"}),e.jsx(y,{children:e.jsxs(j,{align:"center",gap:5,children:[" ",e.jsx(g,{size:"sm",colorScheme:"blue",onClick:()=>{const a=`${window.location.protocol}//${window.location.host}`;window.open(`${a}/admin/queue`,"_blank")},rightIcon:e.jsx(q,{}),children:"Show Checkin Display"}),e.jsx(g,{isDisabled:!r("CHECKIN_ADD"),size:"sm",colorScheme:"blue",onClick:()=>{i()},children:"New Checkin"})]})})]}),e.jsx(Ae,{data:C.data,onActionClick:e.jsx(He,{onClick:te,navigate:ee,EditonOpen:W,DeleteonOpen:X})})]}),e.jsx(j,{justify:"center",mt:4,children:e.jsx($e,{currentPage:u,onPageChange:re,totalPages:ie})}),n&&e.jsx(ze,{isOpen:n,onClose:h}),I&&e.jsx(Pe,{data:t,isOpen:I,onClose:G}),O&&e.jsx(qe,{isOpen:O,onClose:Z,data:t})]}):e.jsx(Ye,{})}const He=({onClick:r,rowData:t,DeleteonOpen:s,EditonOpen:n})=>{const{hasPermission:i}=H();return e.jsxs(j,{justify:"center",children:[e.jsx(N,{isDisabled:!i("CHECKIN_UPDATE"),size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{r(t),n()},icon:e.jsx(ke,{fontSize:18,color:P.colors.blue[500]})}),e.jsx(N,{isDisabled:!i("CHECKIN_DELETE"),size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{r(t),s()},icon:e.jsx(ye,{fontSize:18,color:P.colors.red[500]})})]})};export{as as default};