From 2e16450e2276e81f640e386d7bb630db890a7189 Mon Sep 17 00:00:00 2001 From: brooktewabe Date: Mon, 6 Apr 2026 11:47:53 +0300 Subject: [PATCH] selectedPropertyId bug fix --- src/lib/types/index.ts | 11 ++++------- src/pages/VisitsPage.tsx | 7 +++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/types/index.ts b/src/lib/types/index.ts index c297615..5df087b 100644 --- a/src/lib/types/index.ts +++ b/src/lib/types/index.ts @@ -188,7 +188,10 @@ export interface DashboardPayload { heatmap: { roomId: string; state: "vacant" | "not_ready" | "occupied" | "unavailable" }[]; revenueExtras: { label: string; current: number; target: number }[]; rating: { score: number; label: string; imageUrl?: string }; -}; + recentBookings: Booking[]; + calendarEvents: { id: string; title: string; date: string; accent: "sky" | "pink" | "violet" }[]; + codeStats: { discountRedemptions: number; referralRedemptions: number }; +} export enum HotelStaffRole { FRONT_DESK = "FRONT_DESK", @@ -213,9 +216,3 @@ export interface StaffAccess { }; createdAt: string; } - -export interface DashboardPayload { - recentBookings: Booking[]; - calendarEvents: { id: string; title: string; date: string; accent: "sky" | "pink" | "violet" }[]; - codeStats: { discountRedemptions: number; referralRedemptions: number }; -} diff --git a/src/pages/VisitsPage.tsx b/src/pages/VisitsPage.tsx index 19cf4a9..0dd0b06 100644 --- a/src/pages/VisitsPage.tsx +++ b/src/pages/VisitsPage.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useState } from "react"; +import { useAuthStore } from "@/store/authStore"; import { Bar, BarChart, @@ -29,6 +30,8 @@ export function VisitsPage() { >([]); const [recent, setRecent] = useState([]); + const selectedPropertyId = useAuthStore((s) => s.selectedPropertyId); + const refresh = useCallback(async () => { const v = await apiGet<{ series: Array<{ date: string; count: number }>; @@ -40,11 +43,11 @@ export function VisitsPage() { })).slice(-21)); const r = await apiGet<{ data: SiteVisit[] }>("/analytics/visits/recent"); setRecent(r.data); - }, []); + }, [selectedPropertyId]); useEffect(() => { refresh(); - }, [refresh]); + }, [refresh, selectedPropertyId]); async function simulateHit() { await apiPost("/analytics/visits", {