Trigger data refetch on mount for events and themes pages

Added `useEffect` hooks to automatically refetch guests data in the Event Detail Page and themes data in the Event Themes Page upon component mount. This ensures the displayed data is always up-to-date when the user navigates to these pages.
This commit is contained in:
2025-03-19 09:02:57 +01:00
parent 31c6ae3f5c
commit 1f1192fb62
2 changed files with 11 additions and 1 deletions

View File

@@ -27,11 +27,13 @@ import {
import { useEventThemes } from "@/context/event-theme-context";
import { getServerFileUrl } from "@/lib/utils";
import GuestsList from "@/components/guests/guests-list";
import { useGuests } from "@/context/guest-context";
export default function EventDetailPage() {
const { slug } = useParams<{ slug: string }>();
const { event, fetchEventBySlug, isLoadingEvent, eventError } = useEvents();
const { themes } = useEventThemes();
const { refetchGuests } = useGuests();
const currentTheme =
event?.theme_id && themes
? themes.find((theme) => theme.id === event.theme_id)
@@ -44,6 +46,10 @@ export default function EventDetailPage() {
fetchEventBySlug(slug);
}, [slug, fetchEventBySlug]);
useEffect(() => {
refetchGuests();
}, []);
if (isLoadingEvent) {
return (
<div className="flex items-center justify-center min-h-[50vh]">