mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +02:00
Update statistics panel to show data for the current month only
Fix StatsPanel component to use a passed-in currentDate prop, defaulting to new Date(), and update Calendar page to pass currentDate to StatsPanel. Refactor useQuery to include fetch logic. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/r0JXGx6
This commit is contained in:
1 parent
79cf87d067
commit
25af55c840
2 files changed
+17
-3
No files matched your search
@@ -4,10 +4,13 @@ import { TrendingUp, Package, Truck, Clock } from "lucide-react";
|
||||
import { useStore } from "./Layout";
|
||||
import { useAuthUnified } from "@/hooks/useAuthUnified";
|
||||
|
||||
export default function StatsPanel() {
|
||||
interface StatsPanelProps {
|
||||
currentDate?: Date;
|
||||
}
|
||||
|
||||
export default function StatsPanel({ currentDate = new Date() }: StatsPanelProps) {
|
||||
const { selectedStoreId } = useStore();
|
||||
const { user } = useAuthUnified();
|
||||
const currentDate = new Date();
|
||||
const year = currentDate.getFullYear();
|
||||
const month = currentDate.getMonth() + 1;
|
||||
|
||||
@@ -16,6 +19,17 @@ export default function StatsPanel() {
|
||||
|
||||
const { data: stats, isLoading } = useQuery({
|
||||
queryKey: [statsUrl, selectedStoreId], // Include selectedStoreId in key to force refetch
|
||||
queryFn: async () => {
|
||||
const response = await fetch(statsUrl, {
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch stats');
|
||||
}
|
||||
|
||||
return response.json();
|
||||
},
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
|
||||
@@ -267,7 +267,7 @@ export default function Calendar() {
|
||||
)}
|
||||
|
||||
{/* Stats Panel */}
|
||||
<StatsPanel />
|
||||
<StatsPanel currentDate={currentDate} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user