text: import React, { useState, useEffect } from 'react';
  import { useAuth } from '../AuthContext';
  import Alert from '../common/Alert';
  
  const ConfirmAccount = ({ history, match }) => {
    const email = match.params.email;
  
    const [code, setCode] = useState('');
  
    const { userInfo, error, confirmAccount } = useAuth();
  
    useEffect(() => {
      if (!email || userInfo) {
        history.push('/');
      }
    }, [userInfo, history, email]);
  
    const confirmAccountHandler = e => {
      e.preventDefault();
      confirmAccount(email, code);
    };
  
    return (
      <section className="auth-section">
        <div className="container">
          <div className="row">
            <div className="col-md-4">
              <h1 className="text-center display-4 mb-3">Confirmar Cuenta</h1>
  
              {error && <Alert msg={error} />}
  
              <form onSubmit={confirmAccountHandler}>
                <div className="form-group mb-3">
                  <label htmlFor="code">Código *</label>
                  <input
                    type="text"
                    className="form-control"
                    id="code"
                    name="code"
                    required
                    value={code}
                    onChange={e => setCode(e.target.value)}
                  />
                </div>
  
                <button type="submit" className="btn btn-info">
                  Confirmar
                </button>
              </form>
            </div>
          </div>
        </div>
      </section>
    );
  };
  
  export default ConfirmAccount;
  