Skip to content

Commit

Permalink
Merge pull request #12 from dlv237/registrar
Browse files Browse the repository at this point in the history
Agregar funcionalidad de registrar usuario
  • Loading branch information
FabianMF1 authored Apr 21, 2024
2 parents 83dc656 + fd54023 commit d074e85
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 12 deletions.
40 changes: 36 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/common/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./button.css";
import "./Button.css";
import { useRef, useEffect } from "react";
import PropTypes from "prop-types";

Expand Down
Empty file added src/userpages/.env
Empty file.
54 changes: 47 additions & 7 deletions src/userpages/register.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
import "./register.css";
import { useNavigate } from "react-router-dom";
import { useState } from "react";
import axios from "axios";

function Register() {
const navigate = useNavigate();

const [user, setUser] = useState({
name: "",
email: "",
phone: "",
password: "",
});

const handleSubmit = async (e) => {
e.preventDefault();
console.log(user);
try {
const response = await axios.post("https://flightsbooking.me/users", user);
if (response.status === 200) {
navigate("/");
} else {
console.log(error);
}
} catch (error) {
console.error("Error al registrar:", error);
}
};

const handleChange = (e) => {
setUser({ ...user, [e.target.name]: e.target.value });
};

return (
<div className="landing-container">
<div className="landing-content">
Expand All @@ -13,37 +41,49 @@ function Register() {
<div className="screen">
<div className="screen__content">
<h2 className="register-title">Registrarse</h2>
<form className="register">
<form className="register" onSubmit={handleSubmit}>
<div className="register__field">
<input
type="text"
className="login__input"
placeholder="Nombre"
></input>
name="name"
value={user.name}
onChange={handleChange}
/>
</div>
<div className="register__field">
<input
type="mail"
type="email"
className="login__input"
placeholder="Mail"
></input>
name="email"
value={user.email}
onChange={handleChange}
/>
</div>
<div className="register__field">
<input
type="text"
className="login__input"
placeholder="Telefono"
></input>
name="phone"
value={user.phone}
onChange={handleChange}
/>
</div>
<div className="register__field">
<input
type="password"
className="login__input"
placeholder="Contraseña"
></input>
name="password"
value={user.password}
onChange={handleChange}
/>
</div>
<div className="login-buttons-container">
<button className="button login__submit">
<button type="submit" className="button login__submit">
<span className="button__text">Continuar</span>
</button>
<button
Expand Down

0 comments on commit d074e85

Please sign in to comment.