feat: Implement full Phase 3 API optimizations

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 23:02:26 +00:00
parent 46ca1c29bc
commit 0091584677
18 changed files with 654 additions and 243 deletions

View File

@@ -110,5 +110,81 @@ export function useQueryInvalidation() {
invalidateRides: () => {
queryClient.invalidateQueries({ queryKey: ['rides'] });
},
/**
* Invalidate park detail cache
* Call this after updating a park
*/
invalidateParkDetail: (slug: string) => {
queryClient.invalidateQueries({ queryKey: queryKeys.parks.detail(slug) });
},
/**
* Invalidate ride detail cache
* Call this after updating a ride
*/
invalidateRideDetail: (parkSlug: string, rideSlug: string) => {
queryClient.invalidateQueries({ queryKey: queryKeys.rides.detail(parkSlug, rideSlug) });
},
/**
* Invalidate entity reviews
* Call this after adding/updating/deleting reviews
*/
invalidateEntityReviews: (entityType: 'park' | 'ride', entityId: string) => {
queryClient.invalidateQueries({ queryKey: queryKeys.reviews.entity(entityType, entityId) });
},
/**
* Invalidate user reviews
* Call this after a user adds/updates/deletes their reviews
*/
invalidateUserReviews: (userId: string) => {
queryClient.invalidateQueries({ queryKey: ['reviews', 'user', userId] });
},
/**
* Invalidate entity photos
* Call this after uploading/deleting photos
*/
invalidateEntityPhotos: (entityType: string, entityId: string) => {
queryClient.invalidateQueries({ queryKey: queryKeys.photos.entity(entityType, entityId) });
},
/**
* Invalidate photo count
* Call this after photo changes
*/
invalidatePhotoCount: (entityType: string, entityId: string) => {
queryClient.invalidateQueries({ queryKey: queryKeys.photos.count(entityType, entityId) });
},
/**
* Invalidate search results
* Call this after major data changes
*/
invalidateSearchResults: () => {
queryClient.invalidateQueries({ queryKey: ['search'] });
},
/**
* Invalidate similar rides
* Call this after ride updates
*/
invalidateSimilarRides: (parkId: string, category: string) => {
queryClient.invalidateQueries({
queryKey: ['rides', 'similar', parkId, category]
});
},
/**
* Invalidate featured parks
* Call this after park updates that affect featured status
*/
invalidateFeaturedParks: () => {
queryClient.invalidateQueries({
queryKey: ['homepage', 'featured-parks']
});
},
};
}