Refactor homepage content fetching

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 22:26:02 +00:00
parent d7ef581220
commit 662c2fbed4
11 changed files with 911 additions and 580 deletions

View File

@@ -68,5 +68,31 @@ export function useQueryInvalidation() {
invalidateModerationStats: () => {
queryClient.invalidateQueries({ queryKey: queryKeys.moderationStats() });
},
/**
* Invalidate homepage data
* Call this after creating/updating parks or rides
*/
invalidateHomepageData: (entityType?: 'parks' | 'rides' | 'all') => {
if (!entityType || entityType === 'all') {
queryClient.invalidateQueries({ queryKey: ['homepage'] });
} else if (entityType === 'parks') {
queryClient.invalidateQueries({
queryKey: ['homepage'],
predicate: (query) => {
const key = query.queryKey[1] as string;
return typeof key === 'string' && key.includes('parks');
}
});
} else if (entityType === 'rides') {
queryClient.invalidateQueries({
queryKey: ['homepage'],
predicate: (query) => {
const key = query.queryKey[1] as string;
return typeof key === 'string' && key.includes('rides');
}
});
}
},
};
}