function addRole() {
    db.query(
        `SELECT * FROM department`,
        function (err, results) {
            if (err) throw err;

            let departmentList = results.map(department => ({
                name: department.name, value: department.id
            }));

            inquirer.prompt([
                {
                    type: "input",
                    name: "newRoleName",
                    message: "Please enter the name of the new Role:"
                },
                {
                    type: "input",
                    name: "newRoleSalary",
                    message: "Please enter the new salary for the new Role:",
                },
                {
                    type: "list",
                    name: "newRoleDept",
                    message: "please select the new Role's Department.",
                    choices: departmentList
                }
            ])
                .then(answers => {
                    db.query(
                        `INSERT INTO role SET ?`,
                        {
                            title: answers.newRoleName,
                            salary: answers.newRoleSalary,
                            department_id: answers.newRoleDept
                        },
                        function (err, results) {
                            if (err) throw err;
                            console.log('\x1b[33m%s\x1b[0m' ,'New Role Added to the database\n');
                            comfirmPrompt();
                        }
                    );
                })
        }
    );
}
// fuction to add new role to the database
fuction to add new role to the database
fuction to add new role to the database
function addRole() {
    db.query(
        `SELECT * FROM department`,
        function (err, results) {
            if (err) throw err;
            let departmentList = results.map(department => ({
                name: department.name, value: department.id
            }));
            inquirer.prompt([
                {
                    type: "input",
                    name: "newRoleName",
                    message: "Please enter the name of the new Role:"
                },
                {
                    type: "input",
                    name: "newRoleSalary",
                    message: "Please enter the new salary for the new Role:",
                },
                {
                    type: "list",
                    name: "newRoleDept",
                    message: "please select the new Role's Department.",
                    choices: departmentList
                }
            ])
                .then(answers => {
                    db.query(
                        `INSERT INTO role SET ?`,
                        {
                            title: answers.newRoleName,
                            salary: answers.newRoleSalary,
                            department_id: answers.newRoleDept
                        },
                        function (err, results) {
                            if (err) throw err;
                            console.log('\x1b[33m%s\x1b[0m' ,'New Role Added to the database\n');
                            comfirmPrompt();
                        }
                    );
                })
        }
    );
}
function addRole ( ) { db . query ( ` ` , function ( err , results ) { if ( err ) throw err ; let departmentList = results . map ( department => ( { name : department . name , value : department . id } ) ) ; inquirer . prompt ( [ { type : "input" , name : "newRoleName" , message : "Please enter the name of the new Role:" } , { type : "input" , name : "newRoleSalary" , message : "Please enter the new salary for the new Role:" , } , { type : "list" , name : "newRoleDept" , message : "please select the new Role's Department." , choices : departmentList } ] ) . then ( answers => { db . query ( ` ` , { title : answers . newRoleName , salary : answers . newRoleSalary , department_id : answers . newRoleDept } , function ( err , results ) { if ( err ) throw err ; console . log ( '\x1b[33m%s\x1b[0m' , 'New Role Added to the database\n' ) ; comfirmPrompt ( ) ; } ) ; } ) } ) ; }
fuction to add new role to the database
fuction to add new role to the database