RoomHeader.js 1.31 KB
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
3
4
5
6
7
8
9
import { useEffect, useState } from "react";
import { useParams } from "react-router";
import roomApi from '../../apis/room.api';
import catchErrors from '../../context/catchError';

const INIT_ROOM = {
  profileimg: "",
};

Kim, Chaerin's avatar
Kim, Chaerin committed
10

Kim, Chaerin's avatar
Kim, Chaerin committed
11
const RoomHeader = () => {
Kim, Chaerin's avatar
Kim, Chaerin committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  const {roomId}=useParams();
  const [room, setRoom] = useState([INIT_ROOM]);
  const [error, setError] = useState("")
  async function getRoom(Id) {
    try {
      const Room = await roomApi.getRoom([Id]);
        setRoom({profileimg: Room[0].profileimg})
        console.log(room)
      }
     catch (error) {
      catchErrors(error, setError);
    }
  }

  useEffect(() => {
    getRoom(roomId);
  }, [roomId]);

Kim, Chaerin's avatar
Kim, Chaerin committed
30
  return (
우지원's avatar
우지원 committed
31
32
    <div
      className="d-flex justify-content-between align-items-center p-2"
seoyeon's avatar
ui0707    
seoyeon committed
33
      style={{ backgroundColor: '#C4C4C4', height: '60px' }}
우지원's avatar
우지원 committed
34
35
36
37
    >
      <div className="d-flex align-items-center">
        <img
          className="rounded-circle"
Kim, Chaerin's avatar
Kim, Chaerin committed
38
          src={`/roomUploads/${room.profileimg}`}
우지원's avatar
우지원 committed
39
40
41
42
43
44
45
          width="40px"
          height="40px"
        />
        <a
          className="p-3 ms-1 text-center text-decoration-none"
          style={{
            fontWeight: 'bold',
seoyeon's avatar
ui0707    
seoyeon committed
46
47
            fontSize: '20px',
            color: '#6c33a2',
우지원's avatar
우지원 committed
48
          }}
Kim, Chaerin's avatar
Kim, Chaerin committed
49
        >
seoyeon's avatar
ui0707    
seoyeon committed
50
          # 회의
우지원's avatar
우지원 committed
51
        </a>
Kim, Chaerin's avatar
Kim, Chaerin committed
52
53
      </div>
    </div>
seoyeon's avatar
0705    
seoyeon committed
54
55
  )
}
Kim, Chaerin's avatar
Kim, Chaerin committed
56

seoyeon's avatar
0705    
seoyeon committed
57
export default RoomHeader