Commit 17fb0773 authored by 우지원's avatar 우지원
Browse files

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

parents 7d87eeae d7cf7826
...@@ -38,7 +38,6 @@ const RoomSingle = () => { ...@@ -38,7 +38,6 @@ const RoomSingle = () => {
useEffect(() => { useEffect(() => {
getJoinRoom(id); getJoinRoom(id);
}, [id]); }, [id]);
console.log(room)
const { profileimg } = room; const { profileimg } = room;
return ( return (
...@@ -46,7 +45,7 @@ const RoomSingle = () => { ...@@ -46,7 +45,7 @@ const RoomSingle = () => {
{room && {room &&
room.map((el) => ( room.map((el) => (
<div> <div>
{room === INIT_ROOM ? (<div></div>): ( {room[0] === INIT_ROOM ? (<div></div>): (
<Link <Link
to={`/room/${el.roomId}/${channelId}`} to={`/room/${el.roomId}/${channelId}`}
className="text-decoration-none text-dark" className="text-decoration-none text-dark"
......
...@@ -45,22 +45,33 @@ const Login = () => { ...@@ -45,22 +45,33 @@ const Login = () => {
} }
} }
if (success) { if (success) {
alert('로그인 되었습니다'); alert('로그인 되었습니다')
window.location.href = `/user/${id}` window.location.href = `/user/${id}`
} }
const { email, password } = user const { email, password } = user
return ( return (
<div className="container"> <div>
<form onSubmit={handleSubmit}> <div>
<div className="m-3 d-flex justify-content-center"> <form
style={{ backgroundColor: '#FCF4FF' }}
className="flex-column align-items-center justify-content-center p-2"
>
<div className="d-flex justify-content-center">
<Link to="/"> <Link to="/">
<img src="/BORA.png" style={{ width: '160px' }} /> <img src="/BORA.png" style={{ width: '160px' }} />
</Link> </Link>
</div> </div>
</form>
</div>
<div
style={{ backgroundColor: '#262626', width: 'auto', height: '2px' }}
></div>
<div className="container">
<form onSubmit={handleSubmit}>
<div className="row mt-5 d-flex align-items-center"> <div className="row mt-5 d-flex align-items-center">
<h2 style={{ textAlign: 'center' }}>로그인</h2> <h5 style={{ textAlign: 'center' }}>로그인</h5>
{error && <div className="alert alert-danger">{error}</div>} {error && <div className="alert alert-danger">{error}</div>}
<div className="form-group"> <div className="form-group">
<div className="mt-5"> <div className="mt-5">
...@@ -100,6 +111,7 @@ const Login = () => { ...@@ -100,6 +111,7 @@ const Login = () => {
</div> </div>
</form> </form>
</div> </div>
</div>
) )
} }
......
...@@ -17,7 +17,9 @@ const InitRoom = () => { ...@@ -17,7 +17,9 @@ 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})
console.log(room.profileimg)
} catch (error) { } catch (error) {
catchErrors(error, setError); catchErrors(error, setError);
} }
......
import { useState, useEffect } from "react"; 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 Rightimg from "../../images/RightHamburgerImg.png";
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 exitRoom() { async function getRoom(roomId) {
console.log('id, roomid정보', id, roomId)
try { try {
const data = await roomApi.exitRoom({ id, roomId }) const data = await RoomApi.getRoom([roomId]);
console.log(data) setRoom({ ...room, name: data[0].name });
} catch (error) { } catch (error) {
catchErrors(error, setError); catchErrors(error, setError);
} }
}
async function exitRoom() {
console.log("id, roomid정보", id, roomId);
try {
const data = await RoomApi.exitRoom({ id, roomId });
console.log(data);
} catch (error) {
catchErrors(error, setError);
}
} }
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 = [];
for (const prop in Channel) { // Channel의 항목(prop)으로 작업을 실행합니다 for (const prop in Channel) {
// Channel의 항목(prop)으로 작업을 실행합니다
for (const key in Channel[prop]) { for (const key in Channel[prop]) {
console.log(key) console.log(key);
console.log(prop) console.log(prop);
console.log(Channel[prop][key]) console.log(Channel[prop][key]);
channelList.push({ channelList.push({
channelName: key, channelName: key,
joinName: Channel[prop][key] joinName: Channel[prop][key],
}); });
} }
} }
...@@ -52,12 +62,20 @@ const RightHamburger = () => { ...@@ -52,12 +62,20 @@ const RightHamburger = () => {
catchErrors(error, setError); catchErrors(error, setError);
} }
} }
// console.log(channel) // console.log(channel)
useEffect(() => { useEffect(() => {
// console.log('roomId', roomId)
getChannel(roomId); getChannel(roomId);
getRoom(roomId);
}, [roomId]); }, [roomId]);
function roomIdCopy() {
const t = document.querySelector("#roomId").innerText;
console.log(t);
navigator.clipboard.writeText(t);
document.execCommand("copy");
}
return ( return (
<div> <div>
<div> <div>
...@@ -71,7 +89,7 @@ const RightHamburger = () => { ...@@ -71,7 +89,7 @@ const RightHamburger = () => {
aria-label="Toggle navigation" aria-label="Toggle navigation"
style={{ border: "#f4c1f2" }} style={{ border: "#f4c1f2" }}
> >
<img src={Rightimg} width="50px" height="30px" /> <img src="/RightHamburgerImg.png" width="50px" height="30px" />
</button> </button>
</div> </div>
<div <div
...@@ -94,7 +112,7 @@ const RightHamburger = () => { ...@@ -94,7 +112,7 @@ const RightHamburger = () => {
color: "#000000", color: "#000000",
}} }}
> >
이름{/*Room.name*/} {room.name}
</p> </p>
<h6 className="mt-2" id="roomId"> <h6 className="mt-2" id="roomId">
{" "} {" "}
...@@ -107,9 +125,67 @@ const RightHamburger = () => { ...@@ -107,9 +125,67 @@ const RightHamburger = () => {
aria-label="Close" aria-label="Close"
></button> ></button>
</div> </div>
<ChannelSingle channel={channel} />
<div> <div>
<ChannelSingle channel={channel} />
<div className="d-flex flex-row-reverse">
<button
type="button"
className="m-3 rounded"
data-bs-toggle="modal"
data-bs-target="#inviteRoom"
style={{
height: "30px",
fontWeight: "bold",
backgroundColor: "#E0CEE8",
color: "black",
border: "1px #D64D61",
}}
>
초대
</button>
<div
className="modal fade"
id="inviteRoom"
tabIndex="-1"
aria-labelledby="exitRoomLabel"
aria-hidden="true"
>
<div className="modal-dialog">
<div className="modal-content">
<div className="modal-header">
<button
type="button"
className="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div className="modal-body d-flex justify-content-center">
어떤 방식으로 초대하시겠습니까?
</div>
<div className="row mb-3">
<div className="d-flex justify-content-evenly">
<button
type="submit"
className="col-2 p-1 btn btn-primary"
style={{ width: "120px" }}
>
카카오로 초대
</button>
<button
type="submit"
className="col-2 p-1 btn btn-primary"
data-bs-dismiss="modal"
style={{ width: "120px" }}
onClick={roomIdCopy}
>
Id 복사
</button>
</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"
...@@ -164,8 +240,10 @@ const RightHamburger = () => { ...@@ -164,8 +240,10 @@ const RightHamburger = () => {
</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"> <Link
{/* <div onSubmit={exitSubmit}> */} to={`/user/${id}`}
className="col-2 p-1 btn btn-primary"
>
<button <button
type="button" type="button"
onClick={exitRoom} onClick={exitRoom}
...@@ -174,7 +252,6 @@ const RightHamburger = () => { ...@@ -174,7 +252,6 @@ const RightHamburger = () => {
> >
</button> </button>
{/* </div> */}
</Link> </Link>
<button <button
type="submit" type="submit"
...@@ -192,6 +269,7 @@ const RightHamburger = () => { ...@@ -192,6 +269,7 @@ const RightHamburger = () => {
</div> </div>
</div> </div>
</div> </div>
</div>
); );
}; };
......
...@@ -66,17 +66,28 @@ const Signup = () => { ...@@ -66,17 +66,28 @@ const Signup = () => {
const { name, id, password, checkpw, phone } = user const { name, id, password, checkpw, phone } = user
return ( return (
<div className="container"> <div>
{error && <div className="alert alert-danger">{error}</div>} <div>
<form onSubmit={handleSubmit}> <form
<div className="m-3 d-flex justify-content-center"> style={{ backgroundColor: '#FCF4FF' }}
className="flex-column align-items-center justify-content-center p-2"
>
<div className="d-flex justify-content-center">
<Link to="/"> <Link to="/">
<img src="/BORA.png" style={{ width: '160px' }} /> <img src="/BORA.png" style={{ width: '160px' }} />
</Link> </Link>
</div> </div>
</form>
</div>
<div
style={{ backgroundColor: '#262626', width: 'auto', height: '2px' }}
></div>
<div className="container">
<form onSubmit={handleSubmit}>
<div className="row mt-4"> <div className="row mt-4">
<h5 style={{ textAlign: 'center' }}>회원가입</h5> <h5 style={{ textAlign: 'center' }}>회원가입</h5>
</div> </div>
{error && <div className="alert alert-danger">{error}</div>}
<div className="form-group"> <div className="form-group">
<div className="p-2"> <div className="p-2">
<label className="p-1">이름</label> <label className="p-1">이름</label>
...@@ -152,6 +163,7 @@ const Signup = () => { ...@@ -152,6 +163,7 @@ const Signup = () => {
</div> </div>
</form> </form>
</div> </div>
</div>
) )
} }
......
...@@ -19,6 +19,10 @@ const io = new Server(server, { ...@@ -19,6 +19,10 @@ const io = new Server(server, {
app.use(express.json()); app.use(express.json());
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
app.use(cookieParser()); app.use(cookieParser());
app.use('/uploads', express.static('uploads'))
app.use('/roomUploads', express.static('roomUploads'))
app.use("/api", mainRouter); app.use("/api", mainRouter);
......
...@@ -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 }]);
......
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