From a62e1783a206b37ee37469d42f0de17dbadcb9f2 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Mon, 8 Sep 2025 19:54:45 +0000 Subject: [PATCH 1/2] Improve how verified documents are loaded from the server cache Update the Avoirs page to fetch invoice verification status from a POST request to the server, utilizing the existing cache if available, and store the results in the component's state. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/uMhb9Na --- client/src/pages/Avoirs.tsx | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/client/src/pages/Avoirs.tsx b/client/src/pages/Avoirs.tsx index 4831536..0dee53e 100644 --- a/client/src/pages/Avoirs.tsx +++ b/client/src/pages/Avoirs.tsx @@ -176,7 +176,7 @@ export default function Avoirs() { enabled: !!user, }); - // 🔄 Charger les vérifications du cache au démarrage + // 🔄 Charger les vérifications depuis le cache serveur au démarrage useEffect(() => { const loadCachedVerifications = async () => { console.log('🔍 LoadCache - Début vérification:', { @@ -187,19 +187,34 @@ export default function Avoirs() { if (!avoirs || avoirs.length === 0) return; const cachedResults: Record = {}; + + // Charger les vérifications depuis le cache serveur pour TOUS les avoirs avec référence for (const avoir of avoirs) { console.log('🔍 LoadCache - Avoir analysé:', { id: avoir.id, hasInvoiceRef: !!avoir.invoiceReference?.trim(), invoiceReference: avoir.invoiceReference, - nocodbVerified: avoir.nocodbVerified, - shouldCache: !!(avoir.invoiceReference?.trim() && avoir.nocodbVerified) + nocodbVerified: avoir.nocodbVerified }); - if (avoir.invoiceReference?.trim() && avoir.nocodbVerified) { - // Si l'avoir est validé, marquer comme vérifié - cachedResults[avoir.id] = { exists: true, fromCache: true, permanent: true }; - console.log('✅ LoadCache - Avoir ajouté au cache:', avoir.id); + // Si l'avoir a une référence de facture, vérifier le cache serveur + if (avoir.invoiceReference?.trim()) { + try { + const result = await apiRequest(`/api/avoirs/${avoir.id}/verify-invoice`, 'POST', { + invoiceReference: avoir.invoiceReference, + forceRefresh: false // Utiliser le cache si disponible + }); + + console.log('🔍 LoadCache - Résultat cache serveur pour avoir', avoir.id, ':', result); + + if (result.exists !== undefined) { + cachedResults[avoir.id] = result; + console.log('✅ LoadCache - Avoir ajouté au cache depuis serveur:', avoir.id); + } + } catch (error) { + console.log('⚠️ LoadCache - Erreur cache serveur pour avoir', avoir.id, ':', error); + // Continuer sans erreur si le cache échoue + } } } @@ -210,7 +225,7 @@ export default function Avoirs() { if (Object.keys(cachedResults).length > 0) { setAvoirVerificationResults(prev => ({ ...prev, ...cachedResults })); - console.log('✅ Vérifications cachées chargées et appliquées:', cachedResults); + console.log('✅ Vérifications chargées depuis le serveur:', cachedResults); } }; From 2291dcdd7fc69ef2eeb8f1c905123303c626d0bf Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Mon, 8 Sep 2025 19:55:48 +0000 Subject: [PATCH 2/2] Improve how verification statuses are displayed for specific records Refactor the Avoirs page to wrap the CheckCircle component in a div for better tooltip handling and to display verification status more clearly. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/uMhb9Na --- client/src/pages/Avoirs.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/pages/Avoirs.tsx b/client/src/pages/Avoirs.tsx index 0dee53e..a9333ec 100644 --- a/client/src/pages/Avoirs.tsx +++ b/client/src/pages/Avoirs.tsx @@ -1180,7 +1180,9 @@ export default function Avoirs() { {verifyingAvoirs.has(avoir.id) ? ( ) : (avoirVerificationResults[avoir.id]?.exists === true || avoir.nocodbVerified) ? ( - +
+ +
) : avoirVerificationResults[avoir.id]?.exists === false ? ( ) : (