mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-20 13:48:21 +02:00
Create a new sales registry app with identity verification features
Initial commit of the React application with UI components, form, camera, and indexedDB integration for sale data management. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 91318273-c764-4fd4-be04-bdc12c38af32 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/02867739-9ff7-4441-aca2-12e0153376c5.jpg
This commit is contained in:
1 parent
4969159ef9
commit
4fac1078a1
83 files changed
+16585
No files matched your search
@@ -0,0 +1,68 @@
|
||||
import { Sale } from '@/types/sale';
|
||||
|
||||
export function exportToCSV(sales: Sale[]): void {
|
||||
if (sales.length === 0) return;
|
||||
|
||||
const headers = [
|
||||
'Date de vente',
|
||||
'Vendeur',
|
||||
'Type d\'article',
|
||||
'Catégorie',
|
||||
'Quantité',
|
||||
'Code générique',
|
||||
'Nom client',
|
||||
'Prénom client',
|
||||
'Date de naissance',
|
||||
'Lieu de naissance',
|
||||
'Type et n° identité',
|
||||
'Autorité de délivrance',
|
||||
'Date de délivrance',
|
||||
'Photo recto (Oui/Non)',
|
||||
'Photo verso (Oui/Non)',
|
||||
'Horodatage'
|
||||
];
|
||||
|
||||
const rows = sales.map(sale => [
|
||||
sale.dateVente,
|
||||
sale.vendeur,
|
||||
sale.typeArticle,
|
||||
sale.categorie,
|
||||
sale.quantite.toString(),
|
||||
sale.gencode || '',
|
||||
sale.nom,
|
||||
sale.prenom,
|
||||
sale.dateNaissance || '',
|
||||
sale.lieuNaissance || '',
|
||||
sale.typeIdentite || '',
|
||||
sale.autoriteDelivrance || '',
|
||||
sale.dateDelivrance || '',
|
||||
sale.photoRecto ? 'Oui' : 'Non',
|
||||
sale.photoVerso ? 'Oui' : 'Non',
|
||||
sale.timestamp
|
||||
]);
|
||||
|
||||
const csvContent = [headers, ...rows]
|
||||
.map(row => row.map(field => `"${String(field).replace(/"/g, '""')}"`).join(';'))
|
||||
.join('\n');
|
||||
|
||||
// Add BOM for UTF-8 Excel compatibility
|
||||
const bom = '\uFEFF';
|
||||
const blob = new Blob([bom + csvContent], {
|
||||
type: 'text/csv;charset=utf-8;'
|
||||
});
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.download = `ventes_petards_${new Date().toISOString().split('T')[0]}.csv`;
|
||||
link.click();
|
||||
|
||||
URL.revokeObjectURL(link.href);
|
||||
}
|
||||
|
||||
export function formatDate(dateString: string): string {
|
||||
return new Date(dateString).toLocaleDateString('fr-FR');
|
||||
}
|
||||
|
||||
export function formatDateTime(dateString: string): string {
|
||||
return new Date(dateString).toLocaleString('fr-FR');
|
||||
}
|
||||
Reference in new issue
Block a user