mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-13 18:28:38 +02:00
Update dashboard to refresh DLC products and stats when store changes
Import `useQueryClient` from `@tanstack/react-query` and add a `useEffect` hook to invalidate `/api/dlc-products` and `/api/dlc-products/stats` queries when `selectedStoreId` changes. 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
6d718221e4
commit
704e6fc9c6
1 file changed
+8
-1
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useAuthUnified } from "@/hooks/useAuthUnified";
|
||||
import { useStore } from "@/contexts/StoreContext";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
@@ -15,9 +15,16 @@ import { DlcAlertModal } from "@/components/DlcAlertModal";
|
||||
export default function Dashboard() {
|
||||
const { user } = useAuthUnified();
|
||||
const { selectedStoreId } = useStore();
|
||||
const queryClient = useQueryClient();
|
||||
const [showAnnouncementModal, setShowAnnouncementModal] = useState(false);
|
||||
const [showDlcAlertModal, setShowDlcAlertModal] = useState(false);
|
||||
|
||||
// Invalider les queries DLC quand le magasin change
|
||||
useEffect(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ["/api/dlc-products"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["/api/dlc-products/stats"] });
|
||||
}, [selectedStoreId, queryClient]);
|
||||
|
||||
const { data: stats } = useQuery({
|
||||
queryKey: ['/api/stats/monthly', selectedStoreId],
|
||||
queryFn: async () => {
|
||||
|
||||
Reference in new issue
Block a user