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

0122 수현지원 수정

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