Commit f23faf1e authored by 권병윤's avatar 권병윤
Browse files

Merge remote-tracking branch 'origin/seoyeon2' into byoungyun

parents 461f7743 945e73ff
...@@ -14,6 +14,7 @@ app.use(express.json()); ...@@ -14,6 +14,7 @@ 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('/uploads', express.static('uploads'))
app.use('/roomUploads', express.static('roomUploads'))
app.use("/api", mainRouter); app.use("/api", mainRouter);
let receiverPCs = {}; let receiverPCs = {};
......
REACT_APP_KAKAO_KEY=783f1ca14e1f14bc6442eedcd37c76a1
REACT_FETCH_URL=http://localhost:3000
\ No newline at end of file
...@@ -6,6 +6,8 @@ import ProfilePage from "./pages/ProfilePage"; ...@@ -6,6 +6,8 @@ import ProfilePage from "./pages/ProfilePage";
import RoomPage from "./pages/RoomPage"; import RoomPage from "./pages/RoomPage";
import InfoUpdatePage from "./pages/InfoUpdatePage"; import InfoUpdatePage from "./pages/InfoUpdatePage";
import InvitePage from "./pages/InvitePage"; import InvitePage from "./pages/InvitePage";
import SingupPage from "./components/SignUp";
import LoginPage from "./components/Login"
function App() { function App() {
return ( return (
...@@ -13,10 +15,24 @@ function App() { ...@@ -13,10 +15,24 @@ function App() {
{/* <AuthProvider> */} {/* <AuthProvider> */}
<Switch> <Switch>
<Route exact path="/" component={HomeGuestPage} /> <Route exact path="/" component={HomeGuestPage} />
<Route exact path="/user" component={HomeUserPage} /> <Route exact path="/user/:id" component={HomeUserPage} />
<Route exact path="/signup" component={SingupPage} />
<Route exact path="/login" component={LoginPage} />
<Route path="/profile/:id/update" component={InfoUpdatePage} /> <Route path="/profile/:id/update" component={InfoUpdatePage} />
<Route path="/profile/:id" component={ProfilePage} /> <Route path="/profile/:id" component={ProfilePage} />
<Route path="/room/:roomId/:channelId" component={RoomPage} /> <Route path="/room/:roomId/:channelId" component={RoomPage}>
{/* <Switch>
<Route path={"/room/:roomId/meeting"}>
<></>
</Route>
<Route path={"/room/:roomId/normal"}>
<></>
</Route>
<Route path={"/room/:roomId/notice"}>
<></>
</Route>
</Switch> */}
</Route>
<Route path="/room/Invite" component={InvitePage} /> <Route path="/room/Invite" component={InvitePage} />
</Switch> </Switch>
{/* </AuthProvider> */} {/* </AuthProvider> */}
......
import axios from "axios"; import axios from "axios";
const getRoom = async (id) => { const getRoom = async (payload) => {
const { data } = await axios.get(`/api/room/getRoom/${id}`); const { data } = await axios.post(`/api/room/getRoom`,payload);
return data; return data;
}; };
const create = async (payload) => { const create = async (formData) => {
const { data } = await axios.post("/api/room/create", payload); const { data } = await axios.post("/api/room/create", formData);
return data; return data;
}; };
......
import axios from "axios"; import axios from "axios";
const getUser = async (id) => { const getUser = async (id) => {
// console.log('id222:',id.userID)
const { data } = await axios.get(`/api/getUser/${id}`); const { data } = await axios.get(`/api/getUser/${id}`);
return data; return data;
}; };
......
...@@ -2,6 +2,7 @@ import { Link } from 'react-router-dom' ...@@ -2,6 +2,7 @@ import { Link } from 'react-router-dom'
import { handleLogout } from '../context/auth' import { handleLogout } from '../context/auth'
const Header = () => { const Header = () => {
const id = localStorage.getItem('user');
return ( return (
<div> <div>
<form <form
...@@ -10,7 +11,7 @@ const Header = () => { ...@@ -10,7 +11,7 @@ const Header = () => {
> >
<div className="d-flex justify-content-end"> <div className="d-flex justify-content-end">
<div> <div>
<Link to="/user"> <Link to={`/user/${id}`}>
<img src="/BORA.png" style={{ width: '160px' }} /> <img src="/BORA.png" style={{ width: '160px' }} />
</Link> </Link>
</div> </div>
...@@ -51,14 +52,14 @@ const Header = () => { ...@@ -51,14 +52,14 @@ const Header = () => {
<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="/" className="col-2 p-1 btn btn-primary"> <Link to="/" className="col-2 p-1 btn btn-primary">
<button <button
type="submit" type="submit"
className="btn btn-primary" className="btn btn-primary"
onClick={() => handleLogout()} onClick={() => handleLogout()}
data-bs-dismiss="modal" data-bs-dismiss="modal"
> >
</button> </button>
</Link> </Link>
<button <button
type="submit" type="submit"
......
...@@ -5,14 +5,13 @@ const AddRoom = () => { ...@@ -5,14 +5,13 @@ const AddRoom = () => {
return ( return (
<div> <div>
<div className="mx-4 my-3 d-flex justify-content-between"> <div className="mx-4 my-3 d-flex justify-content-between">
<div className="fs-4"> <div className="fs-4">참여중인 방목록</div>
참여중인 방목록
</div>
<button <button
type="button" type="button"
className="py-1 px-2" className="py-1 px-2"
data-bs-toggle="modal" data-bs-toggle="modal"
data-bs-target="#myModal" data-bs-target="#myModal"
// data-bs-dismiss="modal"
style={{ style={{
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
...@@ -54,7 +53,8 @@ const AddRoom = () => { ...@@ -54,7 +53,8 @@ const AddRoom = () => {
backgroundColor: "#E0CEE8", backgroundColor: "#E0CEE8",
borderColor: "#E0CEE8", borderColor: "#E0CEE8",
}} }}
>방참여하기 >
방참여하기
</button> </button>
<div <div
className="modal fade" className="modal fade"
...@@ -83,7 +83,8 @@ const AddRoom = () => { ...@@ -83,7 +83,8 @@ const AddRoom = () => {
backgroundColor: "#f5cfe3", backgroundColor: "#f5cfe3",
borderColor: "#f5cfe3", borderColor: "#f5cfe3",
}} }}
>방생성하기 >
방생성하기
</button> </button>
<div <div
className="modal fade" className="modal fade"
......
...@@ -3,7 +3,7 @@ import { Redirect } from "react-router-dom"; ...@@ -3,7 +3,7 @@ import { Redirect } from "react-router-dom";
import roomApi from "../../apis/room.api"; import roomApi from "../../apis/room.api";
import catchErrors from "../../context/catchError"; import catchErrors from "../../context/catchError";
const userId = localStorage.getItem('user'); const id = localStorage.getItem('user');
const INIT_ROOM = { const INIT_ROOM = {
name: '', name: '',
owner: userId, owner: userId,
...@@ -23,17 +23,26 @@ const CreateRoom = () => { ...@@ -23,17 +23,26 @@ const CreateRoom = () => {
}, [room]); }, [room]);
function handleChange(event) { function handleChange(event) {
// console.log(room) const { name, value, files } = event.target;
const { name, value } = event.target if (files) {
setRoom({ ...room, [name]: value }) setRoom({ ...room, [name]: files[0] })
} else {
setRoom({ ...room, [name]: value })
}
console.log(room)
} }
async function handleSubmit(e) { async function handleSubmit(e) {
e.preventDefault() e.preventDefault()
// console.log('룸룸', room) let formData = new FormData();
console.log('profileimg:', room.profileimg)
console.log('name:', room.name)
formData.append("name", room.name);
formData.append("userId", id);
formData.append("profileimg", room.profileimg);
try { try {
const res = await roomApi.create(room) const res = await roomApi.create(formData)
// console.log(res) console.log(res)
const Id = res.id const Id = res.id
console.log(Id) console.log(Id)
alert(`방참여코드는 ${Id}입니다`) alert(`방참여코드는 ${Id}입니다`)
...@@ -46,9 +55,10 @@ const CreateRoom = () => { ...@@ -46,9 +55,10 @@ const CreateRoom = () => {
} }
if (success) { if (success) {
console.log('success', success) // console.log('success', success)
alert('룸생성이 완료되었습니다!') alert('룸생성이 완료되었습니다!')
return <Redirect to='/user' /> window.location.href=`/user/${id}`
// return <Redirect to={`/user/${id}`} />
} }
const { name, owner, member, profileimg } = room; const { name, owner, member, profileimg } = room;
...@@ -57,7 +67,9 @@ const CreateRoom = () => { ...@@ -57,7 +67,9 @@ const CreateRoom = () => {
<div className="modal-content" > <div className="modal-content" >
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div className="modal-header"> <div className="modal-header">
<div className="modal-title" id="makeModal">방생성하기</div> <div className="modal-title" id="makeModal">
방생성하기
</div>
<button <button
type="button" type="button"
className="btn-close" className="btn-close"
...@@ -66,6 +78,7 @@ const CreateRoom = () => { ...@@ -66,6 +78,7 @@ const CreateRoom = () => {
></button> ></button>
</div> </div>
<div className="modal-body"> <div className="modal-body">
{error && <div className="alert alert-danger">{error}</div>}
<h6>방프로필사진</h6> <h6>방프로필사진</h6>
<div className="mb-4"> <div className="mb-4">
<input <input
...@@ -74,7 +87,7 @@ const CreateRoom = () => { ...@@ -74,7 +87,7 @@ const CreateRoom = () => {
onChange={handleChange} onChange={handleChange}
accept="image/*" accept="image/*"
name="profileimg" name="profileimg"
value={room.profileimg} /> />
</div> </div>
<h6>방이름</h6> <h6>방이름</h6>
<div className="input-group"> <div className="input-group">
...@@ -86,7 +99,6 @@ const CreateRoom = () => { ...@@ -86,7 +99,6 @@ const CreateRoom = () => {
aria-describedby="basic-addon1" aria-describedby="basic-addon1"
onChange={handleChange} onChange={handleChange}
name="name" name="name"
value={room.name}
/> />
</div> </div>
<div className="modal-footer"> <div className="modal-footer">
......
...@@ -6,28 +6,27 @@ import catchErrors from "../../context/catchError"; ...@@ -6,28 +6,27 @@ import catchErrors from "../../context/catchError";
const userprofile = localStorage.getItem("user"); const userprofile = localStorage.getItem("user");
const INIT_USER = { const INIT_USER = {
id: userprofile, id: userprofile,
email: '', email: "",
img: '', img: "",
} };
const HomeProfile = () => { const HomeProfile = () => {
const [user, setUser] = useState(INIT_USER) const [user, setUser] = useState(INIT_USER);
const [error, setError]= useState("");
async function getSetUser(userID) { async function getSetUser(userID) {
try { try {
console.log('userID', userID) const data = await userApi.getUser(userID);
const data = await userApi.getUser(userID)
console.log(data) setUser(data);
setUser(data)
// console.log(user)
} catch (error) { } catch (error) {
// catchErrors(error, setError) catchErrors(error, setError);
} }
} }
useEffect(() => { useEffect(() => {
getSetUser(userprofile) getSetUser(userprofile);
}, [userprofile]) }, [userprofile]);
return ( return (
<Link to={`/profile/${user.id}`} className="text-decoration-none text-dark"> <Link to={`/profile/${user.id}`} className="text-decoration-none text-dark">
......
...@@ -3,10 +3,10 @@ import { Redirect } from "react-router-dom"; ...@@ -3,10 +3,10 @@ import { Redirect } from "react-router-dom";
import roomApi from "../../apis/room.api"; import roomApi from "../../apis/room.api";
import catchErrors from "../../context/catchError"; import catchErrors from "../../context/catchError";
const userId = localStorage.getItem('user'); const id = localStorage.getItem("user");
const JoinRoom = () => { const JoinRoom = () => {
const [roomId, setRoomId] = useState(''); const [roomId, setRoomId] = useState("");
const [disabled, setDisabled] = useState(true); const [disabled, setDisabled] = useState(true);
const [error, setError] = useState(""); const [error, setError] = useState("");
const [success, setSuccess] = useState(false); const [success, setSuccess] = useState(false);
...@@ -26,7 +26,7 @@ const JoinRoom = () => { ...@@ -26,7 +26,7 @@ const JoinRoom = () => {
try { try {
// setLoading(true); // setLoading(true);
setError(""); setError("");
const data = await roomApi.join({ userId: userId, roomId: roomId }); const data = await roomApi.join({ userId: id, roomId: roomId });
setSuccess(true); setSuccess(true);
} catch (error) { } catch (error) {
catchErrors(error, setError); catchErrors(error, setError);
...@@ -34,8 +34,12 @@ const JoinRoom = () => { ...@@ -34,8 +34,12 @@ const JoinRoom = () => {
// setLoading(false); // setLoading(false);
} }
} }
if (success) { if (success) {
return <Redirect to="/user" />; // console.log('success', success)
alert('룸참여가 완료되었습니다!')
window.location.href=`/user/${id}`
// return <Redirect to={`/user/${id}`} />;
} }
return ( return (
...@@ -53,6 +57,7 @@ const JoinRoom = () => { ...@@ -53,6 +57,7 @@ const JoinRoom = () => {
></button> ></button>
</div> </div>
<div className="modal-body"> <div className="modal-body">
{error && <div className="alert alert-danger">{error}</div>}
<div className="input-group mb-3"> <div className="input-group mb-3">
<input <input
type="text" type="text"
...@@ -66,7 +71,9 @@ const JoinRoom = () => { ...@@ -66,7 +71,9 @@ const JoinRoom = () => {
/> />
</div> </div>
<div className="modal-footer"> <div className="modal-footer">
<button type="submit" className="btn btn-primary"> <button
type="submit"
className="btn btn-primary">
확인 확인
</button> </button>
</div> </div>
......
...@@ -2,32 +2,39 @@ import { useEffect, useState } from 'react'; ...@@ -2,32 +2,39 @@ import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import roomApi from '../../apis/room.api'; import roomApi from '../../apis/room.api';
import userApi from '../../apis/user.api'; import userApi from '../../apis/user.api';
import catchErrors from '../../context/catchError';
const id = localStorage.getItem('user');
const INIT_ROOM={
name:"",
profileimg:"",
member:"",
}
const RoomSingle = () => { const RoomSingle = () => {
const [roomNum, setRoomNum] = useState('') const [room, setRoom] = useState(INIT_ROOM)
const [room, setRoom] = useState([]) const [error,setError]=useState('')
// const roomId = localStorage.getItem('user');
const roomId = "abc7654321"
const channelId = 1 const channelId = 1
const A = [] const roomId = "1234567abc"
async function getJoinRoom(Id) {
try {
const User = await userApi.getUser(Id)
const RoomNumArr = User.roomNumber
const Room= await roomApi.getRoom(RoomNumArr)
console.log(Room[0])
const rrr=Room[0]
const memcount= rrr.member.length
setRoom({...room, name:rrr.name, profileimg: rrr.profileimg, member:memcount})
console.log(room)
// async function getJoinRoom(Id) { } catch (error) {
// try { catchErrors(error, setError)
// console.log('id:',id) }
// const User = await userApi.getUser({id: Id}) }
// console.log('User1:',User)
// console.log('User2:',User.roomNumber)
// const RoomNumArr = User.roomNumber
// console.log('setRoomNum:',RoomNumArr)
// const Room = await roomApi.getRoom(RoomNumArr)
// } catch (error) {
// // catchErrors(error, setError)
// }
// }
// useEffect(() => { useEffect(() => {
// getJoinRoom(id) getJoinRoom(id)
// }, [id]) }, [id])
return ( return (
<Link <Link
...@@ -39,11 +46,11 @@ const RoomSingle = () => { ...@@ -39,11 +46,11 @@ const RoomSingle = () => {
style={{ backgroundColor: '#C4C4C4' }} style={{ backgroundColor: '#C4C4C4' }}
> >
<div style={{ width: '37px', height: '37px' }}> <div style={{ width: '37px', height: '37px' }}>
<img {/* <img
src="BORA.png" src={`/roomUploads/${profileimg}`}
className="rounded-circle" className="rounded-circle"
style={{ width: '37px', height: '37px' }} style={{ width: '37px', height: '37px' }}
/> /> */}
</div> </div>
<div <div
className="mx-3 mt-2" className="mx-3 mt-2"
...@@ -54,9 +61,9 @@ const RoomSingle = () => { ...@@ -54,9 +61,9 @@ const RoomSingle = () => {
msOverflowStyle:'none', msOverflowStyle:'none',
}} }}
> >
데계 재미있는 수학과 데계데계데계 재미있는 수학과 {room.name}
</div> </div>
<div className="ms-auto mt-2"> 15/34 </div> <div className="ms-auto mt-2"> {room.member}/100 </div>
</div> </div>
</Link> </Link>
......
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { Redirect } from 'react-router-dom' import { Link } from 'react-router-dom'
import userApi from '../apis/user.api' import userApi from '../apis/user.api'
import catchErrors from "../context/catchError"; import catchErrors from '../context/catchError'
import { handleLogin } from '../context/auth'; import { handleLogin } from '../context/auth'
const INIT_USER = { const INIT_USER = {
userId: '9999',
email: '', email: '',
password: '', password: '',
} }
const Login = () => { const Login = () => {
// const { loading, login, catchErrorAuth } = useAuth()
const [user, setUser] = useState(INIT_USER) const [user, setUser] = useState(INIT_USER)
const [disabled, setDisabled] = useState(true) const [disabled, setDisabled] = useState(true)
const [error, setError] = useState('') const [error, setError] = useState('')
...@@ -28,10 +28,10 @@ const Login = () => { ...@@ -28,10 +28,10 @@ const Login = () => {
async function handleSubmit(e) { async function handleSubmit(e) {
e.preventDefault() e.preventDefault()
console.log('로그인')
try { try {
// setLoading(true); // setLoading(true);
// setError(""); // setError("");
console.log('user정보:', user)
const data = await userApi.login(user) const data = await userApi.login(user)
console.log(data) console.log(data)
setId(data.id) setId(data.id)
...@@ -45,63 +45,59 @@ const Login = () => { ...@@ -45,63 +45,59 @@ const Login = () => {
} }
} }
if (success) { if (success) {
alert('로그인 되었습니다') alert('로그인 되었습니다');
return <Redirect to={`/user/${id}`} /> window.location.href = `/user/${id}`
} }
const { email, password } = user const { email, password } = user
return ( return (
<div className="modal-content"> <div className="container">
{error && <div className="alert alert-danger">{error}</div>}
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div className="modal-header"> <div className="m-3 d-flex justify-content-center">
<h5 className="modal-title" id="loginModalLabel"> <Link to="/">
로그인 <img src="/BORA.png" style={{ width: '160px' }} />
</h5> </Link>
<button
type="button"
className="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div> </div>
<div className="modal-body"> <div className="row mt-5 d-flex align-items-center">
<div> <h2 style={{ textAlign: 'center' }}>로그인</h2>
<label>아이디</label> {error && <div className="alert alert-danger">{error}</div>}
<input <div className="form-group">
className="form-control" <div className="mt-5">
id="email" <label>아이디</label>
type="text" <input
name="email" className="form-control"
placeholder="아이디를 입력하세요" id="email"
value={email} type="text"
onChange={handleChange} name="email"
/> placeholder="아이디를 입력하세요"
value={email}
onChange={handleChange}
/>
</div>
<div className="mt-3">
<label>비밀번호</label>
<input
className="form-control"
id="password"
type="password"
name="password"
placeholder="비밀번호를 입력하세요"
value={password}
onChange={handleChange}
/>
</div>
</div> </div>
<div> <div className="mt-4 d-flex justify-content-center">
<label>비밀번호</label> <button
<input type="submit"
className="form-control" className="btn btn-primary"
id="loginPassword" disabled={disabled}
type="password" >
name="password" 로그인
placeholder="비밀번호를 입력하세요" </button>
value={password}
onChange={handleChange}
/>
</div> </div>
</div> </div>
<div className="modal-footer">
<button
type="submit"
className="btn btn-primary"
disabled={disabled}
data-bs-dismiss="modal"
>
로그인
</button>
</div>
</form> </form>
</div> </div>
) )
......
...@@ -34,6 +34,7 @@ const InfoUpdate = () => { ...@@ -34,6 +34,7 @@ const InfoUpdate = () => {
const handleChange = async (event) => { const handleChange = async (event) => {
const { files } = event.target; const { files } = event.target;
console.log('files:',files)
let formData = new FormData(); let formData = new FormData();
formData.append("img", files[0]); formData.append("img", files[0]);
formData.append("id", userprofile); formData.append("id", userprofile);
......
...@@ -4,12 +4,14 @@ import LeftHamburger from './LeftHamburger'; ...@@ -4,12 +4,14 @@ import LeftHamburger from './LeftHamburger';
import RightHamburger from './RightHamburger'; import RightHamburger from './RightHamburger';
const ChannelList = () => { const ChannelList = () => {
const id = localStorage.getItem('user');
return ( return (
<div> <div>
<nav className="navbar navbar-light d-flex justify-content-between"> <nav className="navbar navbar-light d-flex justify-content-between">
<LeftHamburger /> <LeftHamburger />
<div> <div>
<Link to="/user:id"> <Link to={`/user/${id}`}>
<img src="/BORA.png" style={{ width: '160px' }} /> <img src="/BORA.png" style={{ width: '160px' }} />
</Link> </Link>
</div> </div>
......
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