Refresh event list after create
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { CalendarDays, ChevronDown, MapPin } from 'lucide-react';
|
||||
import { YStack, XStack } from '@tamagui/stacks';
|
||||
@@ -31,6 +32,7 @@ import { useBackNavigation } from './hooks/useBackNavigation';
|
||||
import { useAdminTheme } from './theme';
|
||||
import { withAlpha } from './components/colors';
|
||||
import { useAuth } from '../auth/context';
|
||||
import { useEventContext } from '../context/EventContext';
|
||||
|
||||
type FormState = {
|
||||
name: string;
|
||||
@@ -52,6 +54,8 @@ export default function MobileEventFormPage() {
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation(['management', 'common']);
|
||||
const { user } = useAuth();
|
||||
const { selectEvent, refetch } = useEventContext();
|
||||
const queryClient = useQueryClient();
|
||||
const { text, muted, subtle, danger, border, surface, primary } = useAdminTheme();
|
||||
const isSuperAdmin = user?.role === 'super_admin' || user?.role === 'superadmin';
|
||||
|
||||
@@ -259,6 +263,9 @@ export default function MobileEventFormPage() {
|
||||
},
|
||||
} as Parameters<typeof createEvent>[0];
|
||||
const { event } = await createEvent(payload);
|
||||
selectEvent(event.slug);
|
||||
void queryClient.invalidateQueries({ queryKey: ['tenant-events'] });
|
||||
void refetch();
|
||||
void trackOnboarding('event_created', { event_id: event.id });
|
||||
navigate(adminPath(`/mobile/events/${event.slug}`));
|
||||
}
|
||||
@@ -307,6 +314,9 @@ export default function MobileEventFormPage() {
|
||||
...pendingPayload,
|
||||
accepted_waiver: consents.acceptedWaiver,
|
||||
});
|
||||
selectEvent(event.slug);
|
||||
void queryClient.invalidateQueries({ queryKey: ['tenant-events'] });
|
||||
void refetch();
|
||||
void trackOnboarding('event_created', { event_id: event.id });
|
||||
navigate(adminPath(`/mobile/events/${event.slug}`));
|
||||
setConsentOpen(false);
|
||||
|
||||
Reference in New Issue
Block a user