import { useState, useEffect } from "react"; import { 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 INIT_ROOM = { name: "", }; const RightHamburger = () => { const [channel, setChannel] = useState([INIT_CHANNEL]); const [room, setRoom] = useState([INIT_ROOM]); const { roomId } = useParams(); const [error, setError] = useState(""); async function getroom(Id) { try { const Room = await roomApi.getRoom([Id]); setRoom({...room, name:Room[0].name}) } 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}

{" "} {`${roomId}`}{" "}
{/* {admin ? ( ) : null} */}
); }; export default RightHamburger;