Spaces:
Configuration error
Configuration error
File size: 963 Bytes
3dee94a | 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 31 | import { useEffect, useState } from 'react'
export default function Sidebar({ onSelect }) {
const [sessions, setSessions] = useState([])
useEffect(() => {
fetch('http://localhost:4000/sessions')
.then(res => res.json())
.then(data => setSessions(data))
.catch(err => console.error('Erro ao carregar sessões:', err))
}, [])
return (
<aside className="w-64 h-full bg-zinc-800 border-r border-zinc-700 p-4 text-white overflow-y-auto">
<h2 className="text-lg font-semibold mb-4">Histórico</h2>
<ul className="space-y-2">
{sessions.map(session => (
<li key={session.id}>
<button
onClick={() => onSelect(session.messages)}
className="w-full text-left text-sm bg-zinc-700 hover:bg-zinc-600 px-3 py-2 rounded"
>
{session.id}
</button>
</li>
))}
</ul>
</aside>
)
}
|