Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
1.4 kB
2
Indexable
Never
import React, { useState } from 'react';

const LoginForm = () => {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');
  const [rememberMe, setRememberMe] = useState(false);

  const handleSubmit = (event) => {
    event.preventDefault();
    console.log('FORM DATA', { email, password, rememberMe });
    // aquí llamamos a la API para iniciar sesión o registrarnos
  };

  return (
    <div className="container">
      <form onSubmit={handleSubmit}>
        <h2>Iniciar sesión</h2>
        <label>
          Email:
          <input
            type="email"
            value={email}
            onChange={(event) => setEmail(event.target.value)}
            placeholder="introduzca su Email"
          />
        </label>
        <br />
        <label>
          Contraseña:
          <input
            type="password"
            value={password}
            onChange={(event) => setPassword(event.target.value)}
            placeholder="introduzca su contraseña"
          />
        </label>
        <br />
        <label>
          <input
            type="checkbox"
            checked={rememberMe}
            onChange={(event) => setRememberMe(event.target.checked)}
          />
          Recuerdame
        </label>
        <br />
        <button type="submit">Ingresar</button>
      </form>
    </div>
  );
};

export default LoginForm;
Leave a Comment