Show photobooth filter only when enabled
This commit is contained in:
13
resources/js/guest/lib/__tests__/galleryFilters.test.ts
Normal file
13
resources/js/guest/lib/__tests__/galleryFilters.test.ts
Normal file
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
5
resources/js/guest/lib/galleryFilters.ts
Normal file
5
resources/js/guest/lib/galleryFilters.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import type { EventData } from '../services/eventApi';
|
||||||
|
|
||||||
|
export function shouldShowPhotoboothFilter(event?: EventData | null): boolean {
|
||||||
|
return Boolean(event?.photobooth_enabled);
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import { fetchEvent, type EventData } from '../services/eventApi';
|
|||||||
import { useTranslation } from '../i18n/useTranslation';
|
import { useTranslation } from '../i18n/useTranslation';
|
||||||
import { useToast } from '../components/ToastHost';
|
import { useToast } from '../components/ToastHost';
|
||||||
import { localizeTaskLabel } from '../lib/localizeTaskLabel';
|
import { localizeTaskLabel } from '../lib/localizeTaskLabel';
|
||||||
|
import { shouldShowPhotoboothFilter } from '../lib/galleryFilters';
|
||||||
import { createPhotoShareLink } from '../services/photosApi';
|
import { createPhotoShareLink } from '../services/photosApi';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { useEventBranding } from '../context/EventBrandingContext';
|
import { useEventBranding } from '../context/EventBrandingContext';
|
||||||
@@ -96,10 +97,7 @@ export default function GalleryPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const typedPhotos = photos as GalleryPhoto[];
|
const typedPhotos = photos as GalleryPhoto[];
|
||||||
const showPhotoboothFilter = React.useMemo(
|
const showPhotoboothFilter = React.useMemo(() => shouldShowPhotoboothFilter(event), [event]);
|
||||||
() => Boolean(event?.photobooth_enabled) || typedPhotos.some((p) => p.ingest_source === 'photobooth'),
|
|
||||||
[event?.photobooth_enabled, typedPhotos],
|
|
||||||
);
|
|
||||||
const allowedGalleryFilters = React.useMemo<GalleryFilter[]>(
|
const allowedGalleryFilters = React.useMemo<GalleryFilter[]>(
|
||||||
() => (showPhotoboothFilter ? allGalleryFilters : ['latest', 'popular', 'mine']),
|
() => (showPhotoboothFilter ? allGalleryFilters : ['latest', 'popular', 'mine']),
|
||||||
[showPhotoboothFilter],
|
[showPhotoboothFilter],
|
||||||
|
|||||||
Reference in New Issue
Block a user