RoomSingle.js 1.59 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
0727    
우지원 committed
13
  async function getJoinRoom(Id) {
우지원's avatar
우지원 committed
14
    try {
우지원's avatar
0727    
우지원 committed
15
16
17
18
      console.log('id:',id)
      const User = await userApi.getUser({id: Id})
      console.log('User1:',User)
      console.log('User2:',User.roomNumber)
우지원's avatar
e    
우지원 committed
19
20
      setRoomNum(User.data.roomNumber)
      const Room = await roomApi.getRoom(roomNum)
우지원's avatar
우지원 committed
21
22
23
24
25
26
    } catch (error) {
      // catchErrors(error, setError)
    }
  }

  useEffect(() => {
우지원's avatar
e    
우지원 committed
27
    getJoinRoom(id)
우지원's avatar
우지원 committed
28
29
  }, [id])

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

seoyeon's avatar
seoyeon committed
60
61
62
    </Link>
  )
}
Kim, Chaerin's avatar
Kim, Chaerin committed
63

seoyeon's avatar
seoyeon committed
64
export default RoomSingle