Tengo este codigo import SmallLogo from "./SmallLogo"
import { useState } from "react"
import axios from "axios";
import "./RegistroPacientes.css";
import { Link } from "react-router-dom";



export default function RegistroPacientes() {
    const [user, setUser] = useState(
        {
            "name": "",
            "CI": "",
            "gender": "",
            "peso": 0,
            "talla": 0,
            "altura": 0.1,
            "glucosa": 0,
        }
    )


    const handleChange = (e) => {
        const name = e.target.name;
        let value = e.target.value;


        setUser({ ...user, [name]: value });
    }



    const [error, setError] = useState([]);
    const [eState, setEstate] = useState(false);

    function submit() {
        try {
            axios
                .post("http://localhost:8081/api/v1/pacientes", user)
                .then((res) => {
                    if (res.data.status === 400) {
                        setError([res.data.message]);
                        setEstate(true);
                    }
                    if (res.data.status === 422) {
                        setError(res.data.error);
                        setEstate(true);
                    } else {
                        setError([res.data.message]);
                        setEstate(true);
                        setTimeout(() => {
                            // changeState("signin")
                        }, 1000);
                    }
                })
                .catch((err) => {
                    console.log(err);
                });
        } catch (err) {
            console.log(err);
        }
        setUser({
            "name": "",
            "CI": "",
            "gender": "",
            "peso": 0,
            "talla": 0,
            "altura": 0.1,
            "glucosa": 0,
        })
    }



    return (
        <div className="signDiv">
            <div style={{ marginTop: "-180px", width: "10px" }}>
                <SmallLogo />
            </div>
            <div className="title">
                <p className="titlep1">Registrar datos del paciente</p>
            </div>
            <div className="details">
                <label><p style={{ color: "lightgrey", marginTop: "5px" }}>Nombre</p></label>
                <input className="email" value={user.name} type="text" name="name" onChange={handleChange} />
                <br />
                <label><p style={{ color: "lightgrey" }}>Cedula de identidad</p></label>
                <input className="email" value={user.CI} type="text" name="CI" onChange={handleChange} />
                <br />
                <label><p style={{ color: "lightgrey" }}>Genero</p></label>
                <input className="email" value={user.gender} type="text" name="gender" onChange={handleChange} />
                <br />
                <label><p style={{ color: "lightgrey", marginTop: "5px" }}>Peso</p></label>
                <input className="email" value={user.peso} type="number" name="peso" onChange={handleChange} />
                <br />
                <label><p style={{ color: "lightgrey", marginTop: "5px" }}>Talla</p></label>
                <input className="email" value={user.talla} type="number" name="talla" onChange={handleChange} />
                <label><p style={{ color: "lightgrey", marginTop: "5px" }}>Altura</p></label>
                <input className="email" value={user.altura} type="number" name="altura" onChange={handleChange} />
                <br />
                <label><p style={{ color: "lightgrey", marginTop: "5px" }}>Glucosa</p></label>
                <input className="email" value={user.glucosa} type="number" name="glucosa" onChange={handleChange} />
                <br />
                <br />
            </div>
            {eState ? <div className="errorDivSU"><div className="allErrSU">{error.map((e) => <p key={e}>{e}</p>)}</div> <button onClick={() => setEstate(false)}>x</button></div> : ""}
            <button className="signinbtn" onClick={submit}> Guardar datos</button>
        </div>

    )
}