ClosedList.js 2.35 KB
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
1
import React from 'react'
Choi Ga Young's avatar
Choi Ga Young committed
2
import { Badge, ListGroup } from 'react-bootstrap';
Choi Ga Young's avatar
Choi Ga Young committed
3

JeongYeonwoo's avatar
JeongYeonwoo committed
4
5
6
7
8
9
10
const INIT_LIST = [{
  interest: '',
  isOpen: '',
  memeber: [],
  roomId: '',
  roomName: '',
}]
11
function ClosedList(props) {
12

Soo Hyun Kim's avatar
Soo Hyun Kim committed
13
  function enterChatRoomCH(e) {
14
    if (props.roomCode) {
Soo Hyun Kim's avatar
Soo Hyun Kim committed
15
16
      props.closeChatRoom(props.roomCode)
    }
17
    const roomCode = e.target.name
Soo Hyun Kim's avatar
Soo Hyun Kim committed
18
    const roomName = e.target.value
19
    props.enterChatRoom(roomCode)
Soo Hyun Kim's avatar
Soo Hyun Kim committed
20
    props.setRoomCode(roomCode)
Soo Hyun Kim's avatar
Soo Hyun Kim committed
21
    props.setRoomName(roomName)
22

Choi Ga Young's avatar
Choi Ga Young committed
23
24
    // console.log('rrrrrrrrrrrrrrr', props.closedlist)
    // console.log('1111111111111111111', props.leaveInfo, typeof (props.leaveInfo))
25
  }
우지원's avatar
수정    
우지원 committed
26

Choi Ga Young's avatar
Choi Ga Young committed
27
28
29
30
31
32
33
34
35
36
37
  // const [checknew, setChecknew] = useState([])
  // const [unreadnumber, setUnreadnumber] = useState([''])
  // async function dbChat() {
  //   for (let i = 0; i <= props.closedlist.length - 1; i++) {
  //     const respond = await axios.get('/room/dbChat', { params: { 'roomId': props.closedlist[i].roomId } })
  //     setChecknew(respond.data)
  //   }
  // }
  // useEffect(() => {
  //   dbChat()
  // }, [props.singleChat, props.recievedMsg])
우지원's avatar
수정    
우지원 committed
38

Choi Ga Young's avatar
Choi Ga Young committed
39
40
41
42
  // useEffect(() => {
  //   // console.log('chat 클라이언트 변경!')
  //   unreadMessage()
  // }, [checknew])
JeongYeonwoo's avatar
JeongYeonwoo committed
43

Choi Ga Young's avatar
Choi Ga Young committed
44
45
46
47
  // async function unreadMessage() {
  //   //여기서 나간시간과 db의 메세지와 시간비교해서 개수를 count해주면 됨
  //   //물론 그 방 별로 찾아서 list를 맵써서 하던?
  //   // console.log('ddddddddd', list[0].roomId)
JeongYeonwoo's avatar
JeongYeonwoo committed
48

Choi Ga Young's avatar
Choi Ga Young committed
49
50
51
52
53
54
55
56
57
  //   setUnreadnumber([''])
  //   let arr = []
  //   for (let i = 0; i <= props.closedlist.length - 1; i++) {
  //     const respond = await axios.get('/room/unreadMessage', { params: { 'leaveInfo': props.leaveInfo, 'roomId': props.closedlist[i].roomId } })
  //     // setUnreadnumber([...unreadnumber, respond.data])
  //     arr = [...arr, respond.data]
  //   }
  //   setUnreadnumber(arr)
  //   // console.log('클라이언트 클로즈드 카운드', unreadnumber, list.length)
JeongYeonwoo's avatar
JeongYeonwoo committed
58

Choi Ga Young's avatar
Choi Ga Young committed
59
  // }
60

Choi Ga Young's avatar
Choi Ga Young committed
61
62
  return (
    <div>
63
      {props.closedlist.map((item, index) =>
Choi Ga Young's avatar
Choi Ga Young committed
64
        <ListGroup key={index}>
Soo Hyun Kim's avatar
Soo Hyun Kim committed
65
          <ListGroup.Item action onClick={enterChatRoomCH} name={item.roomId} value={item.roomName}>
Choi Ga Young's avatar
Choi Ga Young committed
66
            {item.roomName}
Choi Ga Young's avatar
Choi Ga Young committed
67
            {/* {[index] ? <Badge className='ml-2' pill variant='danger'>{unreadnumber[index]}</Badge> : ''} */}
Choi Ga Young's avatar
Choi Ga Young committed
68
69
          </ListGroup.Item>
        </ListGroup>
70
71
      )
      }
72
    </div >
Choi Ga Young's avatar
Choi Ga Young committed
73
74
75
  )
}

Soo Hyun Kim's avatar
Soo Hyun Kim committed
76
export default ClosedList