import React, { useState } from 'react'; import { Search, Download, Printer, Calendar, Filter, BarChart3, PieChart, LineChart, ArrowUpRight, RefreshCw, FileText } from 'lucide-react'; import { Button } from "../ui/button"; import { Input } from "../ui/input"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../ui/table"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../ui/select"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../ui/card"; import { Badge } from "../ui/badge"; import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, Line, LineChart as RechartsLineChart } from 'recharts'; import { toast } from "sonner@2.0.3"; import { cn } from "../ui/utils"; // --- Mock Data --- const MOCK_PRINT_LOG = [ { id: '1-251201', productName: 'Whole Milk', category: 'Dairy', template: '2"x2" Basic', printedAt: '2024-03-20 09:30 AM', printedBy: 'Alice Johnson', location: 'Downtown Store (101)', expiryDate: '2024-03-27', status: 'Valid' }, { id: '2-251201', productName: 'Ground Beef', category: 'Meat', template: '2"x2" Basic', printedAt: '2024-03-20 10:15 AM', printedBy: 'Bob Smith', location: 'Uptown Store (102)', expiryDate: '2024-03-23', status: 'Valid' }, { id: '3-251201', productName: 'Croissant', category: 'Bakery', template: '2"x2" Basic', printedAt: '2024-03-19 14:00 PM', printedBy: 'Charlie Brown', location: 'Downtown Store (101)', expiryDate: '2024-03-20', status: 'Expired' }, { id: '4-251201', productName: 'Caesar Salad', category: 'Deli', template: '2"x6" G\'n\'G !!!', printedAt: '2024-03-18 11:45 AM', printedBy: 'Alice Johnson', location: 'Downtown Store (101)', expiryDate: '2024-03-21', status: 'Expiring Soon' }, { id: '5-251201', productName: 'Orange Juice', category: 'Beverage', template: '2"x2" Basic', printedAt: '2024-03-18 08:20 AM', printedBy: 'Bob Smith', location: 'Airport Kiosk (201)', expiryDate: '2024-03-25', status: 'Valid' }, ]; const MOCK_CATEGORY_STATS = [ { name: 'Dairy', count: 450 }, { name: 'Meat', count: 320 }, { name: 'Bakery', count: 280 }, { name: 'Deli', count: 190 }, { name: 'Produce', count: 150 }, { name: 'Beverage', count: 120 }, ]; const MOCK_USAGE_TRENDS = [ { date: 'Mon', count: 120 }, { date: 'Tue', count: 132 }, { date: 'Wed', count: 101 }, { date: 'Thu', count: 134 }, { date: 'Fri', count: 190 }, { date: 'Sat', count: 230 }, { date: 'Sun', count: 210 }, ]; export function ReportsView() { const [activeTab, setActiveTab] = useState('print-log'); const handleReprint = (labelId: string) => { // Logic to reprint would go here // For now, we simulate the action toast.success(`Reprinting label ${labelId}`, { description: "Watermark 'RePrint' applied.", }); }; return (
{/* Toolbar + Filters - style consistent with Labels / Location Manager */}
{/* Row 1: Partner, Group, Location dropdowns + Period Search, Product search, Export */}
Period Search:
-
{/* Tabs - underline spans full width */}
{/* Content Area - same padding as Labels */}
{activeTab === 'print-log' && (
Label ID Product Name Category Template Printed At Printed By Location Expiry Date Action {MOCK_PRINT_LOG.map((log) => ( {log.id} {log.productName} {log.category} {(() => { const hasAlert = log.template.endsWith(' !!!'); const main = hasAlert ? log.template.slice(0, -4) : log.template; const lastSpace = main.lastIndexOf(' '); const prefix = main.slice(0, lastSpace + 1); const boldPart = main.slice(lastSpace + 1); return ( <> {prefix} {boldPart} {hasAlert && !!!} ); })()} {log.printedAt} {log.printedBy} {log.location} {log.expiryDate} ))}
)} {activeTab === 'label-report' && (
{/* Summary Cards */}
Total Labels Printed
2,543

+20.1% from last month

Most Printed Category
Dairy

450 labels generated

Top Product
Whole Milk

182 labels generated

Avg. Daily Prints
85

+12% from last week

{/* Category Breakdown Chart */} Labels by Category Distribution of printed labels across product categories. `${value}`} /> {/* Usage Trend Chart */} Print Volume Trends Daily label printing volume for the last 7 days.
{/* Top Products Table */} Most Used Products Product Name Category Total Printed Usage % Whole Milk Dairy 182 7.2% Ground Beef 80/20 Meat 145 5.7% Chicken Breast Meat 132 5.2% Sliced Ham Deli 98 3.8%
)}
); }