import './Bouton.css'
import {useState} from "react";

function Bouton() {

    const [status, setStatus] = useState(true)

    function changeStatus() {
        setStatus(!status)
        const toFetch = status ? 'http://localhost:3000/unlock' : 'http://localhost:3000/lock'
        fetch(toFetch, {method: 'POST'})
    }

    return(
        <div className="btn">
            <button onClick={changeStatus}>
                Chatière {status ? "ouverte" : "fermée"}
            </button>
        </div>
    )
}

export default Bouton
