typescript-typenfehler behoben.. npm run lint läuft nun fehlerfrei durch.

This commit is contained in:
Codex Agent
2025-11-22 11:49:47 +01:00
parent 6c78d7e281
commit eb41cb6194
74 changed files with 469 additions and 396 deletions

View File

@@ -9,6 +9,20 @@ import { useTranslation } from '../i18n/useTranslation';
type Props = { token: string };
type PreviewFilter = 'latest' | 'popular' | 'mine' | 'photobooth';
type PreviewPhoto = {
id: number;
session_id?: string | null;
ingest_source?: string | null;
likes_count?: number | null;
created_at?: string | null;
task_id?: number | null;
task_title?: string | null;
emotion_id?: number | null;
emotion_name?: string | null;
thumbnail_path?: string | null;
file_path?: string | null;
title?: string | null;
};
export default function GalleryPreview({ token }: Props) {
const { locale } = useTranslation();
@@ -16,28 +30,29 @@ export default function GalleryPreview({ token }: Props) {
const [mode, setMode] = React.useState<PreviewFilter>('latest');
const items = React.useMemo(() => {
let arr = photos.slice();
const typed = photos as PreviewPhoto[];
let arr = typed.slice();
// MyPhotos filter (requires session_id matching)
if (mode === 'mine') {
const deviceId = getDeviceId();
arr = arr.filter((photo: any) => photo.session_id === deviceId);
arr = arr.filter((photo) => photo.session_id === deviceId);
} else if (mode === 'photobooth') {
arr = arr.filter((photo: any) => photo.ingest_source === 'photobooth');
arr = arr.filter((photo) => photo.ingest_source === 'photobooth');
}
// Sorting
if (mode === 'popular') {
arr.sort((a: any, b: any) => (b.likes_count ?? 0) - (a.likes_count ?? 0));
arr.sort((a, b) => (b.likes_count ?? 0) - (a.likes_count ?? 0));
} else {
arr.sort((a: any, b: any) => new Date(b.created_at ?? 0).getTime() - new Date(a.created_at ?? 0).getTime());
arr.sort((a, b) => new Date(b.created_at ?? 0).getTime() - new Date(a.created_at ?? 0).getTime());
}
return arr.slice(0, 4); // 2x2 = 4 items
}, [photos, mode]);
// Helper function to generate photo title (must be before return)
function getPhotoTitle(photo: any): string {
function getPhotoTitle(photo: PreviewPhoto): string {
if (photo.task_id) {
return `Task: ${photo.task_title || 'Unbekannte Aufgabe'}`;
}
@@ -102,7 +117,7 @@ export default function GalleryPreview({ token }: Props) {
)}
<div className="grid gap-3 sm:grid-cols-2">
{items.map((p: any) => (
{items.map((p: PreviewPhoto) => (
<Link
key={p.id}
to={`/e/${encodeURIComponent(token)}/gallery?photoId=${p.id}`}