web/src/components/BrowserList.js (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import { BrowserSession } from "./BrowserSession"; export default function BrowserList({ sessions, onSessionsChange, onError }) { const handleDelete = async (sessionId) => { try { const response = await fetch( `http://localhost:8080/api/browser/sessions/${sessionId}`, { method: "DELETE", }, ); if (!response.ok) throw new Error("Failed to delete session"); onSessionsChange(sessions.filter((session) => session.id !== sessionId)); } catch (err) { onError(err.message); } }; return ( <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"> {sessions.map((session) => ( <BrowserSession key={session.id} session={session} onDelete={() => handleDelete(session.id)} /> ))} </div> ); } |