| Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/ |
| Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/Index-BTsBYTon.js |
import{r as o,C as h,j as e,B as _,F as ue,G as pe,y as j,J as Z,L as f}from"./index-f5FVPPWf.js";import{e as me}from"./index-D-rZ_zLU.js";import{u as ee}from"./SettingData-HUsgVeqA.js";import{u as te,N as ne,S as D,i as ae,D as se,P as oe,c as xe,d as _e,e as J,f as ge,h as U}from"./Dashboard-QYea_GjR.js";import{T as he,p as je}from"./printPDF-Ded9xNLv.js";import{u as re}from"./HasPermission-D75jcuOi.js";import{u as ie}from"./index.esm-CxKpqEdJ.js";import{F as l,I as ce}from"./input-aKY8cD2r.js";import{I as de}from"./index-B8iLT9XL.js";import{B as X}from"./visually-hidden.style-BrEqndXz.js";import"./index-NjlW3JBs.js";import"./image-DDwLQVjO.js";import"./tr-SHTCPR9-.js";import"./use-clickable-DJbYv-Vn.js";const fe=(n,t)=>{const r=(n-1)*t;let a=r+t-1;return{startIndex:r,endIndex:a}},le="Errortoast";function De(){const[n,t]=o.useState(),{hasPermission:r}=re(),a=ie(),[i,P]=o.useState(1),g=o.useRef(null),[v,$]=o.useState(""),s=te(v,1e3),[m,A]=o.useState({startDate:null,endDate:null}),y=m.startDate?h(m.startDate).format("YYYY-MM-DD"):"",I=m.endDate?h(m.endDate).format("YYYY-MM-DD"):"",{startIndex:S,endIndex:u}=fe(i,50),E=async()=>{const p=j.role.name==="Doctor"?`get_invoices/page?start=${S}&end=${u}&search=${s}&start_date=${y}&end_date=${I}&doctor_id=${j.id}`:`get_invoices/page?start=${S}&end=${u}&search=${s}&start_date=${y}&end_date=${I}`,b=await Z(j.token,p);return{data:b==null?void 0:b.data.map(Q=>{const{id:C,user_id:w,patient_id:B,appointment_id:T,status:L,total_amount:V,invoice_date:W,created_at:q,patient_f_name:k,patient_l_name:O,user_f_name:N,user_l_name:R,coupon_title:G,coupon_value:K,coupon_off_amount:H}=Q;return{id:C,status:L,total_Amount:V,applied_coupon:G||"N/A","coupon value (%)":K||"N/A",coupon_off_amount:H||0,invoice_Date:h(W).format("D MMM YY"),patient:k?e.jsx(f,{to:`/patient/${B}`,children:`${k} ${O}`}):"N/A",user:w?e.jsx(f,{to:`/user/${w}`,children:`${N} ${R}`}):"N/A",appointmentID:e.jsx(f,{to:`/appointment/${T}`,children:T}),createdAt:h(q).format("D MMM YY hh:mmA")}}),total_record:b.total_record}},z=p=>{t(p)},{isLoading:x,data:c,error:M}=ee({queryKey:["invoices",i,s,m],queryFn:E}),F=p=>{P(p)},d=Math.ceil((c==null?void 0:c.total_record)/50);return M&&(a.isActive(le)||a({id:le,title:"oops!",description:"Something bad happens.",status:"error",duration:2e3,isClosable:!0,position:"top"})),o.useEffect(()=>{g.current&&g.current.scrollIntoView({behavior:"smooth",block:"start"})},[i]),r("APPOINTMENT_INVOICE_VIEW")?e.jsxs(_,{ref:g,children:[x||!c?e.jsxs(_,{children:[e.jsxs(l,{mb:5,justify:"space-between",children:[e.jsx(D,{w:400,h:8}),e.jsx(D,{w:50,h:8})]}),e.jsx(D,{h:300,w:"100%"})]}):e.jsxs(_,{children:[e.jsx(l,{mb:5,justify:"space-between",align:"center",children:e.jsxs(l,{align:"center",gap:4,children:[e.jsx(ce,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:p=>$(p.target.value)}),e.jsx(ae,{dateRange:m,setDateRange:A,size:"md"})]})}),e.jsx(se,{data:c==null?void 0:c.data,onActionClick:e.jsx($e,{rowData:n,onClick:z})})]}),e.jsx(l,{justify:"center",mt:4,children:e.jsx(oe,{currentPage:i,onPageChange:F,totalPages:d})})]}):e.jsx(ne,{})}const $e=({onClick:n,rowData:t})=>{const r=a=>{const i=window.open(a,"_blank");i&&(i.focus(),i.onload=()=>{i.load(),i.onafterprint=()=>{i.close()}})};return e.jsx(l,{justify:"center",children:e.jsx(de,{size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{n(t),r(`${pe}/invoice/generatePDF/${t.id}`)},icon:e.jsx(he,{fontSize:18,color:ue.colors.blue[500]})})})},ye=(n,t)=>{const r=(n-1)*t;let a=r+t-1;return{startIndex:r,endIndex:a}};function be(){const{hasPermission:n}=re(),[t,r]=o.useState(),[a,i]=o.useState(1),P=o.useRef(null),[g,v]=o.useState(""),$=te(g,1e3),[s,m]=o.useState({startDate:null,endDate:null}),A=s.startDate?h(s.startDate).format("YYYY-MM-DD"):"",y=s.endDate?h(s.endDate).format("YYYY-MM-DD"):"",I=ie(),S="Errortoast",u=async()=>{const{startIndex:d,endIndex:p}=ye(a,50),b=j.role.name==="Doctor"?`get_appointment_payments/page?start=${d}&end=${p}&search=${$}&start_date=${A}&end_date=${y}&doctor_id=${j.id}`:`get_appointment_payments/page?start=${d}&end=${p}&search=${$}&start_date=${A}&end_date=${y}`,Y=await Z(j.token,b);return{data:Y==null?void 0:Y.data.map(C=>{const{id:w,txn_id:B,invoice_id:T,amount:L,payment_time_stamp:V,payment_method:W,created_at:q,user_id:k,patient_id:O,appointment_id:N,patient_f_name:R,patient_l_name:G,user_f_name:K,user_l_name:H}=C;return{id:w,"txn ID":B,invoiceID:T,patient:R?e.jsx(f,{to:`/patient/${O}`,children:`${R} ${G}`}):"N/A",user:K?e.jsx(f,{to:`/user/${k}`,children:`${K} ${H}`}):"N/A","APP ID":e.jsx(f,{to:`/appointment/${N}`,children:N}),amount:L,"payment Method":W,"payment Time stamp":h(V).format("D MMM YY hh.mmA"),"created At":h(q).format("D MMM YY hh:mmA")}}),total_record:Y.total_record}},E=d=>{r(d)},{isLoading:z,data:x,error:c}=ee({queryKey:["appointment-payments",a,$,s],queryFn:u}),M=d=>{i(d)},F=Math.ceil((x==null?void 0:x.total_record)/50);return o.useEffect(()=>{P.current&&P.current.scrollIntoView({behavior:"smooth",block:"start"})},[a]),c&&(I.isActive(S)||I({id:S,title:"oops!.",description:"Something bad happens.",status:"error",duration:2e3,isClosable:!0,position:"top"})),n("APPOINTMENT_PAYMENTS_VIEW")?e.jsxs(_,{children:[z||!x?e.jsxs(_,{children:[e.jsxs(l,{mb:5,justify:"space-between",children:[e.jsx(D,{w:400,h:8}),e.jsx(D,{w:50,h:8})]}),e.jsx(D,{h:300,w:"100%"})]}):e.jsxs(_,{children:[e.jsx(l,{mb:5,justify:"space-between",align:"center",children:e.jsxs(l,{align:"center",gap:4,children:[" ",e.jsx(ce,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:d=>v(d.target.value)}),e.jsx(ae,{dateRange:s,setDateRange:m,size:"md"})]})}),e.jsx(se,{data:x?x.data:[],onActionClick:e.jsx(Ae,{onClick:E,rowData:t})})]}),e.jsx(l,{justify:"center",mt:4,children:e.jsx(oe,{currentPage:a,onPageChange:M,totalPages:F})})]}):e.jsx(ne,{})}const Ae=({onClick:n,rowData:t})=>e.jsx(l,{justify:"center",children:e.jsx(de,{size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{n(t),je(`${pe}/invoice/generatePDF/${t.invoiceID}`)},icon:e.jsx(he,{fontSize:18,color:ue.colors.blue[500]})})}),Ie=n=>{switch(n){case"Credited":return e.jsx(X,{colorScheme:"green",fontSize:12,letterSpacing:.5,p:"5px",size:"sm",children:"Credited"});case"Debited":return e.jsx(X,{colorScheme:"red",fontSize:12,letterSpacing:.5,p:"5px",children:"Debited"});default:return e.jsx(X,{colorScheme:"yellow",fontSize:12,letterSpacing:.5,p:"5px",children:"N/A"})}};function Ve(){return e.jsx(_,{children:e.jsxs(xe,{children:[e.jsxs(_e,{children:[e.jsx(J,{children:"All Transactions"}),e.jsx(J,{children:"Appointment Payments"}),e.jsx(J,{children:"Invoices"})]}),e.jsxs(ge,{children:[e.jsx(U,{children:e.jsx(Ye,{})}),e.jsx(U,{children:e.jsx(be,{})}),e.jsx(U,{children:e.jsx(De,{})})]})]})})}const Se=(n,t)=>{const r=(n-1)*t;let a=r+t-1;return{startIndex:r,endIndex:a}};function Ye(){const{hasPermission:n}=re(),[t,r]=o.useState(1),a=o.useRef(null),[i,P]=o.useState(""),g=te(i,1e3),v=ie(),$="Errortoast",[s,m]=o.useState({startDate:null,endDate:null}),A=s.startDate?h(s.startDate).format("YYYY-MM-DD"):"",y=s.endDate?h(s.endDate).format("YYYY-MM-DD"):"",I=async()=>{const{startIndex:c,endIndex:M}=Se(t,50),F=j.role.name==="Doctor"?`get_all_transactions/doctor_id/page?start=${c}&end=${M}&search=${g}&start_date=${A}&end_date=${y}&doctor_id=${j.id}`:`get_all_transactions/page?start=${c}&end=${M}&search=${g}&start_date=${A}&end_date=${y}`,d=await Z(j.token,F);return{data:d==null?void 0:d.data.map(b=>{const{id:Y,user_id:Q,patient_id:C,appointment_id:w,payment_transaction_id:B,amount:T,transaction_type:L,is_wallet_txn:V,notes:W,created_at:q,patient_f_name:k,patient_l_name:O,user_f_name:N,user_l_name:R}=b;return{id:Y,patient:C?e.jsx(f,{to:`/patient/${C}`,children:`${k} ${O}`}):"N/A",user:Q?e.jsx(f,{to:`/user/${Q}`,children:`${N} ${R}`}):"N/A","app ID":e.jsx(f,{to:`/appointment/${w}`,children:w}),"txn ID":B||"N/A",amount:T,"txn type":Ie(L),"wallet Txn":V==1?"Yes":"No",notes:W||"N/A",createdAt:h(q).format("D MMM YY hh:mmA")}}),total_record:d.total_record}},{isLoading:S,data:u,error:E}=ee({queryKey:["transactions",t,g,s],queryFn:I}),z=c=>{r(c)},x=Math.ceil((u==null?void 0:u.total_record)/50);return o.useEffect(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth",block:"start"})},[t]),E&&(v.isActive($)||v({id:$,title:"Oops!",description:"Something went wrong.",status:"error",duration:2e3,isClosable:!0,position:"top"})),n("ALL_TRANSACTION_VIEW")?e.jsxs(_,{ref:a,children:[S||!u?e.jsxs(_,{children:[e.jsxs(l,{mb:5,justify:"space-between",children:[e.jsx(D,{w:400,h:8}),e.jsx(D,{w:50,h:8})]}),e.jsx(D,{h:300,w:"100%"})]}):e.jsxs(_,{children:[e.jsx(l,{mb:5,justify:"space-between",align:"center",children:e.jsxs(l,{align:"center",gap:4,children:[e.jsx(ce,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:c=>P(c.target.value),value:i}),e.jsx(ae,{dateRange:s,setDateRange:m,size:"md"})]})}),e.jsx(se,{data:u==null?void 0:u.data,onActionClick:e.jsx(we,{})})]}),e.jsx(l,{justify:"center",mt:4,children:e.jsx(oe,{currentPage:t,onPageChange:z,totalPages:x})})]}):e.jsx(ne,{})}const we=({onClick:n,rowData:t})=>e.jsx(l,{justify:"center",children:e.jsx(de,{size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{n(t)},icon:e.jsx(me,{fontSize:18,color:"blue.500"})})});export{Ve as default};