Welcome to the Jose Madrid Salsa developer docs — explore features, APIs, and deployment guides.
Jose Madrid SalsaJMS Docs

Admin Dashboard

Admin panel with sales overview, order management, inventory alerts, customer growth, and quick actions

Admin Dashboard

The admin dashboard at /admin provides a comprehensive overview of business operations including sales metrics, order status breakdowns, inventory alerts, customer growth, and quick action shortcuts.

Architecture

page.tsx
layout.tsx
loading.tsx
error.tsx
StatsCard.tsx
SalesOverview.tsx
RecentActivityFeed.tsx
TopProductsTable.tsx
OrderStatusBreakdown.tsx
InventoryAlertWidget.tsx
CustomerGrowthChart.tsx
QuickActionsGrid.tsx

Dashboard Stats

The dashboard fetches all stats in parallel using Promise.all for optimal load time:

const [
  totalOrders,
  totalUsers,
  totalProducts,
  totalLocations,
  totalReviews,
  recentOrders,
  lowStockProducts,
  recentUsers,
  ordersByStatus,
] = await Promise.all([
  prisma.order.count(),
  prisma.user.count(),
  prisma.product.count(),
  prisma.retailLocation.count(),
  prisma.review.count(),
  // ... detail queries
])

Dashboard Widgets

Stats Cards

Top-level KPIs displayed as StatsCard components:

MetricSource
Total RevenueSUM(total) from non-cancelled orders
Total OrdersCOUNT(*) from orders
Total CustomersCOUNT(*) from users
Total ProductsCOUNT(*) from products
Retail LocationsCOUNT(*) from retail locations
Average RatingAVG(rating) from reviews
New Users This MonthUsers created since start of current month

Sales Overview

The SalesOverview component renders a 6-month sales trend chart using raw SQL:

SELECT
  to_char(date_trunc('month', "createdAt"), 'Mon') AS month,
  SUM(CASE WHEN status != 'CANCELLED' THEN total ELSE 0 END) AS sales,
  COUNT(*) AS orders
FROM orders
WHERE "createdAt" ≥ date_trunc('month', NOW()) - interval '6 months'
GROUP BY date_trunc('month', "createdAt")
ORDER BY date_trunc('month', "createdAt") ASC

Top Products Table

Shows the 5 best-selling products by unit quantity, with revenue totals.

Order Status Breakdown

Groups orders by status with counts, rendered as a breakdown chart.

Inventory Alert Widget

Displays the 5 products with lowest stock (inventory ≤ 10, active only), sorted ascending by inventory count.

Customer Growth Chart

Visualizes new customer registrations over time.

Recent Activity Feed

Shows the 3 most recent orders with customer name and total.

Quick Actions Grid

Shortcuts to common admin tasks (create product, view orders, manage inventory, etc.).

Admin Sections

The admin layout provides navigation to:

SectionRouteDescription
Dashboard/adminOverview and KPIs
Orders/admin/ordersOrder management
Products/admin/productsProduct CRUD
Categories/admin/categoriesCategory management
Inventory/admin/inventoryStock levels and alerts
Users/admin/usersCustomer management
Analytics/admin/analyticsSales and traffic reports
Email Campaigns/admin/email-campaignsCampaign management
Gift Certificates/admin/gift-certificatesCertificate CRUD
Lead Generation/admin/lead-generationLead scraping campaigns
Settings/admin/settingsSite configuration

Admin access requires the ADMIN or SUPER_ADMIN role. The getCurrentUser() and hasPermission() functions from lib/rbac.ts enforce this on every admin page load.

How is this guide?

Edit on GitHub

Last updated on

On this page