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

5

6
function ClosedList(props) {
7

JeongYeonwoo's avatar
JeongYeonwoo committed
8
9
  const realTime = new Date().toISOString()

Soo Hyun Kim's avatar
Soo Hyun Kim committed
10
  function enterChatRoomCH(e) {
11
    const roomCode = e.target.name
Soo Hyun Kim's avatar
Soo Hyun Kim committed
12
    const roomName = e.target.value
13
    props.enterChatRoom(roomCode)
Soo Hyun Kim's avatar
Soo Hyun Kim committed
14
    props.setRoomCode(roomCode)
15

16
17
18
    // console.log('rrrrrrrrrrrrrrr',props.closedlist)
    // console.log('1111111111111111111',props.leaveInfo, typeof(props.leaveInfo))
    // unreadMessage()
19
  }
20
21
22
  
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//안읽은 메세지 count하는 부분
우지원's avatar
수정    
우지원 committed
23

24
25
26
27
28
29
30
31
32
33
34
  // 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])
35

36
37
38
39
  // useEffect(() => {
  //   // console.log('chat 클라이언트 변경!')
  //   unreadMessage()
  // }, [checknew])
JeongYeonwoo's avatar
JeongYeonwoo committed
40

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

46
47
48
49
50
51
52
53
54
  //   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
55

56
  // }
JeongYeonwoo's avatar
JeongYeonwoo committed
57

58

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

export default ClosedList