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