import { useState } from "react"; import { useParams } from "react-router-dom"; import roomApi from "../../apis/room.api"; import catchErrors from "../../context/catchError"; const MakeChannel = () => { const { roomId } = useParams(); const [channelName, setChannelName] = useState(""); const [error, setError] = useState(""); const [success, setSuccess] = useState(false); function handleChange(event) { const { value } = event.target; setChannelName(value); } console.log(channelName) async function handleSubmit(e) { // e.preventDefault(); try { const data = await roomApi.makeChannel({ roomId: roomId, channelName: channelName }); console.log('서버연결됬나요', data) setSuccess(true); } catch (error) { catchErrors(error, setError); } finally { // setLoading(false); } } if (success) { // console.log('success', success) alert('채널생성이 완료되었습니다!') window.location.href = `/room/${roomId}/${channelName}` } return (