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