diff --git a/client/src/components/NewSaleForm.tsx b/client/src/components/NewSaleForm.tsx index f470698..bdf4285 100644 --- a/client/src/components/NewSaleForm.tsx +++ b/client/src/components/NewSaleForm.tsx @@ -75,7 +75,8 @@ export default function NewSaleForm() { return response.json(); }, onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ['/api/sales'] }); + // Invalidate all sales queries to refresh the history + queryClient.invalidateQueries({ queryKey: ['/api/sales'], exact: false }); toast({ title: "Vente enregistrée", description: "La vente a été enregistrée avec succès", diff --git a/client/src/components/SalesHistory.tsx b/client/src/components/SalesHistory.tsx index 912b45f..e83f678 100644 --- a/client/src/components/SalesHistory.tsx +++ b/client/src/components/SalesHistory.tsx @@ -52,7 +52,8 @@ export default function SalesHistory({ canDelete = false }: SalesHistoryProps) { mutationFn: (saleId: number) => apiRequest(`/api/sales/${saleId}`, { method: 'DELETE' }), onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ['/api/sales'] }); + // Invalidate all sales queries to refresh the history + queryClient.invalidateQueries({ queryKey: ['/api/sales'], exact: false }); toast({ title: "Vente supprimée", description: "La vente a été supprimée avec succès", diff --git a/server/routes.ts b/server/routes.ts index f46dad9..c7d34a1 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -149,9 +149,14 @@ export async function registerRoutes(app: Express): Promise { // Determine which store to query let targetStoreId: number; - if (user.role === 'admin' && storeId) { - // Admin can query any store - targetStoreId = parseInt(storeId as string); + if (user.role === 'admin') { + if (storeId) { + // Admin querying a specific store + targetStoreId = parseInt(storeId as string); + } else { + // Admin without specific store - should not happen with the new frontend + return res.status(400).json({ error: "Store ID required for admin queries" }); + } } else { // Non-admin users can only query their own store if (!user.storeId) {