mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-16 19:58:43 +02:00
Provide users a detailed sales report in an easily accessible file
Implements sales data export to .xlsx format using the xlsx library and updates related dependencies. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e80fed01-7137-4997-b9af-dad57132d430 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/e80fed01-7137-4997-b9af-dad57132d430/uQbgywo
This commit is contained in:
1 parent
c3c1616e04
commit
a586798a5d
4 files changed
+366
-10
No files matched your search
@@ -12,6 +12,7 @@ import { apiRequest } from '@/lib/queryClient';
|
||||
import type { Sale } from '@shared/schema';
|
||||
import { History, Download, Trash2, Eye, Filter, FileText, Search, X, Calendar, Users } from 'lucide-react';
|
||||
import SaleDetailsModal from '@/components/SaleDetailsModal';
|
||||
import { formatDateTime } from '@/lib/export';
|
||||
|
||||
interface SalesHistoryProps {
|
||||
canDelete?: boolean;
|
||||
@@ -364,6 +365,35 @@ export default function SalesHistory({ canDelete = false }: SalesHistoryProps) {
|
||||
setSearchQuery('');
|
||||
};
|
||||
|
||||
const exportToExcel = async () => {
|
||||
if (filteredSales.length === 0) {
|
||||
toast({
|
||||
title: "Aucune donnée",
|
||||
description: "Aucune vente à exporter",
|
||||
variant: "destructive",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const { exportToExcel } = await import('@/lib/export');
|
||||
await exportToExcel(filteredSales);
|
||||
|
||||
toast({
|
||||
title: "Export réussi",
|
||||
description: "Le fichier Excel a été téléchargé",
|
||||
variant: "success",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de l\'export Excel:', error);
|
||||
toast({
|
||||
title: "Erreur d'export",
|
||||
description: "Impossible de générer le fichier Excel",
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="elegant-card">
|
||||
@@ -475,12 +505,12 @@ export default function SalesHistory({ canDelete = false }: SalesHistoryProps) {
|
||||
Registre PDF Détaillé
|
||||
</button>
|
||||
<button
|
||||
onClick={exportToCSV}
|
||||
onClick={exportToExcel}
|
||||
disabled={filteredSales.length === 0}
|
||||
className="modern-button modern-button-secondary"
|
||||
>
|
||||
<Download className="h-4 w-4" />
|
||||
Export CSV
|
||||
Export Excel (.xlsx)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user