Add alert modal for DLC status to dashboard view

Introduces a `DlcAlertModal` component and integrates it into the `Dashboard` page. The modal is conditionally displayed for non-admin users based on DLC expiration status, with logic to handle snoozing and auto-dismissal. Updates are also reflected in database backup files.

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/jnL5Pt5
This commit is contained in:
michaelschal committed 2025-09-24 12:04:15 +00:00
1 parent 7b359e4f3f
commit 0a328c147e
4 files changed
+650 -241

No files matched your search

+39
View File
@@ -10,11 +10,13 @@ import { Calendar, Package, ShoppingCart, TrendingUp, Clock, MapPin, User, Alert
import { safeFormat, safeDate } from "@/lib/dateUtils";
import type { PublicityWithRelations, DashboardMessage } from "@shared/schema";
import AnnouncementCard from "@/components/AnnouncementCard";
import { DlcAlertModal } from "@/components/DlcAlertModal";
export default function Dashboard() {
const { user } = useAuthUnified();
const { selectedStoreId } = useStore();
const [showAnnouncementModal, setShowAnnouncementModal] = useState(false);
const [showDlcAlertModal, setShowDlcAlertModal] = useState(false);
const { data: stats } = useQuery({
queryKey: ['/api/stats/monthly', selectedStoreId],
@@ -229,6 +231,35 @@ 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);
if (shouldShowDlcModal && !showDlcAlertModal) {
// Vérifier s'il n'y a pas de snooze actif
const snoozedUntil = localStorage.getItem('dlcAlertSnooze');
if (snoozedUntil) {
const snoozeDate = new Date(snoozedUntil);
if (new Date() >= snoozeDate) {
localStorage.removeItem('dlcAlertSnooze');
setShowDlcAlertModal(true);
}
} else {
setShowDlcAlertModal(true);
}
} else if (!shouldShowDlcModal && showDlcAlertModal) {
// Fermer le modal si plus de problèmes DLC
setShowDlcAlertModal(false);
}
}, [user?.role, dlcStats.expired, dlcStats.expiringSoon, showDlcAlertModal]);
// Fonction pour fermer le modal DLC
const handleCloseDlcAlertModal = () => {
setShowDlcAlertModal(false);
};
// Fetch tasks
const { data: tasks = [] } = useQuery({
queryKey: ["/api/tasks", selectedStoreId],
@@ -740,6 +771,14 @@ export default function Dashboard() {
</div>
</DialogContent>
</Dialog>
{/* Modal d'alerte DLC pour les utilisateurs non-admin */}
<DlcAlertModal
isOpen={showDlcAlertModal}
onClose={handleCloseDlcAlertModal}
dlcStats={dlcStats}
selectedStoreId={selectedStoreId}
/>
</div>
);
}