function addEmployee(){
    connection.query("SELECT * FROM role", function (err, res){
        if(err) throw err;
        inquirer.prompt([
            {
                type: "input",
                name: "first_name",
                message: "What is the employee's first name?"
            },
            {
                type: "input",
                name: "last_name",
                message: "What is the employee's last name?"
            },
            {
                type: "list",
                name: "role",
                message: "What is the employee's role?",
                choices: res.map((role) => `${role.title}`)
            },
            // {
            //     type: "list",
            //     name: "manager",
            //     message: "Who is the employee's manager?",
            //     choices: res.map((employee) => `${employee.first_name} ${employee.last_name}`)
            // }
        ])
        .then((createdEmployee) =>{
            console.log(`Added ${createdEmployee.first_name} ${createdEmployee.last_name} to the database`);
            connection.query(
                "INSERT INTO employee SET ?",
                createdEmployee,
                function(err, res) {
                    if(err) throw err;
            question1Prompt();
        })
    })
         
        
    });
        
    }
//This question should come after the user wants to add an employee
This question should come after the user wants to add an employee
This question should come after the user wants to add an employee
function addEmployee(){
    connection.query("SELECT * FROM role", function (err, res){
        if(err) throw err;
        inquirer.prompt([
            {
                type: "input",
                name: "first_name",
                message: "What is the employee's first name?"
            },
            {
                type: "input",
                name: "last_name",
                message: "What is the employee's last name?"
            },
            {
                type: "list",
                name: "role",
                message: "What is the employee's role?",
                choices: res.map((role) => `${role.title}`)
            },
        ])
        .then((createdEmployee) =>{
            console.log(`Added ${createdEmployee.first_name} ${createdEmployee.last_name} to the database`);
            connection.query(
                "INSERT INTO employee SET ?",
                createdEmployee,
                function(err, res) {
                    if(err) throw err;
            question1Prompt();
        })
    })
    });
    }
function addEmployee ( ) { connection . query ( "SELECT * FROM role" , function ( err , res ) { if ( err ) throw err ; inquirer . prompt ( [ { type : "input" , name : "first_name" , message : "What is the employee's first name?" } , { type : "input" , name : "last_name" , message : "What is the employee's last name?" } , { type : "list" , name : "role" , message : "What is the employee's role?" , choices : res . map ( ( role ) => ` ${ role . title } ` ) } , ] ) . then ( ( createdEmployee ) => { console . log ( ` ${ createdEmployee . first_name } ${ createdEmployee . last_name } ` ) ; connection . query ( "INSERT INTO employee SET ?" , createdEmployee , function ( err , res ) { if ( err ) throw err ; question1Prompt ( ) ; } ) } ) } ) ; }
This question should come after the user wants to add an employee
This question should come after the user wants to add an employee
// { //     type: "list", //     name: "manager", //     message: "Who is the employee's manager?", //     choices: res.map((employee) => `${employee.first_name} ${employee.last_name}`) // }