Commit 35b35878 authored by 우지원's avatar 우지원
Browse files

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

parents b1f271f9 db5383e3
import axios from 'axios'; import React, { useState, useEffect } from 'react'
import React, { useState } from 'react'
import { ListGroup, Row, Col } from 'react-bootstrap'; import { ListGroup, Row, Col } from 'react-bootstrap';
import axios from 'axios'
function ClosedList(props) { function ClosedList(props) {
const [list, setList] = useState([]); const [list, setList] = useState([]);
// async function getClosedList() { //email로 db에서 찾아오기 ㅇㅇㅇㅇㅇ useEffect(() => {
// const member = sessionStorage.getItem('name') getClosedList();
// const response = await axios.put(`/room/${member}`, { 'member': member }) }, []);
// setList(response.data)
// }
// console.log(list)
async function getClosedList() {
let res = await axios.get('/room/closedlist')
console.log('가져온거', res)
setList(res.data)
}
function enterChatroomCH(e) { function enterChatroomCH(e) {
console.log(e.target.name) console.log(e.target.name)
...@@ -29,8 +30,8 @@ function ClosedList(props) { ...@@ -29,8 +30,8 @@ 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.room}> <ListGroup.Item action onClick={enterChatroomCH} name={item.roomName}>
{item.room} {item.roomName}
</ListGroup.Item> </ListGroup.Item>
</ListGroup> </ListGroup>
)} )}
......
...@@ -19,7 +19,7 @@ const makeRoom = async (req, res) => { ...@@ -19,7 +19,7 @@ const makeRoom = async (req, res) => {
try { try {
if (!isLength(roomName, { min: 3, max: 20 })) { if (!isLength(roomName, { min: 3, max: 20 })) {
return res.status(422).send('채팅방의 이름은 3-20자여야 합니다.') return res.status(422).send('채팅방의 이름은 3-20자여야 합니다.')
} else if (interest=='Choose...' || interest==''){ } else if (interest == 'Choose...' || interest == '') {
return res.status(422).send('분야를 반드시 선택하여야 합니다.') return res.status(422).send('분야를 반드시 선택하여야 합니다.')
} }
const newRoom = await new Room({ const newRoom = await new Room({
...@@ -37,14 +37,14 @@ const makeRoom = async (req, res) => { ...@@ -37,14 +37,14 @@ const makeRoom = async (req, res) => {
} }
} }
// const checkmember = async (req, res) => { const getClosedList = async (req, res) => {
// try { try {
// let user = await Room.findOne(req.body).select('roomName').exec() let list = await Room.find({ isOpen: false })
// console.log(user) console.log('list가져오기', list)
// return res.json(user) return res.json(list)
// } catch (error) { } catch (error) {
// alert('올바르지 못한 접근입니다.') res.status(500).send('리스트 불러오기를 실패하였습니다!')
// } }
// } }
export default { makeRoom } export default { makeRoom, getClosedList }
\ No newline at end of file
...@@ -2,8 +2,7 @@ import User from "../models/User.js" ...@@ -2,8 +2,7 @@ import User from "../models/User.js"
import isLength from 'validator/lib/isLength.js' import isLength from 'validator/lib/isLength.js'
import isEmail from 'validator/lib/isEmail.js' import isEmail from 'validator/lib/isEmail.js'
import bcrypt from "bcryptjs"; import bcrypt from "bcryptjs";
import jwt from 'jsonwebtoken'
import config from "../config.js"
const signup = async (req, res) => { const signup = async (req, res) => {
...@@ -62,21 +61,12 @@ const changenick = async (req, res) => { ...@@ -62,21 +61,12 @@ const changenick = async (req, res) => {
} }
} }
const loginNavbar = async (req, res) => { // const saveroom = async (req, res) => {
try { // const roomId = room.roomId
let user = await User.findOne(req.body).select('username').exec() // if (!isLength(roomId, { min: 11 })) {
return res.json(user) // return res.status(422).send('방아이디 저장에 오류가 발생하였습니다.')
} catch (error) { // }
alert('올바르지 못한 접근입니다.') // }
}
}
const saveroom = async (req, res) => {
const roomId = room.roomId
if (!isLength(roomId, { min: 11 })) {
return res.status(422).send('방아이디 저장에 오류가 발생하였습니다.')
}
}
export default { signup, logineduser, changenick, loginNavbar, saveroom } export default { signup, logineduser, changenick }
// {} : 객체로 return 함 // {} : 객체로 return함
\ No newline at end of file
...@@ -6,7 +6,6 @@ const router = express.Router() ...@@ -6,7 +6,6 @@ const router = express.Router()
router.route('/room/makeRoom') router.route('/room/makeRoom')
.post(roomCtrl.makeRoom) .post(roomCtrl.makeRoom)
// router.route(`/room/:member`) router.route('/room/closedlist')
// .put(userCtrl.checkmember) .get(roomCtrl.getClosedList)
export default router export default router
\ 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