import React, { useState, useEffect } from 'react'; import axios from 'axios'; import { Row, Col, Modal, Button, Form, Alert } from 'react-bootstrap'; import Tabs from 'react-bootstrap/Tabs'; import Tab from 'react-bootstrap/Tab'; import ClosedList from '../Components/ClosedList'; import OpenList from '../Components/OpenList'; import Chat from '../Components/Chat'; import Menu from '../Components/Menu'; import catchErrors from '../utils/catchErrors'; // import styled from 'styled-components'; // const List = styled.div` // background: #FFFAFA; // ` const INIT_CHATR = { name: '', interest: '', isOpen: false } function Home() { const [show, setShow] = useState(false); const [show2, setShow2] = useState(false); const [chat, setChat] = useState(false); // const [checkedI, setCheckedI] = useState(false); const [chatR, setChatR] = useState(INIT_CHATR); const [disabled, setDisabled] = useState(true); const [error, setError] = useState(''); const handleClose = () => setShow(false); const handleShow = () => setShow(true); const handleChato = () => setChat(true); const handleChatc = () => setChat(false); const handleClose2 = () => setShow2(false); const handleShow2 = () => setShow2(true); // variant="pills" useEffect(() => { const isChatR = Object.values(chatR).every(el => Boolean(el)) isChatR ? setDisabled(false) : setDisabled(true) }, [chatR]) function handleChange(event) { const { name, value } = event.target setChatR({ ...chatR, [name]: value }) } async function handleSubmit(event) { event.preventDefault() try { setError('') // const response = await fetch('chat/makeChat', { // method: 'POST', // headers: { // 'Content-Type': 'application/json' // }, // body: JSON.stringify(chatR) // }) //const data = await response.json() const response = await axios.post('chat/makeChat', chatR) setChatR(INIT_CHATR) } catch (error){ catchErrors(error, setError) } } return ( <>
공개방으로 개설되어 공개방 목록에 공개되며, 코드를 공유하여 참가할 수도 있습니다.
) : (비밀방으로 개설되며, 참여자들에게 코드를 공유해야합니다.
) }