PageSourceSearch

https://livingtokens.com/assets/AdminDashboard-DCjYZjdl-v4.js

js livingtokens.com collected 2026-10-02 01:35:27 UTC 10,358 bytes, 1 lines download raw bytes

1import{b0 as i,j as e,aa as E,ao as r,aR as U,ag as T,w as _,x as O,O as P,ar as G,as as M,aN as Q,i as q}from"./index-OosC7O28-v4.js";import{r as d,L as t}from"./react-vendor-Muxl3iU2-v4.js";import"./ui-vendor-Bt0bJPpm-v4.js";import{m as z}from"./framer-motion-DbzRPpXx-v4.js";import"./swiper-vendor-CLjMzi4o-v4.js";const X=()=>{var o,x,m,g,h,p,b,j,u,y,N,f,k,w,v,S,D;const[s,A]=d.useState(null),[n,F]=d.useState([]),[c,R]=d.useState([]),[L,V]=d.useState(!0);d.useEffect(()=>{C()},[]);const C=async()=>{try{const[a,l,$]=await Promise.all([i.getDashboard(),i.getTopProducts(5),i.getRecentOrders(5)]);A(a),F(l),R($)}catch(a){console.error("Error fetching dashboard data:",a)}finally{V(!1)}};if(L)return e.jsx(E,{});const B=[{label:"Total Revenue",value:r(((o=s==null?void 0:s.revenue)==null?void 0:o.total)||0),icon:e.jsx(U,{}),color:"bg-green-500",link:"/admin/orders"},{label:"Total Orders",value:((x=s==null?void 0:s.orders)==null?void 0:x.total)||0,icon:e.jsx(T,{}),color:"bg-blue-500",link:"/admin/orders"},{label:"Products",value:((m=s==null?void 0:s.products)==null?void 0:m.total)||0,icon:e.jsx(_,{}),color:"bg-primary-500",link:"/admin/products"},{label:"Videos",value:((g=s==null?void 0:s.videos)==null?void 0:g.total)||0,icon:e.jsx(O,{}),color:"bg-purple-500",link:"/admin/videos"},{label:"Courses",value:((h=s==null?void 0:s.courses)==null?void 0:h.total)||0,icon:e.jsx(P,{}),color:"bg-indigo-500",link:"/admin/courses"},{label:"Books",value:`${((p=s==null?void 0:s.books)==null?void 0:p.total)||0} (${((b=s==null?void 0:s.books)==null?void 0:b.purchases)||0} sold)`,icon:e.jsx(G,{}),color:"bg-amber-500",link:"/admin/books"},{label:"Total Users",value:((j=s==null?void 0:s.users)==null?void 0:j.total)||0,icon:e.jsx(M,{}),color:"bg-pink-500",link:"/admin/users"}];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-display font-bold text-gray-900 dark:text-white mb-1",children:"Dashboard"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Overview of your Living Tokens platform"})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-6 mb-6",children:B.map((a,l)=>e.jsx(z.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:l*.1},children:e.jsx(t,{to:a.link,className:"block bg-white dark:bg-dark-800 rounded-xl p-3 sm:p-6 shadow-lg hover:shadow-xl transition-shadow h-full",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-xs sm:text-sm mb-1 truncate",children:a.label}),e.jsx("p",{className:"text-lg sm:text-3xl font-bold text-gray-900 dark:text-white truncate",children:a.value})]}),e.jsx("div",{className:`w-9 h-9 sm:w-14 sm:h-14 ${a.color} rounded-xl flex items-center justify-center text-white text-base sm:text-2xl flex-shrink-0`,children:a.icon})]})})},l))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-6 mb-6",children:[e.jsxs("div",{className:"bg-white dark:bg-dark-800 rounded-xl p-4 sm:p-6 shadow-lg",children:[e.jsx("h3",{className:"text-lg font-bold mb-4",children:"Revenue Breakdown"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Today's Revenue"}),e.jsx("span",{className:"font-bold text-green-600",children:r(((u=s==null?void 0:s.revenue)==null?void 0:u.today)||0)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"This Month"}),e.jsx("span",{className:"font-bold text-blue-600",children:r(((y=s==null?void 0:s.revenue)==null?void 0:y.month)||0)})]}),e.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-gray-200 dark:border-dark-600",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"All Time"}),e.jsx("span",{className:"font-bold text-primary-600",children:r(((N=s==null?void 0:s.revenue)==null?void 0:N.total)||0)})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-800 rounded-xl p-4 sm:p-6 shadow-lg",children:[e.jsx("h3",{className:"text-lg font-bold mb-4",children:"Order Status"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Processing"}),e.jsx("span",{className:"font-bold text-blue-600",children:((f=s==null?void 0:s.orders)==null?void 0:f.processing)||0})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Shipped"}),e.jsx("span",{className:"font-bold text-yellow-600",children:((k=s==null?void 0:s.orders)==null?void 0:k.shipped)||0})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Delivered"}),e.jsx("span",{className:"font-bold text-green-600",children:((w=s==null?void 0:s.orders)==null?void 0:w.delivered)||0})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Cancelled"}),e.jsx("span",{className:"font-bold text-red-600",children:((v=s==null?void 0:s.orders)==null?void 0:v.cancelled)||0})]}),e.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-gray-200 dark:border-dark-600",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Total Orders"}),e.jsx("span",{className:"font-bold text-primary-600",children:((S=s==null?void 0:s.orders)==null?void 0:S.total)||0})]})]})]})]}),((D=s==null?void 0:s.products)==null?void 0:D.low_stock)>0&&e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-xl p-4 mb-8",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"text-yellow-600 text-xl",children:"⚠️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-yellow-800 dark:text-yellow-200 text-sm",children:"Low Stock Alert"}),e.jsxs("p",{className:"text-xs text-yellow-700 dark:text-yellow-300",children:[s.products.low_stock," product",s.products.low_stock>1?"s":""," running low on stock"]})]}),e.jsx(t,{to:"/admin/products",className:"ml-auto px-4 py-2 bg-yellow-600 text-white rounded-lg hover:bg-yellow-700 transition-colors",children:"View Products"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-6 mb-6",children:[e.jsxs("div",{className:"bg-white dark:bg-dark-800 rounded-xl p-4 sm:p-6 shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[e.jsx(Q,{className:"text-green-500"}),"Top Selling Products"]}),e.jsx(t,{to:"/admin/products",className:"text-sm text-primary-500 hover:text-primary-600",children:"View All"})]}),e.jsx("div",{className:"space-y-3",children:n.length>0?n.map((a,l)=>e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 p-2 sm:p-3 bg-gray-50 dark:bg-dark-700 rounded-lg",children:[e.jsxs("span",{className:"text-xs font-bold text-gray-500 w-5 flex-shrink-0",children:["#",l+1]}),a.image&&e.jsx("img",{src:a.image,alt:a.name,className:"w-9 h-9 sm:w-12 sm:h-12 object-cover rounded flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate text-sm",children:a.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[a.total_sold," sales · ",r(a.total_revenue)]})]})]},a.id)):e.jsx("p",{className:"text-gray-500 text-center py-4",children:"No sales data yet"})})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-800 rounded-xl p-4 sm:p-6 shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[e.jsx(q,{className:"text-blue-500"}),"Recent Orders"]}),e.jsx(t,{to:"/admin/orders",className:"text-sm text-primary-500 hover:text-primary-600",children:"View All"})]}),e.jsx("div",{className:"space-y-3",children:c.length>0?c.map(a=>{var l;return e.jsxs(t,{to:`/admin/orders/${a.id}`,className:"block p-2 sm:p-3 bg-gray-50 dark:bg-dark-700 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-600 transition-colors",children:[e.jsxs("div",{className:"flex justify-between items-start mb-1 gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:["#",a.order_number]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded flex-shrink-0 ${a.order_status==="delivered"?"bg-green-100 text-green-700":a.order_status==="shipped"?"bg-blue-100 text-blue-700":a.order_status==="processing"?"bg-yellow-100 text-yellow-700":"bg-gray-100 text-gray-700"}`,children:a.order_status})]}),e.jsxs("div",{className:"flex justify-between items-center text-xs",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400 truncate mr-2",children:((l=a.user)==null?void 0:l.name)||"Guest"}),e.jsx("span",{className:"font-bold text-primary-600 flex-shrink-0",children:r(a.total_amount)})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:new Date(a.created_at).toLocaleDateString()})]},a.id)}):e.jsx("p",{className:"text-gray-500 text-center py-4",children:"No orders yet"})})]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-bold mb-3",children:"Qu
1ick Actions"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{label:"Add Product",link:"/admin/products/new",icon:e.jsx(_,{})},{label:"Add Video",link:"/admin/videos/new",icon:e.jsx(O,{})},{label:"Add Course",link:"/admin/courses/new",icon:e.jsx(P,{})},{label:"View Orders",link:"/admin/orders",icon:e.jsx(T,{})}].map((a,l)=>e.jsxs(t,{to:a.link,className:"flex items-center gap-2 sm:gap-3 p-3 sm:p-4 bg-white dark:bg-dark-800 rounded-xl shadow hover:shadow-lg transition-shadow",children:[e.jsx("span",{className:"text-xl sm:text-2xl text-primary-500 flex-shrink-0",children:a.icon}),e.jsx("span",{className:"font-medium text-xs sm:text-sm leading-tight",children:a.label})]},l))})]})]})};export{X as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.