'use client'; import { useEffect, useState } from 'react'; import Link from 'next/link'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Image as ImageIcon } from 'lucide-react'; interface Photo { id: number; path: string; title: string; size: number; thumbnail: string; type: string; } export default function PhotosPage() { const [photos, setPhotos] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetchPhotos(); }, []); const fetchPhotos = async () => { try { const response = await fetch('/api/photos'); const data = await response.json(); setPhotos(data); } catch (error) { console.error('Error fetching photos:', error); } finally { setLoading(false); } }; const formatFileSize = (bytes: number) => { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; }; if (loading) { return (

Loading photos...

); } return (

Photos

{photos.length} {photos.length === 1 ? 'photo' : 'photos'} found

{photos.length > 0 ? (
{photos.map((photo) => (
{photo.title} { (e.target as HTMLImageElement).src = '/placeholder-image.jpg'; }} />
View

{photo.title}

{formatFileSize(photo.size)}

))}
) : (

No Photos Found

Add media libraries to scan for photos

)}
); }