Improve task module loading for director and manager roles

Enhance Layout component to auto-select a store for director/manager roles and add a useEffect hook in Tasks page to invalidate the "/api/tasks" query when selectedStoreId changes for these roles.

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/yiEpJFx
This commit is contained in:
michaelschal committed 2025-09-09 08:49:02 +00:00
1 parent 27305d5706
commit 025bca2e38
2 files changed
+20 -1

No files matched your search

+12
View File
@@ -331,6 +331,18 @@ export default function Tasks() {
timestamp: new Date().toISOString()
});
// Force refresh when selectedStoreId changes for directeur/manager
useEffect(() => {
if (user && (user.role === 'directeur' || user.role === 'manager') && selectedStoreId) {
console.log('🔄 FORCE REFRESH: selectedStoreId changed for directeur/manager:', {
userRole: user.role,
selectedStoreId,
timestamp: new Date().toISOString()
});
queryClient.invalidateQueries({ queryKey: ["/api/tasks"] });
}
}, [selectedStoreId, user, queryClient]);
// États locaux
const [searchTerm, setSearchTerm] = useState("");
const [statusFilter, setStatusFilter] = useState<string>("all");