app.js
// Prompt to decide the role of the employee
Prompt to decide the role of the employee
Prompt to decide the role of the employee
function addEmployee() {
    inquirer    .prompt([
        {
            type: 'list',
            name: 'role',
            message: "What is your role within the company?",
            choices: ["Manager", "Engineer", "Intern", "Done adding employees"]
        }
    ]).then(function(response) {
        switch (response.role) {
            case "Manager":
                addManager();
                break;
            case "Engineer":
                addEngineer();
                break;
            case "Intern":
                addIntern();
                break;
            default:
                console.log(employees);
                generateHTML(render(employees));
        }
    })
    function addManager() {
        inquirer   
            .prompt([
                {
                    type: "input",
                    message: "What is your first name?",
                    name: "managerName"
                },
                {
                    type: "input",
                    message: "What is your email?",
                    name: "managerEmail"
                },
            ]).then(function(response) {
                var managerName = response.managerName;
                var managerEmail = response.managerEmail;
                var manager = new Manager(
                    managerName,
                    managerEmail,
                    empId,
                    managerOffice
                )
                employees.push(manager)
                empId++;
                managerOffice++;
                console.log(manager);
                addEmployee();
            })
    }
    function addEngineer() {
        inquirer
            .prompt([
                {
                    type: "input",
                    message: "What is your first name?",
                    name: "engineerName"
                },
                {
                    type: "input",
                    message: "What is your email addrress",
                    name: "engineerEmail"
                },
                {
                    type: "input",
                    message: "What is your GitHub username?",
                    name: "username"
                }
            ]).then(function(response) {
                var engineerName = response.engineerName;
                var engineerEmail = response.engineerEmail;
                var username = response.username;
                var engineer = new Engineer(
                    engineerName,
                    engineerEmail,
                    empId,
                    username,                      
                )
                employees.push(engineer);
                empId ++;
                console.log(engineer);
                addEmployee();
            })
    }
    function addIntern() {
        inquirer
            .prompt([
                {
                    type: "input",
                    message: "What is your first name?",
                    name: "internName"
                },
                {
                    type: "input",
                    message: "What is your email?",
                    name: "internEmail"
                },
                {
                    type: "input",
                    message: "What school do you attend?",
                    name: "internSchool"
                }
            ]).then(function(response) {
                var internName = response.internName;
                var internEmail = response.internEmail;
                var internSchool = response.internSchool;
                var intern = new Intern(
                    internName,
                    internEmail,
                    empId,
                    internSchool,
                )
                employees.push(intern);
                empId ++;
                console.log(intern);
                addEmployee();
            })
    }
}
function addEmployee ( ) { inquirer . prompt ( [ { type : 'list' , name : 'role' , message : "What is your role within the company?" , choices : [ "Manager" , "Engineer" , "Intern" , "Done adding employees" ] } ] ) . then ( function ( response ) { switch ( response . role ) { case "Manager" : addManager ( ) ; break ; case "Engineer" : addEngineer ( ) ; break ; case "Intern" : addIntern ( ) ; break ; default : console . log ( employees ) ; generateHTML ( render ( employees ) ) ; } } ) function addManager ( ) { inquirer . prompt ( [ { type : "input" , message : "What is your first name?" , name : "managerName" } , { type : "input" , message : "What is your email?" , name : "managerEmail" } , ] ) . then ( function ( response ) { var managerName = response . managerName ; var managerEmail = response . managerEmail ; var manager = new Manager ( managerName , managerEmail , empId , managerOffice ) employees . push ( manager ) empId ++ ; managerOffice ++ ; console . log ( manager ) ; addEmployee ( ) ; } ) } function addEngineer ( ) { inquirer . prompt ( [ { type : "input" , message : "What is your first name?" , name : "engineerName" } , { type : "input" , message : "What is your email addrress" , name : "engineerEmail" } , { type : "input" , message : "What is your GitHub username?" , name : "username" } ] ) . then ( function ( response ) { var engineerName = response . engineerName ; var engineerEmail = response . engineerEmail ; var username = response . username ; var engineer = new Engineer ( engineerName , engineerEmail , empId , username , ) employees . push ( engineer ) ; empId ++ ; console . log ( engineer ) ; addEmployee ( ) ; } ) } function addIntern ( ) { inquirer . prompt ( [ { type : "input" , message : "What is your first name?" , name : "internName" } , { type : "input" , message : "What is your email?" , name : "internEmail" } , { type : "input" , message : "What school do you attend?" , name : "internSchool" } ] ) . then ( function ( response ) { var internName = response . internName ; var internEmail = response . internEmail ; var internSchool = response . internSchool ; var intern = new Intern ( internName , internEmail , empId , internSchool , ) employees . push ( intern ) ; empId ++ ; console . log ( intern ) ; addEmployee ( ) ; } ) } }
Prompt to decide the role of the employee
Prompt to decide the role of the employee
// Switch statement to decide which prompts to use based on role // When user is done adding employees, the HTML will be generated and eployee array logged // generateHTML(employees); // Prompts for Manager criteria // console.log(response); // Increment employee ID // Increment Manager office number // Prompts for Engineer criteria // console.log(response); // Prompts for Intern criteria