ClosedList.js 1.05 KB
Newer Older
우지원's avatar
수정    
우지원 committed
1
import axios from 'axios';
Choi Ga Young's avatar
Choi Ga Young committed
2
import React, { useState } from 'react'
3
import { ListGroup, Row, Col } from 'react-bootstrap';
Choi Ga Young's avatar
Choi Ga Young committed
4

5
function ClosedList(props) {
우지원's avatar
수정    
우지원 committed
6
7
8
9
10
11
12
13
14
15
  const [list, setList] = useState([]);

  // async function getClosedList() { //email로 db에서 찾아오기 ㅇㅇㅇㅇㅇ
  //   const member = sessionStorage.getItem('name')
  //   const response = await axios.put(`/room/${member}`, { 'member': member })
  //   setList(response.data)
  // }
  // console.log(list)


Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
16

17
  function enterChatroomCH(e) {
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
18
19
    console.log(e.target.name)
    console.log(e.target)
20
21
22
    const roomName = e.target.name
    props.enterChatroom(roomName) // 각각의 room으로 들어가도록 설정해야 함
    props.setRoomName(roomName)
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
23
    // props.clearChat()
24
25
  }

우지원's avatar
수정    
우지원 committed
26
27
  //user.hasOwnProperty('이름');

Choi Ga Young's avatar
Choi Ga Young committed
28
29
  return (
    <div>
Soo Hyun Kim's avatar
soo0115    
Soo Hyun Kim committed
30
      {list.map((item, index) =>
Choi Ga Young's avatar
Choi Ga Young committed
31
        <ListGroup key={index}>
32
          <ListGroup.Item action onClick={enterChatroomCH} name={item.room}>
우지원's avatar
수정    
우지원 committed
33
            {item.room}
Choi Ga Young's avatar
Choi Ga Young committed
34
35
36
37
38
39
40
41
          </ListGroup.Item>
        </ListGroup>
      )}
    </div>
  )
}

export default ClosedList