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

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

parents eacfbbbf a176c47f
...@@ -6,12 +6,11 @@ function Chat(props) { ...@@ -6,12 +6,11 @@ function Chat(props) {
let defaultname = sessionStorage.getItem('name'); let defaultname = sessionStorage.getItem('name');
const [inner, setInner] = useState(['']) const [inner, setInner] = useState([''])
const [chat, setChat] = useState([inner]) //object로 key는 보낸사람 value는 메세지 const [chat, setChat] = useState([]) //object로 key는 보낸사람 value는 메세지
function handleChange(e) { function handleChange(e) {
e.preventDefault() e.preventDefault()
setInner(e.target.value) setInner(e.target.value)
console.log(e.target.value)
} }
function sendMsgCH(e) { function sendMsgCH(e) {
......
...@@ -18,8 +18,11 @@ function EnterRoom(props) { ...@@ -18,8 +18,11 @@ function EnterRoom(props) {
event.preventDefault() event.preventDefault()
try { try {
setError('') setError('')
await axios.post('/room/enterRoom', enterCode) let res = await axios.post('/room/enterRoom', { enterCode })
props.setRoomName(res.data)
props.enterChatRoom(enterCode) props.enterChatRoom(enterCode)
props.handleCloseEnter()
props.handleChato()
setEnterCode('') setEnterCode('')
} catch (error){ } catch (error){
catchErrors(error, setError) catchErrors(error, setError)
......
...@@ -24,6 +24,8 @@ function Home() { ...@@ -24,6 +24,8 @@ function Home() {
//방참가 //방참가
const [roomName, setRoomName] = useState('')
const handleCloseModal = () => setShowModal(false); const handleCloseModal = () => setShowModal(false);
const handleShowModal = () => setShowModal(true); const handleShowModal = () => setShowModal(true);
const handleCloseEnter = () => setEnter(false); const handleCloseEnter = () => setEnter(false);
...@@ -90,7 +92,7 @@ function Home() { ...@@ -90,7 +92,7 @@ function Home() {
</Col> </Col>
</Row> </Row>
<RoomMake showModal={showModal} handleCloseModal={handleCloseModal} /> <RoomMake showModal={showModal} handleCloseModal={handleCloseModal} />
<EnterRoom showEnter={showEnter} enterChatRoom={enterChatRoom} handleCloseEnter={handleCloseEnter} /> <EnterRoom showEnter={showEnter} enterChatRoom={enterChatRoom} handleCloseEnter={handleCloseEnter} handleChato={handleChato} setRoomName={setRoomName}/>
</> </>
); );
} }
......
import Room from "../models/Room.js" import Room from "../models/Room.js"
const roomEnter = async (req, res) => { const roomEnter = async (req, res) => {
const roomId = req.body const roomId = req.body.enterCode
// console.log(req)
try { try {
console.log(roomId)
const room = await Room.findOne({ roomId }) const room = await Room.findOne({ roomId })
if (!room) { if (!room) {
return res.status(404).send(`참여코드가 존재하지 않습니다.`) return res.status(404).send(`참여코드가 존재하지 않습니다.`)
} }
// room.member = console.log('roomId존재')
const name = await Room.findOne({ roomId: roomId }).select('roomName')
return res.json(name.roomName)
} catch (error) { } catch (error) {
//알수없는 모든 에러발생시 처리 //알수없는 모든 에러발생시 처리
console.log(error) console.log(error)
res.status(500).send('로그인 에러가 발생하였습니다') res.status(500).send('방 참여 에러')
} }
} }
export default { roomEnter } export default { roomEnter }
\ No newline at end of file
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