Commit 8ae18a67 authored by Kim, Chaerin's avatar Kim, Chaerin
Browse files

Merge remote-tracking branch 'origin/woojiweon2'

parents 7df7d5cd 3ed2ebe0
...@@ -30,7 +30,7 @@ const ChannelSettingChange = (props) => { ...@@ -30,7 +30,7 @@ const ChannelSettingChange = (props) => {
} }
if (count == 1) { if (count == 1) {
window.alert("이미 존재하는 채널 입니다. 다른 이름을 입력해 주십시오."); alert("이미 존재하는 채널 입니다. 다른 이름을 입력해 주십시오.");
} else { } else {
Channel.number = props.channel.length; Channel.number = props.channel.length;
alert("채널이 성공적으로 생성되었습니다."); alert("채널이 성공적으로 생성되었습니다.");
...@@ -54,7 +54,7 @@ const ChannelSettingChange = (props) => { ...@@ -54,7 +54,7 @@ const ChannelSettingChange = (props) => {
const data = await roomApi.channelDelete(Channel); const data = await roomApi.channelDelete(Channel);
} }
else { else {
window.alert( alert(
"입력한 채널명과 일치하는 채널이 존재하지 않습니다. 다시 확인해 주십시오." "입력한 채널명과 일치하는 채널이 존재하지 않습니다. 다시 확인해 주십시오."
); );
} }
......
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { Link, useParams } from "react-router-dom"; import { Link, useParams } from "react-router-dom";
import ChannelSingle from "./ChannelSingle"; import ChannelSingle from "./ChannelSingle";
import RoomApi from "../../apis/room.api";
import catchErrors from "../../context/catchError"; import catchErrors from "../../context/catchError";
import KakaoShareButton from "../KakaoShareButton"; import KakaoShareButton from "../KakaoShareButton";
import RoomSettingChange from "./RoomSettingChange"; import RoomSettingChange from "./RoomSettingChange";
...@@ -28,7 +27,7 @@ const RightHamburger = () => { ...@@ -28,7 +27,7 @@ const RightHamburger = () => {
async function getRoom(roomId) { async function getRoom(roomId) {
try { try {
const data = await RoomApi.getRoom([roomId]); const data = await roomApi.getRoom([roomId]);
const roomdata = []; const roomdata = [];
roomdata.push({ roomdata.push({
name: data[0].name, name: data[0].name,
...@@ -42,9 +41,9 @@ const RightHamburger = () => { ...@@ -42,9 +41,9 @@ const RightHamburger = () => {
async function exitRoom() { async function exitRoom() {
try { try {
const data = await RoomApi.exitRoom({ id, roomId }); const data = await roomApi.exitRoom({ id, roomId });
if (data.owner === Number(id)){ if (data.owner === Number(id)){
const room = await RoomApi.removeRoom({roomId : roomId}) const room = await roomApi.removeRoom({roomId : roomId})
console.log(room) console.log(room)
} }
} catch (error) { } catch (error) {
...@@ -54,7 +53,7 @@ const RightHamburger = () => { ...@@ -54,7 +53,7 @@ const RightHamburger = () => {
async function getChannel(roomId) { async function getChannel(roomId) {
try { try {
const data = await RoomApi.getRoom([roomId]); const data = await roomApi.getRoom([roomId]);
const Channel = data[0].channel; const Channel = data[0].channel;
const channelList = []; const channelList = [];
for (const prop in Channel) { for (const prop in Channel) {
...@@ -104,6 +103,34 @@ const RightHamburger = () => { ...@@ -104,6 +103,34 @@ const RightHamburger = () => {
} }
} }
async function exitChannel() {
try {
const data = await userApi.getUser(id);
const A = doubleJoinCheck(data.name)
if (A) {
await roomApi.doubleJoin({ roomId: roomId, index1: A.index1, index2: A.index2, joinChName: A.joinChName })
}
} catch (error) {
catchErrors(error, setError);
}
}
function doubleJoinCheck(e) {
for (const index in channel) {
for (const el in channel[index].joinUser) {
if (channel[index].joinUser[el] === e) {
const doublejoinCh = channel[index].channelName
const A = {
index1: index,
index2: el,
joinChName: doublejoinCh,
}
return A
}
}
}
}
// console.log(channel) // console.log(channel)
useEffect(() => { useEffect(() => {
......
...@@ -49,10 +49,10 @@ const InvitePage = () => { ...@@ -49,10 +49,10 @@ const InvitePage = () => {
if (check === true) { if (check === true) {
joinroom(usercheck, roomId); joinroom(usercheck, roomId);
window.alert("방 참여가 완료되었습니다."); alert("방 참여가 완료되었습니다.");
window.location.href=`/user/${usercheck}` window.location.href=`/user/${usercheck}`
} else { } else {
window.alert("로그인이 필요합니다."); alert("로그인이 필요합니다.");
window.location.href = `/`; window.location.href = `/`;
} }
} }
...@@ -63,10 +63,10 @@ const InvitePage = () => { ...@@ -63,10 +63,10 @@ const InvitePage = () => {
else check = true; else check = true;
if (check === true) { if (check === true) {
window.alert("유저 페이지로 이동합니다."); alert("유저 페이지로 이동합니다.");
window.location.href = `/user/${usercheck}`; window.location.href = `/user/${usercheck}`;
} else { } else {
window.alert("로그인이 필요합니다."); alert("로그인이 필요합니다.");
window.location.href = `/`; window.location.href = `/`;
} }
} }
......
...@@ -124,7 +124,9 @@ const exitRoom = async (req, res) => { ...@@ -124,7 +124,9 @@ const exitRoom = async (req, res) => {
); );
const user = await User.findOne({ where: { id: id } }); const user = await User.findOne({ where: { id: id } });
const index2 = user.roomNumber.indexOf(id); console.log('user',user, user.roomNumber)
const index2 = user.roomNumber.indexOf(roomId);
console.log('제발제발',index2, roomId, user.roomNumber)
user.roomNumber.splice(index2, 1); user.roomNumber.splice(index2, 1);
const newUser = await User.update( const newUser = await User.update(
{ roomNumber: user.roomNumber }, { roomNumber: user.roomNumber },
...@@ -141,6 +143,7 @@ const changename = async (req, res) => { ...@@ -141,6 +143,7 @@ const changename = async (req, res) => {
try { try {
await Room.update({ name: name }, { where: { id: id } }); await Room.update({ name: name }, { where: { id: id } });
const room1 = await Room.findOne({ where: { id: id } }); const room1 = await Room.findOne({ where: { id: id } });
return res.body.json(true)
} catch (error) { } catch (error) {
res.status(500).send("에러"); res.status(500).send("에러");
} }
...@@ -172,7 +175,7 @@ const doubleJoin = async (req, res) => { ...@@ -172,7 +175,7 @@ const doubleJoin = async (req, res) => {
const removeRoom = async (req, res) => { const removeRoom = async (req, res) => {
const { roomId } = req.params; const { roomId } = req.params;
console.log('서버연결성공!!!!',roomId) console.log('서버연결성공!!!!', roomId)
try { try {
const room = await Room.destroy({ where: { id: roomId } }); const room = await Room.destroy({ where: { id: roomId } });
} catch (error) { } catch (error) {
......
...@@ -20,7 +20,7 @@ sequelize ...@@ -20,7 +20,7 @@ sequelize
email: "admin", email: "admin",
password: "admin!", password: "admin!",
gender: 0, gender: 0,
roomNumber : ["1234567abc","abc7654321"], roomNumber : [],
}); });
// await Room.create({ // await Room.create({
......
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