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

에러

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