import React, { useState } from 'react'
import { ListGroup, Row, Col } from 'react-bootstrap';

function ClosedList(props) {
  const [list, setList] = useState([
    { room: '테스트 방1', memnum: 5, admin: '가영' },
    { room: '테스트 방2', memnum: 4, admin: '수현' }]
  );

  function enterChatRoomCH(e) {
    console.log(e.target.name)
    console.log(e.target)
    const roomName = e.target.name
    props.enterChatRoom(roomName) // 각각의 room으로 들어가도록 설정해야 함
    props.setRoomName(roomName)
    // props.clearChat()
  }

  return (
    <div>
      {list.map((item, index) =>
        <ListGroup key={index}>
          <ListGroup.Item action onClick={enterChatRoomCH} name={item.room}>
          {item.room}
          </ListGroup.Item>
        </ListGroup>
      )}
    </div>
  )
}

export default ClosedList
