Apply all API enhancements

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 23:55:18 +00:00
parent 8f4110d890
commit d40f0f13aa
10 changed files with 435 additions and 45 deletions

View File

@@ -17,6 +17,7 @@ import { PhotoModal } from '@/components/moderation/PhotoModal';
import { EntityPhotoGalleryProps } from '@/types/submissions';
import { useUserRole } from '@/hooks/useUserRole';
import { useEntityPhotos } from '@/hooks/photos/useEntityPhotos';
import { useQueryInvalidation } from '@/lib/queryInvalidation';
interface Photo {
id: string;
@@ -49,6 +50,13 @@ export function EntityPhotoGallery({
sortBy
);
// Query invalidation for cross-component cache updates
const {
invalidateEntityPhotos,
invalidatePhotoCount,
invalidateHomepageData
} = useQueryInvalidation();
const handleUploadClick = () => {
if (!user) {
navigate('/auth');
@@ -59,7 +67,14 @@ export function EntityPhotoGallery({
const handleSubmissionComplete = () => {
setShowUpload(false);
refetch(); // Refresh photos after submission
// Invalidate all related caches
invalidateEntityPhotos(entityType, entityId);
invalidatePhotoCount(entityType, entityId);
invalidateHomepageData(); // Photos affect homepage stats
// Also refetch local component (immediate UI update)
refetch();
};
const handlePhotoClick = (index: number) => {