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