Commit ff15706b authored by Choi Ga Young's avatar Choi Ga Young
Browse files

불필요한거 삭제중

parent 0bece6ad
...@@ -153,12 +153,7 @@ function Chat(props) { ...@@ -153,12 +153,7 @@ function Chat(props) {
getPreviousChat() getPreviousChat()
}, [props.roomCode]) }, [props.roomCode])
useEffect(() => { //const time = new Date().toLocaleTimeString()
getRoomName(props.roomCode)
console.log('겟 룸네임', chat)
}, [props.roomCode])
const time = new Date().toLocaleTimeString()
return ( return (
<> <>
<Container id="chat" style={{ overflow: 'auto', padding: '20px', border: "2px solid", height: "500px", margin: "1%", borderColor: "#BDBDBD", background: '' }}> <Container id="chat" style={{ overflow: 'auto', padding: '20px', border: "2px solid", height: "500px", margin: "1%", borderColor: "#BDBDBD", background: '' }}>
...@@ -182,7 +177,7 @@ function Chat(props) { ...@@ -182,7 +177,7 @@ function Chat(props) {
: null} : null}
<p>{props.newUser}님이 입장하셨습니다.</p> <p>{props.newUser}님이 입장하셨습니다.</p>
{chat.map((value, index) => { {chat.map((value, index) => {
if (!(value == '')) { if (!(value === '')) {
if (!(sender[index] === user.nickname)) { if (!(sender[index] === user.nickname)) {
return ( //상대편 메시지 return ( //상대편 메시지
<Row key={index} className='m-1' > <Row key={index} className='m-1' >
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { Badge, Button, ListGroup } from 'react-bootstrap'; import { Badge, ListGroup } from 'react-bootstrap';
import axios from 'axios' import axios from 'axios'
function ClosedList(props) { function ClosedList(props) {
......
...@@ -11,18 +11,12 @@ const INIT_ROOM = { ...@@ -11,18 +11,12 @@ const INIT_ROOM = {
function RoomMake(props) { function RoomMake(props) {
const [room, setRoom] = useState(INIT_ROOM); const [room, setRoom] = useState(INIT_ROOM);
const [disabled, setDisabled] = useState(true);
const [error, setError] = useState(''); const [error, setError] = useState('');
useEffect(() => {
const isRoom = Object.values(room).every(el => Boolean(el))
isRoom ? setDisabled(false) : setDisabled(true)
}, [room])
const member = sessionStorage.getItem('userId'); const member = sessionStorage.getItem('userId');
function handleChange(event) { function handleChange(event) {
const { name, value } = event.target const { name, value } = event.target
setRoom({ ...room, [name]: value , member}) setRoom({ ...room, [name]: value, member })
// console.log(room) // console.log(room)
} }
...@@ -36,7 +30,7 @@ function RoomMake(props) { ...@@ -36,7 +30,7 @@ function RoomMake(props) {
props.handleCloseModal() props.handleCloseModal()
props.handleChato() props.handleChato()
setRoom(INIT_ROOM) setRoom(INIT_ROOM)
} catch (error){ } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
} }
} }
......
...@@ -60,7 +60,6 @@ function Home() { ...@@ -60,7 +60,6 @@ function Home() {
console.log(`joinRoom : ${rCode} 입장`) console.log(`joinRoom : ${rCode} 입장`)
//여기서 채팅 불러와서 넘겨주던가 해야할거 같은데 //여기서 채팅 불러와서 넘겨주던가 해야할거 같은데
} }
const [roomName, setRoomName] = useState('')
function closeChatRoom(rCode) { function closeChatRoom(rCode) {
socket.emit('closeRoom', rCode) socket.emit('closeRoom', rCode)
...@@ -103,7 +102,7 @@ function Home() { ...@@ -103,7 +102,7 @@ function Home() {
} }
useEffect(() => { useEffect(() => {
if (!(singleChat == "")){ if (!(singleChat == "")) {
socket.emit("chat", { socket.emit("chat", {
roomInfo: roomCode, roomInfo: roomCode,
sendInfo: { sendInfo: {
...@@ -149,10 +148,10 @@ function Home() { ...@@ -149,10 +148,10 @@ function Home() {
<Col className="list" md={5}> <Col className="list" md={5}>
<Tabs defaultActiveKey="closed" id="uncontrolled-tab-example" > <Tabs defaultActiveKey="closed" id="uncontrolled-tab-example" >
<Tab eventKey="closed" title="내 채팅" onClick={handleChato} > <Tab eventKey="closed" title="내 채팅" onClick={handleChato} >
<ClosedList enterChatRoom={enterChatRoom} setRoomCode={setRoomCode} setRoomName={setRoomName} roomCode={roomCode} closeChatRoom={closeChatRoom}/> <ClosedList enterChatRoom={enterChatRoom} setRoomCode={setRoomCode} setRoomName={setRoomName} roomCode={roomCode} closeChatRoom={closeChatRoom} />
</Tab> </Tab>
<Tab eventKey="open" title="공개방" onClick={handleChatc}> <Tab eventKey="open" title="공개방" onClick={handleChatc}>
<OpenList enterChatRoom={enterChatRoom} openListroom={openListroom} setRoomCode={setRoomCode} setRoomName={setRoomName} roomCode={roomCode} closeChatRoom={closeChatRoom}/> <OpenList enterChatRoom={enterChatRoom} openListroom={openListroom} setRoomCode={setRoomCode} setRoomName={setRoomName} roomCode={roomCode} closeChatRoom={closeChatRoom} />
</Tab> </Tab>
</Tabs> </Tabs>
</Col> </Col>
...@@ -166,7 +165,7 @@ function Home() { ...@@ -166,7 +165,7 @@ function Home() {
</div> </div>
} }
{chat ? {chat ?
<Chat handleChatc={handleChatc} sendMsg={sendMsg} singleChat={singleChat} singleUser={singleUser} singleImg={singleImg} recievedMsg={recievedMsg} recievedUser={recievedUser} recievedImg={recievedImg} setSingleChat={setSingleChat} setRecievedMsg={setRecievedMsg} setSingleUser={setSingleUser} setSingleImg={setSingleImg} roomCode={roomCode} roomName={roomName} closeChatRoom={closeChatRoom} exitRoom={exitRoom}/> <Chat handleChatc={handleChatc} leaveInfo={leaveInfo} setLeaveInfo={setLeaveInfo} sendMsg={sendMsg} singleChat={singleChat} singleUser={singleUser} singleImg={singleImg} singleTime={singleTime} recievedMsg={recievedMsg} recievedUser={recievedUser} recievedImg={recievedImg} recievedTime={recievedTime} setSingleChat={setSingleChat} setSingleUser={setSingleUser} setSingleImg={setSingleImg} setSingleTime={setSingleTime} setRecievedMsg={setRecievedMsg} roomCode={roomCode} roomName={roomName} closeChatRoom={closeChatRoom} exitRoom={exitRoom} />
: null} : null}
{open ? {open ?
<div className="vh-90 flex-column align-items-center justify-content-center mt-2" variant="dark"> <div className="vh-90 flex-column align-items-center justify-content-center mt-2" variant="dark">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment