import React, { useState } from 'react';
import { Form, Row, Col, Button } from 'react-bootstrap'

function ChatForm(props) {
    const INIT_SAYING = ''
    const [saying, setSaying] = useState(INIT_SAYING);

    function handleChange(event) {
        const { name, value } = event.target
        setSaying(value)
        console.log(saying)
    }

    function handleSubmit(event) {
        event.preventDefault()
        // const response = await axios.post('chat/makeChat', chatR)
        props.setSingleChat()
        setSaying(INIT_SAYING)
    }

    return (
        <Form onSubmit={handleSubmit}>
            <Row>
                <Col>
                    <Form.Group>
                        <Form.Control name='chat' type='text' onChange={handleChange}>chat</Form.Control>
                    </Form.Group>
                </Col>
                <Col>
                    <Form.Group>
                        <Button type="submit">send</Button>
                    </Form.Group>
                </Col>
            </Row>
        </Form>
    )
}

export default ChatForm