mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Adjust dashboard to better manage DLC alert modal display for users
Modify the useEffect hook in Dashboard.tsx to refine the logic for displaying the DLC alert modal, ensuring it only appears for non-admin users with expiring or expired DLCs, and handles modal state correctly when user roles change or data is loading. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/Q8UjAXl
This commit is contained in:
1 parent
2feb305710
commit
d3bd4d15b6
1 file changed
+12
-4
@@ -240,9 +240,17 @@ export default function Dashboard() {
|
||||
|
||||
// Effet pour afficher automatiquement le modal DLC pour les utilisateurs non-admin
|
||||
useEffect(() => {
|
||||
// Vérifier si l'utilisateur n'est pas admin et qu'il y a des problèmes DLC
|
||||
const shouldShowDlcModal = user?.role !== 'admin' &&
|
||||
(dlcStats.expired > 0 || dlcStats.expiringSoon > 0);
|
||||
// Ne rien faire si l'utilisateur n'est pas encore chargé ou est admin
|
||||
if (!user || user.role === 'admin') {
|
||||
// Fermer le modal si déjà ouvert (cas où l'utilisateur devient admin)
|
||||
if (showDlcAlertModal) {
|
||||
setShowDlcAlertModal(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Vérifier s'il y a des problèmes DLC
|
||||
const shouldShowDlcModal = dlcStats.expired > 0 || dlcStats.expiringSoon > 0;
|
||||
|
||||
if (shouldShowDlcModal && !showDlcAlertModal) {
|
||||
// Vérifier s'il n'y a pas de snooze actif
|
||||
@@ -260,7 +268,7 @@ export default function Dashboard() {
|
||||
// Fermer le modal si plus de problèmes DLC
|
||||
setShowDlcAlertModal(false);
|
||||
}
|
||||
}, [user?.role, dlcStats.expired, dlcStats.expiringSoon, showDlcAlertModal]);
|
||||
}, [user, user?.role, dlcStats.expired, dlcStats.expiringSoon, showDlcAlertModal]);
|
||||
|
||||
// Fonction pour fermer le modal DLC
|
||||
const handleCloseDlcAlertModal = () => {
|
||||
|
||||
Reference in new issue
Block a user