async function viewEmployeeByManeger() {
    let employees = await db.query('SELECT id, CONCAT(first_name, " ", last_name) AS name FROM employee');
    employees.push({ id: null, name: "Cancel" });
    let roles = await db.query('SELECT id, title FROM role');

    inquirer.prompt([
        {
            name: "manager",
            type: "list",
            message: "choose the employee",
            choices: employees.map(obj => obj.name)
        },
        {
            name: "employee role",
            type: "list",
            message: "view employee by manager",
            choices: roles.map(obj => obj.title)
        }
    ]).then(answers => {
        if (answers.empName != "Cancel") {
            let empID = employees.find(obj => obj.name === answers.empName).id
            let roleID = roles.find(obj => obj.title === answers.newRole).id
            db.query("UPDATE employee SET role_id=? WHERE id=?", [roleID, empID]);
            console.log("\x1b[32m", `${answers.empName} new role is ${answers.newRole}`);
        }
        runApp();
    })
}
// viewed the employee by the manager
viewed the employee by the manager
viewed the employee by the manager
async function viewEmployeeByManeger() {
    let employees = await db.query('SELECT id, CONCAT(first_name, " ", last_name) AS name FROM employee');
    employees.push({ id: null, name: "Cancel" });
    let roles = await db.query('SELECT id, title FROM role');
    inquirer.prompt([
        {
            name: "manager",
            type: "list",
            message: "choose the employee",
            choices: employees.map(obj => obj.name)
        },
        {
            name: "employee role",
            type: "list",
            message: "view employee by manager",
            choices: roles.map(obj => obj.title)
        }
    ]).then(answers => {
        if (answers.empName != "Cancel") {
            let empID = employees.find(obj => obj.name === answers.empName).id
            let roleID = roles.find(obj => obj.title === answers.newRole).id
            db.query("UPDATE employee SET role_id=? WHERE id=?", [roleID, empID]);
            console.log("\x1b[32m", `${answers.empName} new role is ${answers.newRole}`);
        }
        runApp();
    })
}
async function viewEmployeeByManeger ( ) { let employees = await db . query ( 'SELECT id, CONCAT(first_name, " ", last_name) AS name FROM employee' ) ; employees . push ( { id : null , name : "Cancel" } ) ; let roles = await db . query ( 'SELECT id, title FROM role' ) ; inquirer . prompt ( [ { name : "manager" , type : "list" , message : "choose the employee" , choices : employees . map ( obj => obj . name ) } , { name : "employee role" , type : "list" , message : "view employee by manager" , choices : roles . map ( obj => obj . title ) } ] ) . then ( answers => { if ( answers . empName != "Cancel" ) { let empID = employees . find ( obj => obj . name === answers . empName ) . id let roleID = roles . find ( obj => obj . title === answers . newRole ) . id db . query ( "UPDATE employee SET role_id=? WHERE id=?" , [ roleID , empID ] ) ; console . log ( "\x1b[32m" , ` ${ answers . empName } ${ answers . newRole } ` ) ; } runApp ( ) ; } ) }
viewed the employee by the manager
viewed the employee by the manager