mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Improve delivery deletion by updating the local cache and refetching data
Implement optimistic UI updates for delivery deletion by using `setQueryData` to remove the item from the cache locally and then using `refetchQueries` to ensure data consistency with the server. Includes error handling to refetch on failure. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 3527f812-5444-4cba-9693-7eb9aae7ec50 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/lCj0xbO
This commit is contained in:
1 parent
fe193b7120
commit
f257234f64
1 file changed
+11
-1
@@ -705,8 +705,18 @@ export default function BLReconciliation() {
|
||||
description: "Livraison supprimée avec succès",
|
||||
});
|
||||
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries/bl'] });
|
||||
// Mise à jour optimiste du cache local pour disparition immédiate
|
||||
queryClient.setQueryData(['/api/deliveries/bl', selectedStoreId], (oldData: any) => {
|
||||
if (!oldData) return oldData;
|
||||
return oldData.filter((d: any) => d.id !== deliveryId);
|
||||
});
|
||||
|
||||
// Force refetch pour synchroniser avec le serveur
|
||||
queryClient.refetchQueries({ queryKey: ['/api/deliveries/bl'] });
|
||||
queryClient.refetchQueries({ queryKey: ['/api/deliveries'] });
|
||||
} catch (error) {
|
||||
// En cas d'erreur, refetch pour annuler la mise à jour optimiste
|
||||
queryClient.refetchQueries({ queryKey: ['/api/deliveries/bl'] });
|
||||
toast({
|
||||
title: "Erreur",
|
||||
description: "Impossible de supprimer la livraison",
|
||||
|
||||
Reference in new issue
Block a user