import{r as n,a as Q,c as R,j as e,v as _,I as $,i as F,ay as q}from"./index-7c7a558c.js";import{B as G}from"./Breadcrumb-2eb871e0.js";const K=()=>{var g,m,b,y,j,N,u,w,f,v,p,S,T,D,E,C,I,L;const[d,z]=n.useState(25),A=25,i=8,{data:a,isLoading:l,isError:M,isFetching:P,error:x,refetch:h}=Q("getTransactions",()=>q({count:d})),s=R();n.useEffect(()=>{const t=localStorage.getItem("token"),c=localStorage.getItem("user");t&&c||s("/login")},[s]),n.useEffect(()=>{h()},[d,h]);let r=null;return l&&(r=e.jsx("tr",{className:"border-b bg-gray-800 border-gray-700 hover:bg-gray-600 hover:text-white",children:e.jsx("td",{colSpan:i,className:"text-center text-white",children:e.jsx("div",{className:"text-center flex justify-center items-center my-6",children:e.jsx(F,{color:"white",size:"lg",variant:"dots"})})})})),!l&&M&&(r=e.jsx("tr",{className:"border-b bg-gray-800 border-gray-700 hover:bg-gray-600 hover:text-white",children:e.jsx("td",{colSpan:i,className:"text-center text-white py-6",children:`${x==null?void 0:x.error}`})})),!l&&((b=(m=(g=a==null?void 0:a.data)==null?void 0:g.data)==null?void 0:m.transactions)==null?void 0:b.length)===0&&(r=e.jsx("tr",{className:"border-b bg-gray-800 border-gray-700 hover:bg-gray-600 hover:text-white",children:e.jsx("td",{colSpan:i,className:"text-center text-white py-6",children:"No Transactions Found!"})})),!l&&((N=(j=(y=a==null?void 0:a.data)==null?void 0:y.data)==null?void 0:j.transactions)==null?void 0:N.length)>0&&(r=(f=(w=(u=a==null?void 0:a.data)==null?void 0:u.data)==null?void 0:w.transactions)==null?void 0:f.map((t,c)=>e.jsxs("tr",{className:"bg-white border-b dark:bg-gray-800 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600",children:[e.jsx("td",{"data-label":"SL",className:"text-black dark:text-white w-4 p-4",children:c+1}),e.jsx("td",{"data-label":"Type",className:"text-black dark:text-white px-6 py-4",children:(t==null?void 0:t.type)==1?"Credit":"Debit"}),e.jsx("td",{"data-label":"Credit",className:"text-black dark:text-white px-6 py-4",children:(t==null?void 0:t.type)==1?t==null?void 0:t.amount:""}),e.jsx("td",{"data-label":"Debit",className:"text-black dark:text-white px-6 py-4",children:(t==null?void 0:t.type)==2?t==null?void 0:t.amount:""}),e.jsxs("td",{"data-label":"Amount",className:"text-black dark:text-white px-6 py-4",children:[(t==null?void 0:t.type)==1?"+":"-",t==null?void 0:t.amount]}),e.jsx("td",{"data-label":"Note",className:"text-black dark:text-white px-6 py-4",children:t==null?void 0:t.narration}),e.jsx("td",{"data-label":"Date",className:"text-black dark:text-white px-6 py-4",children:_(t==null?void 0:t.created_at)})]},c))),e.jsxs(e.Fragment,{children:[e.jsx(G,{title:"Pass book"}),e.jsx("div",{className:"container mx-auto my-5 p-5",children:e.jsxs("div",{className:"relative overflow-x-auto shadow-md sm:rounded-lg bg-white dark:bg-gray-900 p-2 table-wrapper",children:[e.jsx("div",{className:"pb-4 bg-white dark:bg-gray-900"}),e.jsx($,{dataLength:(S=(p=(v=a==null?void 0:a.data)==null?void 0:v.data)==null?void 0:p.transactions)!=null&&S.length?(E=(D=(T=a==null?void 0:a.data)==null?void 0:T.data)==null?void 0:D.transactions)==null?void 0:E.length:0,next:()=>{z(t=>t+A)},hasMore:((L=(I=(C=a==null?void 0:a.data)==null?void 0:C.data)==null?void 0:I.transactions)==null?void 0:L.length)==d,children:e.jsxs("table",{className:"w-full text-sm text-left text-gray-500 dark:text-gray-400",children:[e.jsx("thead",{className:"text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"p-4",children:"Serial"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Credit"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Debit"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Amount"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Note"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Date"})]})}),e.jsx("tbody",{children:r})]})}),P&&e.jsx("div",{className:"text-center flex justify-center items-center my-6",children:e.jsx(F,{color:"white",size:"lg",variant:"dots"})})]})})]})};export{K as default};
