Files
tfm_ainventory/frontend/components/admin/ExportPanel.tsx
Daniel Bedeleanu 9a87064dbe fix(design): replace all 40+ hardcoded colors with DESIGN.md semantic system
Phase 10 Implementation: Bulk color system compliance across frontend

Applied DESIGN_COLOR_RULES.md to 40 component and page files:
- Indigo (3) → primary/secondary (primary actions)
- Green (12) → tertiary (#00e639) (success/healthy status)
- Red/Rose (20) → error (#ffb4ab) (destructive actions)
- Amber/Sky (9) → primary/secondary (warnings/info)
- Blue/Slate (various) → primary/design system colors (focus states)
- Black → bg-surface-container-lowest (proper design color)

Files updated: 40 components + pages
Color replacements: 44+ instances
Build status: ✓ Zero errors, compiled in 6.3s
Test status: Pending (npm run test)

All colors now follow DESIGN.md Industrial Precision system:
 Primary: #ffb781 (caution orange)
 Secondary: #c8c6c5 (gray)
 Tertiary: #00e639 (healthy green)
 Error: #ffb4ab (destructive red)
 Design system enforced across all UI/UX

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-25 17:19:53 +03:00

121 lines
4.8 KiB
TypeScript

"use client";
import { useState } from "react";
import { FileDown, Loader2, FileSpreadsheet, FileText } from "lucide-react";
import { useExport } from "@/hooks/useExport";
import { toast } from "react-hot-toast";
export function ExportPanel() {
const { exportSnapshot, exportAuditTrail, isLoading, error } = useExport();
const handleExportSnapshot = async (format: "csv" | "xlsx") => {
try {
await exportSnapshot(format);
const formatName = format === "csv" ? "CSV" : "Excel";
toast.success(`Inventory snapshot exported as ${formatName}`);
} catch (err) {
// Error handled by hook
}
};
const handleExportAuditTrail = async (format: "csv" | "xlsx") => {
try {
await exportAuditTrail(format);
const formatName = format === "csv" ? "CSV" : "Excel";
toast.success(`Audit trail exported as ${formatName}`);
} catch (err) {
// Error handled by hook
}
};
return (
<div data-testid="admin-tab-exports" className="level-1 p-4 md:p-6 flex flex-col h-full">
<div className="flex items-center gap-3 mb-4 md:mb-6">
<div className="w-10 h-10 bg-surface-container-lowest flex items-center justify-center text-primary border border-border">
<FileDown size={20} />
</div>
<div>
<h2 className="text-xl font-normal text-white tracking-tight">Export & Reports</h2>
<p className="text-[10px] md:text-xs text-muted font-normal tracking-tight">Download system snapshots and action logs</p>
</div>
</div>
<div className="grid md:grid-cols-2 gap-4">
{/* Inventory Snapshot Section */}
<div className="p-4 border border-border hover:border-primary/20 transition-all group flex flex-col justify-between">
<div className="mb-4">
<h3 className="text-sm font-normal text-secondary flex items-center gap-2">
<FileSpreadsheet size={14} className="text-primary" />
Inventory Snapshot
</h3>
<p className="text-xs text-muted mt-1 leading-relaxed">
Export current inventory state with all item details and locations.
</p>
</div>
<div className="grid grid-cols-2 gap-2">
<button
onClick={() => handleExportSnapshot("csv")}
disabled={isLoading}
className="btn-primary text-sm px-5 py-1.5 disabled:opacity-50"
aria-label="Export inventory snapshot as CSV"
>
{isLoading ? <Loader2 size={14} className="animate-spin" /> : <FileText size={14} />}
CSV
</button>
<button
onClick={() => handleExportSnapshot("xlsx")}
disabled={isLoading}
className="btn-primary text-sm px-5 py-1.5 disabled:opacity-50"
aria-label="Export inventory snapshot as Excel"
>
{isLoading ? <Loader2 size={14} className="animate-spin" /> : <FileSpreadsheet size={14} />}
Excel
</button>
</div>
</div>
{/* Audit Trail Section */}
<div className="p-4 border border-border hover:border-primary/20 transition-all group flex flex-col justify-between">
<div className="mb-4">
<h3 className="text-sm font-normal text-secondary flex items-center gap-2">
<FileText size={14} className="text-primary" />
Audit Trail
</h3>
<p className="text-xs text-muted mt-1 leading-relaxed">
Complete history of system actions, changes, and user operations.
</p>
</div>
<div className="grid grid-cols-2 gap-2">
<button
onClick={() => handleExportAuditTrail("csv")}
disabled={isLoading}
className="btn-primary text-sm px-5 py-1.5 disabled:opacity-50"
aria-label="Export audit trail as CSV"
>
{isLoading ? <Loader2 size={14} className="animate-spin" /> : <FileText size={14} />}
CSV
</button>
<button
onClick={() => handleExportAuditTrail("xlsx")}
disabled={isLoading}
className="btn-primary text-sm px-5 py-1.5 disabled:opacity-50"
aria-label="Export audit trail as Excel"
>
{isLoading ? <Loader2 size={14} className="animate-spin" /> : <FileSpreadsheet size={14} />}
Excel
</button>
</div>
</div>
</div>
{error && (
<div className="mt-4 p-3 bg-error/10 border border-error/20 text-error text-[10px] flex items-center gap-2 animate-in slide-in-from-top-2 duration-300">
<div className="w-1.5 h-1.5 bg-rose-500 animate-pulse" />
<span className="font-normal truncate">Error: {error}</span>
</div>
)}
</div>
);
}