Improve sales data exports with file size and availability information

Refactors exportToExcel function in export.ts to include photo size and availability using xlsx library.

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/TZiycnz
This commit is contained in:
michaelschal committed 2025-07-19 11:29:25 +00:00
1 parent 91f5c13f33
commit 0aa27fdbd2
2 files changed
+22 -16

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

+22 -16
View File
@@ -4,7 +4,7 @@ export async function exportToExcel(sales: Sale[]): Promise<void> {
if (sales.length === 0) return; if (sales.length === 0) return;
try { try {
const XLSX = await import('xlsx-js-style'); const XLSX = await import('xlsx');
const { utils, writeFile } = XLSX; const { utils, writeFile } = XLSX;
// Créer un nouveau classeur // Créer un nouveau classeur
@@ -129,30 +129,35 @@ export async function exportToExcel(sales: Sale[]): Promise<void> {
}; };
// Ajouter les informations sur les photos disponibles // Ajouter les informations sur les photos disponibles
photoRow['Photo Recto'] = sale.photoRecto ? 'DISPONIBLE' : 'NON DISPONIBLE';
photoRow['Photo Verso'] = sale.photoVerso ? 'DISPONIBLE' : 'NON DISPONIBLE';
photoRow['Photo Ticket'] = sale.photoTicket ? 'DISPONIBLE' : 'NON DISPONIBLE';
// Ajouter des informations sur la taille des photos pour référence
if (sale.photoRecto) { if (sale.photoRecto) {
photoRow['Photo Recto'] = 'DISPONIBLE'; const rectoSize = Math.round(sale.photoRecto.length / 1024);
photoRow['Lien Recto'] = `data:image/jpeg;base64,${sale.photoRecto.split(',')[1] || sale.photoRecto}`; photoRow['Taille Recto (KB)'] = `${rectoSize} KB`;
} else { } else {
photoRow['Photo Recto'] = 'NON DISPONIBLE'; photoRow['Taille Recto (KB)'] = 'N/A';
photoRow['Lien Recto'] = '';
} }
if (sale.photoVerso) { if (sale.photoVerso) {
photoRow['Photo Verso'] = 'DISPONIBLE'; const versoSize = Math.round(sale.photoVerso.length / 1024);
photoRow['Lien Verso'] = `data:image/jpeg;base64,${sale.photoVerso.split(',')[1] || sale.photoVerso}`; photoRow['Taille Verso (KB)'] = `${versoSize} KB`;
} else { } else {
photoRow['Photo Verso'] = 'NON DISPONIBLE'; photoRow['Taille Verso (KB)'] = 'N/A';
photoRow['Lien Verso'] = '';
} }
if (sale.photoTicket) { if (sale.photoTicket) {
photoRow['Photo Ticket'] = 'DISPONIBLE'; const ticketSize = Math.round(sale.photoTicket.length / 1024);
photoRow['Lien Ticket'] = `data:image/jpeg;base64,${sale.photoTicket.split(',')[1] || sale.photoTicket}`; photoRow['Taille Ticket (KB)'] = `${ticketSize} KB`;
} else { } else {
photoRow['Photo Ticket'] = 'NON DISPONIBLE'; photoRow['Taille Ticket (KB)'] = 'N/A';
photoRow['Lien Ticket'] = '';
} }
// Information pour accéder aux photos
photoRow['Instructions'] = 'Voir détails de la vente dans l\'application pour télécharger les photos';
photosData.push(photoRow); photosData.push(photoRow);
}); });
@@ -165,11 +170,12 @@ export async function exportToExcel(sales: Sale[]): Promise<void> {
{ wch: 20 }, // Client { wch: 20 }, // Client
{ wch: 15 }, // Vendeur { wch: 15 }, // Vendeur
{ wch: 15 }, // Photo Recto { wch: 15 }, // Photo Recto
{ wch: 50 }, // Lien Recto
{ wch: 15 }, // Photo Verso { wch: 15 }, // Photo Verso
{ wch: 50 }, // Lien Verso
{ wch: 15 }, // Photo Ticket { wch: 15 }, // Photo Ticket
{ wch: 50 } // Lien Ticket { wch: 15 }, // Taille Recto (KB)
{ wch: 15 }, // Taille Verso (KB)
{ wch: 15 }, // Taille Ticket (KB)
{ wch: 40 } // Instructions
]; ];
// Ajuster la hauteur des lignes pour mieux voir les liens // Ajuster la hauteur des lignes pour mieux voir les liens