RoomSingle.js 1.48 KB
Newer Older
우지원's avatar
우지원 committed
1
import { useEffect, useState } from 'react';
seoyeon's avatar
seoyeon committed
2
import { Link } from 'react-router-dom'
우지원's avatar
e    
우지원 committed
3
import roomApi from '../../apis/room.api';
우지원's avatar
우지원 committed
4
5
import userApi from '../../apis/user.api';

Kim, Chaerin's avatar
Kim, Chaerin committed
6

Kim, Chaerin's avatar
Kim, Chaerin committed
7
const RoomSingle = () => {
우지원's avatar
e    
우지원 committed
8
9
  const [roomNum, setRoomNum] = useState([])
  const [room, setRoom] = useState([])
우지원's avatar
우지원 committed
10
  const id = localStorage.getItem('user');
seoyeon's avatar
seoyeon committed
11
  const channelId = 1
우지원's avatar
우지원 committed
12

우지원's avatar
e    
우지원 committed
13
  async function getJoinRoom(id) {
우지원's avatar
우지원 committed
14
    try {
우지원's avatar
e    
우지원 committed
15
16
17
      const User = await userApi.getUser(id)
      setRoomNum(User.data.roomNumber)
      const Room = await roomApi.getRoom(roomNum)
우지원's avatar
우지원 committed
18
19
20
21
22
23
    } catch (error) {
      // catchErrors(error, setError)
    }
  }

  useEffect(() => {
우지원's avatar
e    
우지원 committed
24
    getJoinRoom(id)
우지원's avatar
우지원 committed
25
26
  }, [id])

Kim, Chaerin's avatar
Kim, Chaerin committed
27
  return (
seoyeon's avatar
seoyeon committed
28
29
30
31
    <Link
      to={`/room/${id}/${channelId}`}
      className="text-decoration-none text-dark"
    >
Kim, Chaerin's avatar
Kim, Chaerin committed
32
      <div
우지원's avatar
우지원 committed
33
        className="d-flex mx-4 my-2 p-2"
seoyeon's avatar
seoyeon committed
34
        style={{ backgroundColor: '#C4C4C4' }}
Kim, Chaerin's avatar
Kim, Chaerin committed
35
      >
seoyeon's avatar
seoyeon committed
36
        <div style={{ width: '37px', height: '37px' }}>
Kim, Chaerin's avatar
Kim, Chaerin committed
37
38
39
          <img
            src="BORA.png"
            className="rounded-circle"
seoyeon's avatar
seoyeon committed
40
            style={{ width: '37px', height: '37px' }}
Kim, Chaerin's avatar
Kim, Chaerin committed
41
42
          />
        </div>
seoyeon's avatar
seoyeon committed
43
44
45
46
47
48
49
50
51
52
53
        <div
          className="mx-3 mt-2"
          style={{
            width: '250px',
            overflow:'scroll',
            whiteSpace: 'nowrap',
            msOverflowStyle:'none',
          }}
        >
          데계 재미있는 수학과 데계데계데계 재미있는 수학과
        </div>
우지원's avatar
우지원 committed
54
        <div className="ms-auto mt-2"> 15/34 </div>
Kim, Chaerin's avatar
Kim, Chaerin committed
55
      </div>
우지원's avatar
우지원 committed
56

seoyeon's avatar
seoyeon committed
57
58
59
    </Link>
  )
}
Kim, Chaerin's avatar
Kim, Chaerin committed
60

seoyeon's avatar
seoyeon committed
61
export default RoomSingle