From a589c8b770c1c7d44b7720514c23b43204a4763e Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Fri, 11 Jul 2025 15:40:31 +0000 Subject: [PATCH] Enable users to download photos attached to sales records easily Implement photo download functionality in SaleDetailsModal.tsx using a downloadPhoto function and the Download icon. Replit-Commit-Author: Agent Replit-Commit-Session-Id: dec54137-d5a2-4406-8ad4-5f2f9fb110bf Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/3a1a5de6-d311-4504-a90c-e46ce001fd4a.jpg --- client/src/components/SaleDetailsModal.tsx | 38 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/client/src/components/SaleDetailsModal.tsx b/client/src/components/SaleDetailsModal.tsx index dbb086b..b4320ba 100644 --- a/client/src/components/SaleDetailsModal.tsx +++ b/client/src/components/SaleDetailsModal.tsx @@ -1,7 +1,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; -import { X } from 'lucide-react'; +import { X, Download } from 'lucide-react'; import { Sale } from '@/types/sale'; import { formatDate, formatDateTime } from '@/lib/export'; @@ -14,6 +14,16 @@ interface SaleDetailsModalProps { export default function SaleDetailsModal({ isOpen, sale, onClose }: SaleDetailsModalProps) { if (!sale) return null; + // Fonction pour télécharger une photo + const downloadPhoto = (photoData: string, fileName: string) => { + const link = document.createElement('a'); + link.href = photoData; + link.download = fileName; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }; + return ( @@ -83,7 +93,18 @@ export default function SaleDetailsModal({ isOpen, sale, onClose }: SaleDetailsM
Photo Recto: {sale.photoRecto ? ( - Photo recto +
+ Photo recto + +
) : (

Aucune photo

)} @@ -91,7 +112,18 @@ export default function SaleDetailsModal({ isOpen, sale, onClose }: SaleDetailsM
Photo Verso: {sale.photoVerso ? ( - Photo verso +
+ Photo verso + +
) : (

Aucune photo

)}