Commit 7fc6b37a authored by Soo Hyun Kim's avatar Soo Hyun Kim
Browse files

enterChatRoom수정

parent 00dade89
...@@ -18,7 +18,7 @@ function EnterRoom(props) { ...@@ -18,7 +18,7 @@ function EnterRoom(props) {
event.preventDefault() event.preventDefault()
try { try {
setError('') setError('')
// await axios.post('/room/enterRoom', enterCode) await axios.post('/room/enterRoom', enterCode)
props.enterChatRoom(enterCode) props.enterChatRoom(enterCode)
setEnterCode('') setEnterCode('')
} catch (error){ } catch (error){
......
...@@ -70,10 +70,10 @@ function Home() { ...@@ -70,10 +70,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} setRoomName={setRoomName}/> <ClosedList enterChatRoom={enterChatRoom} setRoomName={setRoomName}/>
</Tab> </Tab>
<Tab eventKey="open" title="공개방" > <Tab eventKey="open" title="공개방" >
<OpenList enterChatroom={enterChatRoom} setRoomName={setRoomName}/> <OpenList enterChatRoom={enterChatRoom} setRoomName={setRoomName}/>
</Tab> </Tab>
</Tabs> </Tabs>
</Col> </Col>
......
import Room from "../models/Room.js"
const roomEnter = async (req, res) => {
const roomId = req.body
try {
const room = await Room.findOne({ roomId })
if (!room) {
return res.status(404).send(`참여코드가 존재하지 않습니다.`)
}
// room.member =
} catch (error) {
//알수없는 모든 에러발생시 처리
console.log(error)
res.status(500).send('로그인 에러가 발생하였습니다')
}
}
export default { roomEnter }
\ No newline at end of file
import express from 'express'
import roomEnterCtrl from '../controllers/roomEnter.controller.js'
const router = express.Router()
router.route('/room/enterRoom')
.post(roomEnterCtrl.roomEnter)
export default router
\ No newline at end of file
...@@ -3,6 +3,7 @@ import connectDb from './utils/connectDb.js' ...@@ -3,6 +3,7 @@ import connectDb from './utils/connectDb.js'
import userRouter from './routes/user.routes.js' import userRouter from './routes/user.routes.js'
import authRouter from './routes/auth.routes.js' import authRouter from './routes/auth.routes.js'
import roomRouter from './routes/room.routers.js' import roomRouter from './routes/room.routers.js'
import roomEnterRouter from './routes/roomEnter.routers.js'
import bodyParser from "body-parser"; import bodyParser from "body-parser";
import http from "http"; import http from "http";
import { Server } from 'socket.io'; import { Server } from 'socket.io';
...@@ -46,6 +47,7 @@ app.use(cors()); ...@@ -46,6 +47,7 @@ app.use(cors());
app.use(userRouter) app.use(userRouter)
app.use(authRouter) app.use(authRouter)
app.use(roomRouter) app.use(roomRouter)
app.use(roomEnterRouter)
server.listen(3030, () => { server.listen(3030, () => {
console.log('Listening on port 3030') console.log('Listening on port 3030')
......
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