// @ts-nocheck import React from 'react'; import { useParams } from 'react-router-dom'; import { fetchPhotoShare } from '../services/photosApi'; import { Loader2, AlertCircle } from 'lucide-react'; interface ShareResponse { slug: string; expires_at?: string; photo: { id: number; title?: string; likes_count?: number; emotion?: { name?: string; emoji?: string | null } | null; created_at?: string | null; image_urls: { full: string; thumbnail: string }; }; event?: { id: number; name?: string | null } | null; } type ShareProps = { slug: string | undefined }; export function SharedPhotoStandalone() { const slug = React.useMemo(() => { const parts = window.location.pathname.split('/').filter(Boolean); return parts.length >= 2 ? parts[1] : undefined; }, []); return ; } export default function SharedPhotoPage() { const { slug } = useParams<{ slug: string }>(); return ; } function SharedPhotoView({ slug }: ShareProps) { const [state, setState] = React.useState<{ loading: boolean; error: string | null; data: ShareResponse | null; }>({ loading: true, error: null, data: null }); React.useEffect(() => { let active = true; if (!slug) return; setState({ loading: true, error: null, data: null }); fetchPhotoShare(slug) .then((data) => { if (active) setState({ loading: false, error: null, data }); }) .catch((error: unknown) => { if (!active) return; setState({ loading: false, error: 'Dieses Foto ist nicht mehr verfügbar.', data: null }); }); return () => { active = false; }; }, [slug]); if (state.loading) { return (

Moment wird geladen …

); } if (state.error || !state.data) { return (

Link abgelaufen

{state.error ?? 'Dieses Foto ist nicht mehr verfügbar.'}

); } const { data } = state; const chips = buildChips(data); return (

Geteiltes Foto

{data.event?.name ?? 'Ein besonderer Moment'}

{data.photo.title &&

{data.photo.title}

}
{data.photo.title
{chips.length > 0 && (
{chips.map((chip) => ( {chip.icon ? {chip.icon} : null} {chip.label} {chip.value} ))}
)}
); } function buildChips(data: ShareResponse): { id: string; label: string; value: string; icon?: string }[] { const list: { id: string; label: string; value: string; icon?: string }[] = []; if (data.photo.emotion?.name) { list.push({ id: 'emotion', label: 'Emotion', value: data.photo.emotion.name, icon: data.photo.emotion.emoji ?? '★' }); } if (data.photo.title) { list.push({ id: 'task', label: 'Aufgabe', value: data.photo.title }); } if (data.photo.created_at) { const date = formatDate(data.photo.created_at); list.push({ id: 'date', label: 'Aufgenommen', value: date }); } return list; } function formatDate(value: string): string { const parsed = new Date(value); if (Number.isNaN(parsed.getTime())) return ''; return parsed.toLocaleDateString(undefined, { day: '2-digit', month: 'short', year: 'numeric' }); }