Commit bdbf406c authored by 우지원's avatar 우지원
Browse files

e

parent 0c3731f4
...@@ -3,11 +3,11 @@ import { Redirect } from "react-router-dom"; ...@@ -3,11 +3,11 @@ 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: id,
member: userId, member: id,
profileimg: '', profileimg: '',
} }
...@@ -43,9 +43,9 @@ const CreateRoom = () => { ...@@ -43,9 +43,9 @@ const CreateRoom = () => {
} }
if (success) { if (success) {
console.log('success', success) // console.log('success', success)
alert('룸생성이 완료되었습니다!') alert('룸생성이 완료되었습니다!')
return <Redirect to='/user/:id' /> return <Redirect to={`/user/${id}`} />
} }
const { name, owner, member, profileimg } = room; const { name, owner, member, profileimg } = room;
......
...@@ -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 JoinRoom = () => { const JoinRoom = () => {
const [roomId, setRoomId] = useState(""); const [roomId, setRoomId] = useState("");
...@@ -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,11 @@ const JoinRoom = () => { ...@@ -34,8 +34,11 @@ const JoinRoom = () => {
// setLoading(false); // setLoading(false);
} }
} }
if (success) { if (success) {
return <Redirect to="/user" />; // console.log('success', success)
alert('룸참여가 완료되었습니다!')
return <Redirect to={`/user/${id}`} />;
} }
return ( return (
......
...@@ -6,7 +6,7 @@ import userApi from '../../apis/user.api'; ...@@ -6,7 +6,7 @@ import userApi from '../../apis/user.api';
const RoomSingle = () => { const RoomSingle = () => {
const [roomNum, setRoomNum] = useState('') const [roomNum, setRoomNum] = useState('')
const [room, setRoom] = useState([]) const [room, setRoom] = useState([])
const id = localStorage.getItem('user'); const roomId = localStorage.getItem('user');
const channelId = 1 const channelId = 1
const A = [] const A = []
...@@ -30,7 +30,7 @@ const RoomSingle = () => { ...@@ -30,7 +30,7 @@ const RoomSingle = () => {
return ( return (
<Link <Link
to={`/room/${id}/${channelId}`} to={`/room/${roomId}/${channelId}`}
className="text-decoration-none text-dark" className="text-decoration-none text-dark"
> >
<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