Commit 0bfa56e9 authored by Soo Hyun Kim's avatar Soo Hyun Kim
Browse files

0122 수현지원 수정

parent fe18c505
...@@ -28,6 +28,7 @@ function Chat(props) { ...@@ -28,6 +28,7 @@ function Chat(props) {
async function getRoomName(roomCode) { async function getRoomName(roomCode) {
try { try {
let res = await axios.get('/room/getRoomName', { params: { 'roomCode': roomCode } }) let res = await axios.get('/room/getRoomName', { params: { 'roomCode': roomCode } })
console.log(res.data)
setRoomName(res.data) setRoomName(res.data)
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
...@@ -49,6 +50,7 @@ function Chat(props) { ...@@ -49,6 +50,7 @@ function Chat(props) {
setDisabled(true) setDisabled(true)
console.log(chat) console.log(chat)
} }
useEffect(() => { useEffect(() => {
getProfile(userId) getProfile(userId)
}, [userId]) }, [userId])
...@@ -68,16 +70,6 @@ function Chat(props) { ...@@ -68,16 +70,6 @@ function Chat(props) {
getRoomName(props.roomCode) getRoomName(props.roomCode)
}, [props.roomCode]) }, [props.roomCode])
// function check() {
// // if (chat[chat.length-1].user ===chat[chat.length-2].user){ //마지막보낸거랑 그 전꺼랑 보낸사람이 같은지 비교
// if (chat.length === 2) {
// setHidden(false)
// } else {
// setHidden(true)
// }
// console.log(hidden)
// }
const time = new Date().toLocaleTimeString() const time = new Date().toLocaleTimeString()
return ( return (
<div className="chat" id="chat" style={{ border: "2px solid", height: "300%", margin: "1%", borderColor: "#BDBDBD", background: '' }}> <div className="chat" id="chat" style={{ border: "2px solid", height: "300%", margin: "1%", borderColor: "#BDBDBD", background: '' }}>
...@@ -90,8 +82,6 @@ function Chat(props) { ...@@ -90,8 +82,6 @@ function Chat(props) {
<Row > {props.roomCode} </Row> <Row > {props.roomCode} </Row>
</Col> </Col>
</Row> </Row>
{/* <h2> 참여코드 : {props.roomCode} </h2> */}
{/* 상대방이 보낸 메세지 띄우기 + 같은유저면 프로필 이미지는 생략(chat을 object로 보낸사람과 함께 보내서 구분하자) */}
{ {
chat.map((value, index) => { chat.map((value, index) => {
if (!(value == '')) { if (!(value == '')) {
......
...@@ -20,7 +20,7 @@ function ClosedList(props) { ...@@ -20,7 +20,7 @@ function ClosedList(props) {
const roomCode = e.target.name const roomCode = e.target.name
const roomName = e.target.value const roomName = e.target.value
props.enterChatRoom(roomCode) props.enterChatRoom(roomCode)
props.setRoomName(roomName) props.setRoomCode(roomCode)
} }
return ( return (
......
...@@ -118,7 +118,7 @@ function Home() { ...@@ -118,7 +118,7 @@ function Home() {
<Col style={{ padding: "0" }}> <Col style={{ padding: "0" }}>
{show ? <> {show ? <>
{chat ? {chat ?
<Chat handleChatc={handleChatc} sendMsg={sendMsg} singleChat={singleChat} recievedMsg={recievedMsg} setSingleChat={setSingleChat} roomName={roomName} /> <Chat handleChatc={handleChatc} sendMsg={sendMsg} singleChat={singleChat} recievedMsg={recievedMsg} setSingleChat={setSingleChat} roomCode={roomCode} roomName={roomName} />
: <div style={{ position: "fixed", bottom: "20px", right: "30px" }}> : <div style={{ position: "fixed", bottom: "20px", right: "30px" }}>
<Button variant="primary" onClick={handleShowModal} size="lg" block>생성</Button> <Button variant="primary" onClick={handleShowModal} size="lg" block>생성</Button>
<Button variant="secondary" onClick={handleShowEnter} size="lg" block>참가</Button> <Button variant="secondary" onClick={handleShowEnter} size="lg" block>참가</Button>
......
...@@ -61,9 +61,11 @@ const getOpenList = async (req, res) => { ...@@ -61,9 +61,11 @@ const getOpenList = async (req, res) => {
const getRoomName = async (req, res) => { const getRoomName = async (req, res) => {
const roomId = req.query.roomCode const roomId = req.query.roomCode
console.log(req.query.roomCode)
try { try {
let roominfo = await Room.findOne({ roomId: roomId }).select('roomName') let roominfo = await Room.findOne({ roomId: roomId }).select('roomName')
console.log(roominfo.roomName)
return res.json(roominfo.roomName) return res.json(roominfo.roomName)
} catch (error) { } catch (error) {
res.status(500).send('리스트 불러오기를 실패하였습니다!') res.status(500).send('리스트 불러오기를 실패하였습니다!')
...@@ -103,4 +105,4 @@ const roomInf = async (req, res) => { ...@@ -103,4 +105,4 @@ const roomInf = async (req, res) => {
} }
} }
export default { makeRoom, getClosedList, getOpenList, changemember, roomInf } export default { makeRoom, getClosedList, getOpenList, getRoomName, changemember, roomInf }
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