From 83c58358a1d197c18eff6aba1671dadf004d557e Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Wed, 14 Jan 2026 11:45:29 +0100 Subject: [PATCH] Show photobooth filter only when enabled --- .../js/guest/lib/__tests__/galleryFilters.test.ts | 13 +++++++++++++ resources/js/guest/lib/galleryFilters.ts | 5 +++++ resources/js/guest/pages/GalleryPage.tsx | 6 ++---- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 resources/js/guest/lib/__tests__/galleryFilters.test.ts create mode 100644 resources/js/guest/lib/galleryFilters.ts diff --git a/resources/js/guest/lib/__tests__/galleryFilters.test.ts b/resources/js/guest/lib/__tests__/galleryFilters.test.ts new file mode 100644 index 0000000..3b5ce9e --- /dev/null +++ b/resources/js/guest/lib/__tests__/galleryFilters.test.ts @@ -0,0 +1,13 @@ +import { shouldShowPhotoboothFilter } from '../galleryFilters'; + +describe('shouldShowPhotoboothFilter', () => { + it('returns true when photobooth is enabled', () => { + expect(shouldShowPhotoboothFilter({ photobooth_enabled: true } as any)).toBe(true); + }); + + it('returns false when photobooth is disabled or missing', () => { + expect(shouldShowPhotoboothFilter({ photobooth_enabled: false } as any)).toBe(false); + expect(shouldShowPhotoboothFilter(null)).toBe(false); + expect(shouldShowPhotoboothFilter(undefined)).toBe(false); + }); +}); diff --git a/resources/js/guest/lib/galleryFilters.ts b/resources/js/guest/lib/galleryFilters.ts new file mode 100644 index 0000000..80f7636 --- /dev/null +++ b/resources/js/guest/lib/galleryFilters.ts @@ -0,0 +1,5 @@ +import type { EventData } from '../services/eventApi'; + +export function shouldShowPhotoboothFilter(event?: EventData | null): boolean { + return Boolean(event?.photobooth_enabled); +} diff --git a/resources/js/guest/pages/GalleryPage.tsx b/resources/js/guest/pages/GalleryPage.tsx index 2cdb5f1..9eb1c4f 100644 --- a/resources/js/guest/pages/GalleryPage.tsx +++ b/resources/js/guest/pages/GalleryPage.tsx @@ -12,6 +12,7 @@ import { fetchEvent, type EventData } from '../services/eventApi'; import { useTranslation } from '../i18n/useTranslation'; import { useToast } from '../components/ToastHost'; import { localizeTaskLabel } from '../lib/localizeTaskLabel'; +import { shouldShowPhotoboothFilter } from '../lib/galleryFilters'; import { createPhotoShareLink } from '../services/photosApi'; import { cn } from '@/lib/utils'; import { useEventBranding } from '../context/EventBrandingContext'; @@ -96,10 +97,7 @@ export default function GalleryPage() { }); const typedPhotos = photos as GalleryPhoto[]; - const showPhotoboothFilter = React.useMemo( - () => Boolean(event?.photobooth_enabled) || typedPhotos.some((p) => p.ingest_source === 'photobooth'), - [event?.photobooth_enabled, typedPhotos], - ); + const showPhotoboothFilter = React.useMemo(() => shouldShowPhotoboothFilter(event), [event]); const allowedGalleryFilters = React.useMemo( () => (showPhotoboothFilter ? allGalleryFilters : ['latest', 'popular', 'mine']), [showPhotoboothFilter],