JSFiddle - React, Tailwind, and code Playground

JavaScript

// Main class
function Arina(loginstate) {
    var loginstate = loginstate;
}


/**
 * attempts to log the user in
 * @
 * @param  {string} username [user's username]
 * @param  {string} password [user's password]
 * @return {array}           [status, message]      
 */
Arina.prototype.login = function(username, password) {
    /**
     * Validate if the user has filled in all required fields
     */
    if (username == '' || username == null)  return [false, 'No username given.']; 
    if (password == '' || password == null)  return [false, 'No password given.'];

    /**
     * Set up ajax payload
     */
    var payload = {
        username : username,
        password : password,
        unhashed  : true
    }

        /**
         * Make ajax call to check credentials
         * @param {object} 'payload' [Form data]
         */
        $.ajax({
            url     : '/echo/json',
            type    : 'POST',
            data    : payload
        }).always(this.handleResult);



        /**
         * Catch jQuery ajax error
         * @param  {object} event       
         * @param  {object} xhr         
         * @param  {object} settings    
         * @param  {string} thrownError 
         * @return {array}             
         */
        $(document).ajaxError(function(event, xhr, settings, thrownError) {
            if (xhr.status == 401) return [false, 'Invalid username or password.'];
            if (xhr.status == 500) return [false, 'Internal server error, please contact an administrator.'];
        });
}

Arina.prototype.handleResult = function(response, status, xhr) {
    console.log("do stuff here");
}

// I call the method once the script has been loaded (along with the rest of the JS files)
var arina = new Arina(1);
arina.login('test', 'test');