-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sidebar.js
56 lines (53 loc) · 1.62 KB
/
Sidebar.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React, { useEffect, useState } from "react";
import db from "./firebase";
import "./Sidebar.css";
import SidebarChat from "./SidebarChat";
import { Avatar, IconButton } from "@material-ui/core";
import MoreVertIcon from "@material-ui/icons/MoreVert";
import DonutLargeIcon from "@material-ui/icons/DonutLarge";
import ChatIcon from "@material-ui/icons/Chat";
import SearchOutlinedIcon from "@material-ui/icons/SearchOutlined";
function Sidebar({ addNewChat }) {
const [rooms, setRooms] = useState([]);
useEffect(() => {
db.collection("rooms").onSnapshot((snapshot) =>
setRooms(
snapshot.docs.map((doc) => ({
id: doc.id,
data: doc.data(),
}))
)
);
}, []);
return (
<div className="sidebar">
<div className="sidebar__header">
<Avatar />
<div className="sidebar__headerRight">
<IconButton>
<DonutLargeIcon />
</IconButton>
<IconButton>
<ChatIcon />
</IconButton>
<IconButton>
<MoreVertIcon />
</IconButton>
</div>
</div>
<div className="sidebar__search">
<div className="sidebar__searchContainer">
<SearchOutlinedIcon />
<input placeholder="Search or start new chat" type="text" />
</div>
</div>
<div className="sidebar__chats">
<SidebarChat addNewChat />
{rooms.map((room) => (
<SidebarChat key={room.id} id={room.id} name={room.data.name} />
))}
</div>
</div>
);
}
export default Sidebar;