diff --git a/client/src/components/Home/RoomSingle.js b/client/src/components/Home/RoomSingle.js
index d5d03cb0c487fbeeb79e74499f9e0f40b7727744..abb6885a4c40c3c6105aef4ec53b2b105b11ea49 100644
--- a/client/src/components/Home/RoomSingle.js
+++ b/client/src/components/Home/RoomSingle.js
@@ -38,7 +38,6 @@ const RoomSingle = () => {
useEffect(() => {
getJoinRoom(id);
}, [id]);
- console.log(room)
const { profileimg } = room;
return (
@@ -46,7 +45,7 @@ const RoomSingle = () => {
{room &&
room.map((el) => (
- {room === INIT_ROOM ? (
): (
+ {room[0] === INIT_ROOM ? (
): (
{
const data = await roomApi.getRoom([roomId]);
console.log(data)
setRoom({...room, id:data[0].id, name:data[0].name, profileimg: data[0].profileimg})
+ console.log(room.profileimg)
} catch (error) {
catchErrors(error, setError);
}
diff --git a/client/src/components/Room/RightHamburger.js b/client/src/components/Room/RightHamburger.js
index ced5a7c91a64e91ee4ed0411b842ba8b4bbf82f3..707203e48b06f7a774b9b17da0baa8c419a43a28 100644
--- a/client/src/components/Room/RightHamburger.js
+++ b/client/src/components/Room/RightHamburger.js
@@ -5,70 +5,69 @@ import RoomApi from "../../apis/room.api";
import catchErrors from "../../context/catchError";
const INIT_ROOM = {
- name: "",
- };
+ name: "",
+};
const INIT_CHANNEL = {
- channelName: "",
- joinName: [],
+ 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 })
- console.log(data)
- } catch (error) {
- catchErrors(error, setError);
- }
+ 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 });
+ console.log(data);
+ } catch (error) {
+ catchErrors(error, setError);
}
+ }
- async function getChannel(roomId) {
- const ID = roomId
- try {
- const data = await RoomApi.getRoom([ID]);
- const Channel = data[0].channel
- console.log('방데이터:', Channel)
- const channelList = [];
- for (const prop in Channel) { // Channel의 항목(prop)으로 작업을 실행합니다
- for (const key in Channel[prop]) {
- console.log(key)
- console.log(prop)
- console.log(Channel[prop][key])
- channelList.push({
- channelName: key,
- joinName: Channel[prop][key]
- });
- }
- }
- setChannel(channelList);
- } catch (error) {
- catchErrors(error, setError);
+ async function getChannel(roomId) {
+ const ID = roomId;
+ try {
+ const data = await RoomApi.getRoom([ID]);
+ const Channel = data[0].channel;
+ console.log("방데이터:", Channel);
+ const channelList = [];
+ for (const prop in Channel) {
+ // Channel의 항목(prop)으로 작업을 실행합니다
+ for (const key in Channel[prop]) {
+ console.log(key);
+ console.log(prop);
+ console.log(Channel[prop][key]);
+ channelList.push({
+ channelName: key,
+ joinName: Channel[prop][key],
+ });
}
+ }
+ setChannel(channelList);
+ } catch (error) {
+ catchErrors(error, setError);
}
-
+ }
+
// console.log(channel)
useEffect(() => {
getChannel(roomId);
- getRoom(roomId)
+ getRoom(roomId);
}, [roomId]);
function roomIdCopy() {
@@ -127,86 +126,83 @@ const RightHamburger = () => {
>