2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
import{r as a,j as t}from"./chunk-UIGDSWPH-BhuNDbxn.js";import{u as m,ae as y,P as p}from"./main-af3pcbZa.js";import{C as h}from"./Card-CAsJMMfR.js";import{B as g}from"./Badge-DM3morB7.js";function T(){const c=m(),[d,n]=a.useState([]),[l,s]=a.useState(!0),[r,u]=a.useState(1),[f,x]=a.useState(1);a.useEffect(()=>{i()},[r]);const i=async()=>{try{s(!0);const e=await y({page:r});n(e.results||[]),x(Math.ceil((e.count||0)/50))}catch(e){c.error(`Failed to load transactions: ${e.message}`)}finally{s(!1)}},o=e=>{switch(e){case"purchase":case"subscription":return"success";case"deduction":return"error";default:return"primary"}};return t.jsxs("div",{className:"p-6",children:[t.jsx(p,{title:"Credit Transactions"}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Credit Transactions"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"View all credit transactions and history"})]}),l?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx("div",{className:"text-gray-500",children:"Loading..."})}):t.jsx(h,{className:"p-6",children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Date"}),t.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Type"}),t.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Amount"}),t.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Balance After"}),t.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"})]})}),t.jsx("tbody",{children:d.map(e=>t.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800",children:[t.jsx("td",{className:"py-3 px-4 text-sm text-gray-900 dark:text-white",children:new Date(e.created_at).toLocaleDateString()}),t.jsx("td",{className:"py-3 px-4",children:t.jsx(g,{variant:"light",color:o(e.transaction_type),children:e.transaction_type_display})}),t.jsxs("td",{className:`py-3 px-4 text-sm font-medium ${e.amount>=0?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[e.amount>=0?"+":"",e.amount.toLocaleString()]}),t.jsx("td",{className:"py-3 px-4 text-sm text-gray-900 dark:text-white",children:e.balance_after.toLocaleString()}),t.jsx("td",{className:"py-3 px-4 text-sm text-gray-600 dark:text-gray-400",children:e.description})]},e.id))})]})})})]})}export{T as default};
|