import { useEffect, useState } from "react"; import roomApi from "../../apis/room.api"; const userId = localStorage.getItem('user'); console.log(userId) const INIT_ROOM = { name: '', profileimg: '', channel: ['회의'], } const CreateRoom = () => { const [room, setRoom] = useState(INIT_ROOM) const [error, setError] = useState(""); const [success, setSuccess] = useState(false) const [disabled, setDisabled] = useState(true) useEffect(() => { const isRoom = Object.values(roomApi).every((el) => Boolean(el)); isRoom ? setDisabled(false) : setDisabled(true); }, [room]); // const userId = localStorage.getItem('user'); // setRoom({...room, owner: userId}) // setRoom({...room, member: userId}) function handleChange(event) { console.log(room) const { name, value } = event.target setRoom({ ...room, [name]: value }) } console.log(room) async function handleSubmit(e) { e.preventDefault() console.log('룸룸', room) try { const res = await roomApi.create(room) // console.log(res) const Id = res.id // console.log(Id) //alert(`방참여코드는 ${Id}입니다`) //setSuccess(true) } catch (error) { // catchErrors(error, setError); } finally { // setLoading(false); } } if (success) { console.log('success', success) alert('룸생성이 완료되었습니다!') //return } const { name, owner, member, profileimg } = room; return (
방생성하기
방프로필사진
방이름
); }; export default CreateRoom;