import React, { useState, useEffect } from 'react'; import './App.css'; interface Photo { id: number; name: string; url: string; } interface HealthStatus { status: string; message: string; timestamp: string; } function App() { const [photos, setPhotos] = useState([]); const [health, setHealth] = useState(null); const [loading, setLoading] = useState(true); const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:3001'; useEffect(() => { const fetchData = async () => { try { // Health Check const healthResponse = await fetch(`${API_BASE_URL}/api/health`); const healthData = await healthResponse.json(); setHealth(healthData); // Photos const photosResponse = await fetch(`${API_BASE_URL}/api/photos`); const photosData = await photosResponse.json(); setPhotos(photosData.photos); } catch (error) { console.error('Fehler beim Laden der Daten:', error); } finally { setLoading(false); } }; fetchData(); }, [API_BASE_URL]); const handlePrint = async (photoId: number) => { try { const response = await fetch(`${API_BASE_URL}/api/print`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ photoId, copies: 1 }), }); const data = await response.json(); alert(`Druckauftrag erstellt: ${data.message}`); } catch (error) { console.error('Fehler beim Drucken:', error); alert('Fehler beim Erstellen des Druckauftrags'); } }; return (

📸 Fotodrucker

{health && (

Backend Status: {health.status}

Letzte Aktualisierung: {new Date(health.timestamp).toLocaleString()}
)} {loading ? (

Lade Fotos...

) : (

Verfügbare Fotos

{photos.map((photo) => (

{photo.name}

URL: {photo.url}

))}
)}
); } export default App;