4 min readUpdated Mar 2, 2026

LoginModal Component Documentation

Overview

The LoginModal component is an interactive user interface element designed for handling user authentication within the Vantage analytics & data platform. It allows users to log in by entering their email and password credentials. Upon successful authentication, the modal will close and refresh the user interface, facilitating a seamless experience. This component ensures that users can access their accounts securely while providing immediate feedback if authentication fails.

Settings

The LoginModal component accepts the following settings to control its behavior and appearance:

1. onClose

2. title

3. size

4. footer

How It Works

  1. State Management: The component utilizes state management to manage the state of email, password, and any potential error messages that arise during the login process.

    • email: Holds the user's input for the email field.
    • password: Holds the user's input for the password field.
    • error: Keeps track of any error messages during authentication.
  2. Login Handler: The handleLogin function is responsible for sending a POST request to the authorization API with the user's credentials.

    • If authentication is successful (res.ok evaluates true), it will invoke the onClose callback and refresh the UI.
    • If the credentials are invalid, the error message returned from the API is captured and displayed to the user.
  3. Rendering: The component structure includes the BaseModal component, which encapsulates the modal's content. It features:

    • Input fields for collecting user email and password.
    • Conditionally rendered error messages, allowing users to receive immediate feedback for invalid inputs.

Data It Expects

  1. Email: A valid email address input by the user. It should be well-formed and will undergo standard validation.
  2. Password: A user-generated password required for login. The input must conform to standard security policies (minimum length, character complexity) as dictated by the back-end API, though specific validations are not enforced in the UI layer.
  3. Error Handling: The component expects the API to return relevant error messages for failed login attempts, which will be displayed to the user.

Use Cases & Examples

Use Case 1: Integrating Authentication for a Secure Dashboard

A business requires a secure login mechanism for its analytics dashboard where only authorized users can access sensitive data. The LoginModal allows users to log in seamlessly, ensuring their data remains protected.

Use Case 2: User Management Operations

For platforms offering subscription services, user login via LoginModal can facilitate personalized dashboards, billing information access, and account preferences management.

Use Case 3: Custom Error Messaging

Organizations that need specific error messages post-login failures (e.g., indicating whether the issue is an incorrect email or password) can utilize the LoginModal's flexibility to display these messages based on API feedback.

Example Configuration

To implement the LoginModal in an application that needs a customized title and footer:

javascript
// Parent Component Code Snippet

function App() {
    const handleModalClose = () => {
        console.log('Login modal closed');
    };

    return (
        <LoginModal 
            onClose={handleModalClose}
            title="Welcome Back!"
            size="md"
            footer={
                <>
                    <button onClick={handleModalClose}>Cancel</button>
                    <button onClick={handleLogin}>Login</button>
                    <button>Forgot Password?</button> {/* Additional Button */}
                </>
            }
        />
    );
}

In this example, the modal title is customized to "Welcome Back!" and an additional footer button for "Forgot Password?" has been added, providing users with direct access to password recovery options.