first commit

This commit is contained in:
bryan
2025-12-30 13:53:13 -06:00
commit f0e8d9400a
31 changed files with 12464 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import React, { useState, useEffect } from 'react';
import Sidebar from '../components/Sidebar';
import ChatArea from '../components/ChatArea';
const Chat = () => {
const [activeChannel, setActiveChannel] = useState(null);
const [channels, setChannels] = useState([]);
useEffect(() => {
fetch('http://localhost:3000/api/channels')
.then(res => res.json())
.then(data => {
setChannels(data);
if (data.length > 0 && !activeChannel) {
setActiveChannel(data[0].id);
}
})
.catch(err => console.error('Error fetching channels:', err));
}, []);
if (!activeChannel) return <div style={{ color: 'white', padding: 20 }}>Loading...</div>;
return (
<div className="app-container">
<Sidebar
channels={channels}
activeChannel={activeChannel}
onSelectChannel={setActiveChannel}
/>
<ChatArea channelId={activeChannel} />
</div>
);
};
export default Chat;