Commit 174f88d0 authored by 우지원's avatar 우지원
Browse files

Merge remote-tracking branch 'origin/young' into jiweon827

parents 8abb9799 a09f29f3
...@@ -89,7 +89,7 @@ function Chat(props) { ...@@ -89,7 +89,7 @@ function Chat(props) {
<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: '' }}>
<Row className="d-flex justify-content-center" style={{ border: "2px solid", borderWidth: "medium", borderColor: "#FFD75F", height: "80px", margin: "1%" }}> <Row className="d-flex justify-content-center" style={{ border: "2px solid", borderWidth: "medium", borderColor: "#FFD75F", height: "80px", margin: "1%" }}>
<Col md="auto"> <Col md="auto">
<Button variant="light" onClick={props.handleChatc} >{`<`}</Button> <Button variant="light" onClick={handleClick} >{`<`}</Button>
</Col> </Col>
<Col> <Col>
<Row style={{ fontWeight: "bold", fontSize: "x-large" }}> {roomName} </Row> <Row style={{ fontWeight: "bold", fontSize: "x-large" }}> {roomName} </Row>
...@@ -130,8 +130,6 @@ function Chat(props) { ...@@ -130,8 +130,6 @@ function Chat(props) {
}) })
} }
<Button variant="light" onClick={handleClick} >{`<`}</Button>
</Container > </Container >
<Form onSubmit={sendMsgCH} fluid> <Form onSubmit={sendMsgCH} fluid>
<Form.Group className='d-flex flex-wrap-nowrap justify-content-center m-3'> <Form.Group className='d-flex flex-wrap-nowrap justify-content-center m-3'>
......
...@@ -74,8 +74,6 @@ function Home() { ...@@ -74,8 +74,6 @@ function Home() {
setShow(false) setShow(false)
} }
async function attendListRoom() { async function attendListRoom() {
const userId = sessionStorage.getItem('userId'); //sessionStorage에 저장된 userId가져옴 const userId = sessionStorage.getItem('userId'); //sessionStorage에 저장된 userId가져옴
const roomId = room.roomId const roomId = room.roomId
...@@ -94,6 +92,22 @@ function Home() { ...@@ -94,6 +92,22 @@ function Home() {
e.preventDefault() e.preventDefault()
} }
useEffect(() => {
if (!(singleChat == '')) {
socket.emit("chat", {
roomInfo: roomCode,
sendInfo: {
msg: singleChat,
sender: singleUser,
img: singleImg
}
})
setSingleChat([''])
}
}, [singleChat])
useEffect(() => { useEffect(() => {
socket.on("sendedMSG", (sendInfo) => { socket.on("sendedMSG", (sendInfo) => {
setRecievedImg(sendInfo.img) setRecievedImg(sendInfo.img)
...@@ -111,7 +125,7 @@ function Home() { ...@@ -111,7 +125,7 @@ function Home() {
<Tab eventKey="closed" title="내 채팅" onClick={handleChato} > <Tab eventKey="closed" title="내 채팅" onClick={handleChato} >
<ClosedList enterChatRoom={enterChatRoom} setRoomCode={setRoomCode} setRoomName={setRoomName} roomCode={roomCode} /> <ClosedList enterChatRoom={enterChatRoom} setRoomCode={setRoomCode} setRoomName={setRoomName} roomCode={roomCode} />
</Tab> </Tab>
<Tab eventKey="open" title="공개방" onClick={handleChato}> <Tab eventKey="open" title="공개방" onClick={handleChatc}>
<OpenList enterChatRoom={enterChatRoom} openListroom={openListroom} setRoomCode={setRoomCode} setRoomName={setRoomName} roomCode={roomCode} /> <OpenList enterChatRoom={enterChatRoom} openListroom={openListroom} setRoomCode={setRoomCode} setRoomName={setRoomName} roomCode={roomCode} />
</Tab> </Tab>
</Tabs> </Tabs>
...@@ -126,7 +140,7 @@ function Home() { ...@@ -126,7 +140,7 @@ function Home() {
</div> </div>
} }
{chat ? {chat ?
<Chat handleChatc={handleChatc} sendMsg={sendMsg} singleChat={singleChat} recievedMsg={recievedMsg} setSingleChat={setSingleChat} roomCode={roomCode} roomName={roomName} /> <Chat handleChatc={handleChatc} sendMsg={sendMsg} singleChat={singleChat} singleUser={singleUser} singleImg={singleImg} recievedMsg={recievedMsg} recievedUser={recievedUser} recievedImg={recievedImg} setSingleChat={setSingleChat} setSingleUser={setSingleUser} setSingleImg={setSingleImg} roomCode={roomCode} roomName={roomName} />
: 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">
...@@ -153,4 +167,4 @@ function Home() { ...@@ -153,4 +167,4 @@ function Home() {
); );
} }
export default Home export default Home;
\ No newline at end of file
...@@ -39,7 +39,7 @@ const makeRoom = async (req, res) => { ...@@ -39,7 +39,7 @@ const makeRoom = async (req, res) => {
const getClosedList = async (req, res) => { const getClosedList = async (req, res) => {
try { try {
console.log('req확인', req.query._id) console.log('req확인', req.query._id)
let list = await Room.find({ member: [req.query._id] }) let list = await Room.find({ member: req.query._id })
console.log('c_list가져오기', list) console.log('c_list가져오기', list)
return res.json(list) return res.json(list)
} catch (error) { } catch (error) {
...@@ -50,7 +50,7 @@ const getClosedList = async (req, res) => { ...@@ -50,7 +50,7 @@ const getClosedList = async (req, res) => {
const getOpenList = async (req, res) => { const getOpenList = async (req, res) => {
try { try {
let list = await Room.find({ isOpen: true }) let list = await Room.find({ isOpen: true })
console.log('o_list가져오기', list.roomName) console.log('o_list가져오기', list)
return res.json(list) return res.json(list)
} catch (error) { } catch (error) {
res.status(500).send('리스트 불러오기를 실패하였습니다!') res.status(500).send('리스트 불러오기를 실패하였습니다!')
......
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