import { useQuery } from "@tanstack/react-query"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { BarChart3, Download, TrendingUp, Package, AlertTriangle, FileText } from "lucide-react"; import type { Product, StockMovement } from "@shared/schema"; export default function Reports() { const { data: products } = useQuery({ queryKey: ["/api/products"], }); const { data: stockMovements } = useQuery({ queryKey: ["/api/stock-movements"], }); const { data: stats } = useQuery<{ totalItems: number; inStockItems: number; lowStockItems: number; outOfStockItems: number; }>({ queryKey: ["/api/dashboard/stats"], }); const totalValue = products?.reduce((sum, product) => { const price = parseFloat(product.price || "0"); return sum + (price * product.currentStock); }, 0) || 0; const recentMovements = stockMovements?.slice(0, 10) || []; const generateReport = (type: string) => { // In a real app, this would generate and download a proper report console.log(`Generating ${type} report...`); }; return (

Reports & Analytics

{/* Summary Cards */}

Total Items

{stats?.totalItems || 0}

Total Value

${totalValue.toFixed(2)}

Low Stock

{stats?.lowStockItems || 0}

Out of Stock

{stats?.outOfStockItems || 0}

{/* Report Types */} Available Reports

Inventory Summary

Complete overview of all products, stock levels, and values

Stock Movements

Detailed log of all stock ins and outs over time

Stock Alerts

Products that need attention due to low or zero stock

{/* Recent Activity */} Recent Stock Movements {recentMovements.length > 0 ? (
{recentMovements.map((movement) => { const product = products?.find(p => p.id === movement.productId); return (

{product?.name || 'Unknown Product'}

{movement.type === 'in' ? 'Added' : movement.type === 'out' ? 'Removed' : 'Adjusted'} {movement.quantity} units

{movement.createdAt ? new Date(movement.createdAt).toLocaleDateString() : 'Unknown'}

); })}
) : (

No recent stock movements

)}
); }