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

에러

parent b9c8ba1f
......@@ -24,9 +24,9 @@ function ClosedList(props) {
console.log(e.target.name)
console.log(e.target)
const roomName = e.target.name
props.enterChatRoom(roomName) // 각각의 room으로 들어가도록 설정해야 함
props.enterChatroom(roomName) // 각각의 room으로 들어가도록 설정해야 함
props.setRoomName(roomName)
// props.clearChat()
}
//user.hasOwnProperty('이름');
......@@ -35,7 +35,7 @@ function ClosedList(props) {
<div>
{list.map((item, index) =>
<ListGroup key={index}>
<ListGroup.Item action onClick={enterChatroomCH} name={item.roomName}>
<ListGroup.Item action onClick={enterChatRoomCH} name={item.roomName}>
{item.roomName}
</ListGroup.Item>
</ListGroup>
......
......@@ -18,7 +18,7 @@ function OpenList(props) {
function enterChatRoomCH(e) {
const roomName = e.target.name
props.enterChatRoom(roomName) // 각각의 room으로 들어가도록 설정해야 함
props.enterChatroom(roomName) // 각각의 room으로 들어가도록 설정해야 함
props.setRoomName(roomName)
// props.clearChat()
}
......@@ -27,7 +27,7 @@ function OpenList(props) {
<div>
{openlist.map((item, index) =>
<ListGroup key={index}>
<ListGroup.Item action onClick={enterChatroomCH} name={item.roomName}>
<ListGroup.Item action onClick={enterChatRoomCH} name={item.roomName}>
{item.roomName}
</ListGroup.Item>
</ListGroup>
......
......@@ -19,9 +19,10 @@ function RoomMake(props) {
isRoom ? setDisabled(false) : setDisabled(true)
}, [room])
const member = sessionStorage.getItem('userId');
function handleChange(event) {
const { name, value } = event.target
setRoom({ ...room, [name]: value })
setRoom({ ...room, [name]: value , member})
console.log(room)
}
......@@ -29,12 +30,12 @@ function RoomMake(props) {
event.preventDefault()
try {
setError('')
await axios.post('/room/makeRoom', room)
let res = await axios.post('/room/makeRoom', room)
const Id = res.data.roomId
alert(`방암호는 ${Id}입니다`)
props.handleCloseModal()
setRoom(INIT_ROOM)
} catch (error){
} catch (error){
catchErrors(error, setError)
}
}
......
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { Row, Col, Modal, Button, Form, Alert } from 'react-bootstrap';
import { Row, Col, Button } from 'react-bootstrap';
import Tabs from 'react-bootstrap/Tabs';
import Tab from 'react-bootstrap/Tab';
import ClosedList from '../Components/ClosedList';
import OpenList from '../Components/OpenList';
import Menu from '../Components/Menu';
import catchErrors from '../utils/catchErrors';
import { io } from "socket.io-client"; //모듈 가져오기
import Chat from "../Components/Chat";
import RoomMake from "../Components/RoomMake"
......@@ -35,17 +33,7 @@ function Home() {
const handleChato = () => setChat(true);
const handleChatc = () => setChat(false);
const member = sessionStorage.getItem('userId');
useEffect(() => {
const isRoom = Object.values(room).every(el => Boolean(el))
isRoom ? setDisabled(false) : setDisabled(true)
}, [room])
function handleChange(event) {
const { name, value } = event.target
setRoom({ ...room, [name]: value, member })
}
//SOCKET 관련 시작
function enterChatroom(rName) { //방 입장하기
......@@ -63,8 +51,8 @@ function Home() {
msg: singleChat
})
}, [singleChat])
useEffect(() => {
socket.on("sendedMSG", (msg) => {
console.log(msg)
......@@ -87,7 +75,7 @@ function Home() {
</Tabs>
</Col>
<Col style={{ padding: "0" }}>
{chat ? <Chat handleChatc={handleChatc} sendMsg={sendMsg} singleChat={singleChat} recievedMsg={recievedMsg} setSingleChat={setSingleChat} roomName={roomName}/> : null}
{chat ? <Chat handleChatc={handleChatc} sendMsg={sendMsg} singleChat={singleChat} recievedMsg={recievedMsg} setSingleChat={setSingleChat} roomName={roomName} /> : null}
<div style={{ position: "fixed", bottom: "20px", right: "30px" }}>
<Button variant="primary" onClick={handleShowModal} size="lg" block>
......@@ -101,7 +89,7 @@ function Home() {
</Col>
</Row>
<RoomMake showModal={showModal} handleCloseModal={handleCloseModal} />
<EnterRoom showEnter={showEnter} enterChatRoom={enterChatRoom} handleCloseEnter={handleCloseEnter}/>
<EnterRoom showEnter={showEnter} enterChatRoom={enterChatroom} handleCloseEnter={handleCloseEnter} />
</>
);
}
......
......@@ -7,7 +7,7 @@ const nanoid = customAlphabet('1234567890abcdef', 10)
const makeRoom = async (req, res) => {
console.log(req.body)
const { roomName, interest, isOpen, member } = req.body;
console.log(roomName, interest, isOpen, member)
console.log('콘솔확인',roomName, interest, isOpen, member)
const roomId = nanoid()
const room = await Room.findOne({ roomId })
......
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