ClosedList.js 2.41 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
import "../Pages/Home.css";
Choi Ga Young's avatar
Choi Ga Young committed
4

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

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

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

Choi Ga Young's avatar
Choi Ga Young committed
28
29
30
31
32
33
34
35
36
37
38
  // 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
39

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

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

Choi Ga Young's avatar
Choi Ga Young committed
50
51
52
53
54
55
56
57
58
  //   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
59

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

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

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