Commit 3a6135b9 authored by seoyeon's avatar seoyeon
Browse files

Merge remote-tracking branch 'origin/jaeyeon' into seoyeon3

parents c87ccbd3 84e6503b
......@@ -17,7 +17,8 @@ const InitRoom = () => {
async function getRoom(roomId) {
try {
const data = await roomApi.getRoom([roomId]);
setRoom(data[0]);
console.log(data)
setRoom({...room, id:data[0].id, name:data[0].name, profileimg: data[0].profileimg})
} catch (error) {
catchErrors(error, setError);
}
......
......@@ -2,23 +2,36 @@ import { useState, useEffect } from "react";
import { Link, useParams } from "react-router-dom";
import ChannelSingle from "./ChannelSingle";
import RoomApi from "../../apis/room.api";
import roomApi from "../../apis/room.api";
import catchErrors from "../../context/catchError";
const INIT_ROOM = {
name: "",
};
const INIT_CHANNEL = {
channelName: "",
joinName: [],
};
const RightHamburger = () => {
const [channel, setChannel] = useState([INIT_CHANNEL]);
const [room, setRoom] = useState([INIT_ROOM])
const { roomId } = useParams();
const [error, setError] = useState("");
const id = localStorage.getItem('user');
async function getRoom(roomId) {
try {
const data = await RoomApi.getRoom([roomId]);
setRoom({...room, name:data[0].name});
} catch (error) {
catchErrors(error, setError);
}
}
async function exitRoom() {
console.log('id, roomid정보', id, roomId)
try {
const data = await roomApi.exitRoom({ id, roomId })
const data = await RoomApi.exitRoom({ id, roomId })
console.log(data)
} catch (error) {
catchErrors(error, setError);
......@@ -28,10 +41,9 @@ const RightHamburger = () => {
}
async function getChannel(roomId) {
// console.log('roomId', roomId)
const ID = roomId
try {
const data = await roomApi.getRoom([ID]);
const data = await RoomApi.getRoom([ID]);
const Channel = data[0].channel
console.log('방데이터:', Channel)
const channelList = [];
......@@ -56,7 +68,7 @@ const RightHamburger = () => {
useEffect(() => {
getChannel(roomId);
getroom(roomId)
getRoom(roomId)
}, [roomId]);
function roomIdCopy() {
......@@ -115,42 +127,13 @@ const RightHamburger = () => {
></button>
</div>
<div>
<div>
<button
className="navbar-toggler"
type="button"
data-bs-toggle="offcanvas"
data-bs-target="#right-hamburger"
aria-controls="right-hamburger"
aria-expanded="false"
aria-label="Toggle navigation"
style={{ border: "#f4c1f2" }}
>
<img src="/RightHamburgerImg.png" width="50px" height="30px" />
</button>
</div>
<ChannelSingle channel={channel} />
<div>
<div className="d-flex flex-row-reverse">
<button
type="button"
className="m-3 rounded text-white"
data-bs-toggle="modal"
data-bs-target="#exitRoom"
style={{
height: "30px",
fontWeight: "bold",
backgroundColor: "#d86da6",
color: "black",
border: "1px #d86da6",
}}
>
퇴장
</button>
{/* {admin ? (
<button
type="button"
className="m-3 rounded"
data-bs-toggle="modal"
data-bs-target="#inviteRoom"
style={{
height: "30px",
fontWeight: "bold",
......@@ -159,13 +142,11 @@ const RightHamburger = () => {
border: "1px #D64D61",
}}
>
설정
초대
</button>
) : null} */}
<div
className="modal fade"
id="exitRoom"
id="inviteRoom"
tabIndex="-1"
aria-labelledby="exitRoomLabel"
aria-hidden="true"
......@@ -181,26 +162,25 @@ const RightHamburger = () => {
></button>
</div>
<div className="modal-body d-flex justify-content-center">
이방에서 퇴장하시겠습니까?
어떤 방식으로 초대하시겠습니까?
</div>
<div className="row mb-3">
<div className="d-flex justify-content-evenly">
<Link to={`/user/${id}`} className="col-2 p-1 btn btn-primary">
<button
type="button"
onClick={exitRoom}
className="btn btn-primary"
data-bs-dismiss="modal"
type="submit"
className="col-2 p-1 btn btn-primary"
style={{ width: "120px" }}
>
카카오로 초대
</button>
</Link>
<button
type="submit"
className="btn btn-primary"
className="col-2 p-1 btn btn-primary"
data-bs-dismiss="modal"
style={{ width: "120px" }}
onClick={roomIdCopy}
>
아니요
Id 복사
</button>
</div>
</div>
......@@ -209,12 +189,27 @@ const RightHamburger = () => {
</div>
</div>
</div>
<div>
<div className="d-flex flex-row-reverse">
<button
type="button"
className="m-3 rounded"
className="m-3 rounded text-white"
data-bs-toggle="modal"
data-bs-target="#inviteRoom"
data-bs-target="#exitRoom"
style={{
height: "30px",
fontWeight: "bold",
backgroundColor: "#d86da6",
color: "black",
border: "1px #d86da6",
}}
>
퇴장
</button>
{/* {admin ? (
<button
type="button"
className="m-3 rounded"
style={{
height: "30px",
fontWeight: "bold",
......@@ -223,11 +218,13 @@ const RightHamburger = () => {
border: "1px #D64D61",
}}
>
초대
설정
</button>
) : null} */}
<div
className="modal fade"
id="inviteRoom"
id="exitRoom"
tabIndex="-1"
aria-labelledby="exitRoomLabel"
aria-hidden="true"
......@@ -243,25 +240,26 @@ const RightHamburger = () => {
></button>
</div>
<div className="modal-body d-flex justify-content-center">
어떤 방식으로 초대하시겠습니까?
이방에서 퇴장하시겠습니까?
</div>
<div className="row mb-3">
<div className="d-flex justify-content-evenly">
<Link to={`/user/${id}`} className="col-2 p-1 btn btn-primary">
<button
type="submit"
className="col-2 p-1 btn btn-primary"
style={{ width: "120px" }}
type="button"
onClick={exitRoom}
className="btn btn-primary"
data-bs-dismiss="modal"
>
카카오로 초대
</button>
</Link>
<button
type="submit"
className="col-2 p-1 btn btn-primary"
className="btn btn-primary"
data-bs-dismiss="modal"
style={{ width: "120px" }}
onClick={roomIdCopy}
>
Id 복사
아니요
</button>
</div>
</div>
......
......@@ -2,7 +2,7 @@ import { Room, User } from "../models/index.js";
import { customAlphabet } from "nanoid";
import isLength from "validator/lib/isLength.js";
import RoomModel from "../models/room.model.js";
import multer from "multer";
const nanoid = customAlphabet("1234567890abcdef", 10);
const joinRoom = async (req, res) => {
......@@ -43,7 +43,6 @@ const joinRoom = async (req, res) => {
}
};
const multer = require("multer");
const upLoadRoomImg = multer({ dest: "roomUploads/" });
const roomImgUpload = upLoadRoomImg.fields([{ name: "profileimg", maxCount: 1 }]);
......
......@@ -16,7 +16,7 @@ const RoomModel = (sequelize) => {
type: DataTypes.INTEGER,
},
member: {
type: DataTypes.ARRAY(DataTypes.STRING),
type: DataTypes.ARRAY(DataTypes.INTEGER),
//type: DataTypes.STRING,
},
profileimg: {
......
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