index.js
// Add new member function with input arrays for enquirer prompts
Add new member function with input arrays for enquirer prompts
Add new member function with input arrays for enquirer prompts
function addNewMember() {
    inquirer.prompt([{
        type: 'input',
        message: "Type a name for a member of your Team",
        name: "name"
    },
    {
        type: "list",
        message: "What is their role in the Team?",
        choices: [
            "Engineer",
            "Intern",
            "Manager"
        ],
        name: "role"
    },
    {
        type: 'input',
        message: "Enter their ID",
        name: "id"
    },
    {
        type: 'input',
        message: "Include an email address",
        name: "email",
    }])
        .then(function ({ name, role, id, email }) {
            let roleInfo = "";
            if (role === "Engineer") {
                roleInfo = "GitHub username";
            } else if (role === "Intern") {
                roleInfo = "school name/college";
            } else {
                roleInfo = "office phone number";
            }
            inquirer.prompt([{
                type: 'input',
                message: `Enter member's ${roleInfo}`,
                name: "roleInfo"
            },
            {
                type: "list",
                message: "Would you like to add another team member?",
                choices: [
                    "yes",
                    "no"
                ],
                name: "moreMembers"
            }])
                .then(function ({ roleInfo, moreMembers }) {
                    let newMember;
                    if (role === "Engineer") {
                        newMember = new Engineer(name, id, email, roleInfo);
                    } else if (role === "Intern") {
                        newMember = new Intern(name, id, email, roleInfo);
                    } else {
                        newMember = new Manager(name, id, email, roleInfo);
                    }
                    employees.push(newMember);
                    appendHTML(newMember)
                        .then(function () {
                            if (moreMembers === "yes") {
                                addNewMember();
                            } else {
                                finishHtml();
                            }
                        });
                });
        });
}
function addNewMember ( ) { inquirer . prompt ( [ { type : 'input' , message : "Type a name for a member of your Team" , name : "name" } , { type : "list" , message : "What is their role in the Team?" , choices : [ "Engineer" , "Intern" , "Manager" ] , name : "role" } , { type : 'input' , message : "Enter their ID" , name : "id" } , { type : 'input' , message : "Include an email address" , name : "email" , } ] ) . then ( function ( { name , role , id , email } ) { let roleInfo = "" ; if ( role === "Engineer" ) { roleInfo = "GitHub username" ; } else if ( role === "Intern" ) { roleInfo = "school name/college" ; } else { roleInfo = "office phone number" ; } inquirer . prompt ( [ { type : 'input' , message : ` ${ roleInfo } ` , name : "roleInfo" } , { type : "list" , message : "Would you like to add another team member?" , choices : [ "yes" , "no" ] , name : "moreMembers" } ] ) . then ( function ( { roleInfo , moreMembers } ) { let newMember ; if ( role === "Engineer" ) { newMember = new Engineer ( name , id , email , roleInfo ) ; } else if ( role === "Intern" ) { newMember = new Intern ( name , id , email , roleInfo ) ; } else { newMember = new Manager ( name , id , email , roleInfo ) ; } employees . push ( newMember ) ; appendHTML ( newMember ) . then ( function ( ) { if ( moreMembers === "yes" ) { addNewMember ( ) ; } else { finishHtml ( ) ; } } ) ; } ) ; } ) ; }
Add new member function with input arrays for enquirer prompts
Add new member function with input arrays for enquirer prompts
// else if function to determine what additional information to prompt for based on selected role // then prompt for the correct information based on role // Once all questions are asked prompt to check if they want to add another member // Function to add class to new member based on role choice // Else if statement to determine the class for the content to be appended // Append new member to the HTML document // If user selects more members run new members function again // Else, run finishHtml function