import { useState, useEffect } from "react"; import { Link, useParams } from "react-router-dom"; import ChannelSingle from "./ChannelSingle"; import RoomApi from "../../apis/room.api"; import roomApi from "../../apis/room.api"; import catchErrors from "../../context/catchError"; const INIT_CHANNEL = { channelName: "", joinName: [], }; const RightHamburger = () => { const [channel, setChannel] = useState([INIT_CHANNEL]); const { roomId } = useParams(); const [error, setError] = useState(""); const id = localStorage.getItem('user'); 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) { // console.log('roomId', 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) }, [roomId]); function roomIdCopy() { const t = document.querySelector("#roomId").innerText; console.log(t); navigator.clipboard.writeText(t); document.execCommand("copy"); } return (
{room.name}