server.js
// This next inquirer prompt is within a function so this way if the user chose to cancel this inquirer prompt wouldn't run anyways.
This next inquirer prompt is within a function so this way if the user chose to cancel this inquirer prompt wouldn't run anyways.
This next inquirer prompt is within a function so this way if the user chose to cancel this inquirer prompt wouldn ' t run anyways .
function secondUpdateQuestion() {
                    inquirer
                     .prompt({
                        type: 'list',
                        name: 'userSecondChoice',
                        message: promptMessage,
                        choices: arrayChoice
                     })
                     .then(function(choice) {
                        var settingChoice = [
                            {
                                id: answer.userChoice.id
                            }
                        ];
                        if (updateVal === 'manager') {
                            settingChoice.unshift({
                                manager_id: choice.userSecondChoice.id
                            });
                        } 
                        else {
                            settingChoice.unshift({
                                role_id: choice.userSecondChoice.id
                            });
                        }
                        connection.query(
                            `UPDATE employee SET ? WHERE ?`,
                            settingChoice,
                            function (err, res) {
                                if (err) throw err;
                                console.clear();
                                if (updateVal === 'manager') {
                                    if (choice.userSecondChoice !== 'No one') {
                                        console.log(`${answer.userChoice.first_name}'s manager has been updated to ${choice.userSecondChoice.name_without_id}!\n`)
                                    } else {
                                        console.log(`${answer.userChoice.first_name}'s manager has been updated!\n`);
                                    }
                                } 
                                else {
                                    console.log(`${answer.userChoice.first_name}'s position has been updated to ${choice.userSecondChoice.name}!\n`);
                                }
                                init();
                            }
                        );
                    });
                }
function secondUpdateQuestion ( ) { inquirer . prompt ( { type : 'list' , name : 'userSecondChoice' , message : promptMessage , choices : arrayChoice } ) . then ( function ( choice ) { var settingChoice = [ { id : answer . userChoice . id } ] ; if ( updateVal === 'manager' ) { settingChoice . unshift ( { manager_id : choice . userSecondChoice . id } ) ; } else { settingChoice . unshift ( { role_id : choice . userSecondChoice . id } ) ; } connection . query ( ` ` , settingChoice , function ( err , res ) { if ( err ) throw err ; console . clear ( ) ; if ( updateVal === 'manager' ) { if ( choice . userSecondChoice !== 'No one' ) { console . log ( ` ${ answer . userChoice . first_name } ${ choice . userSecondChoice . name_without_id } \n ` ) } else { console . log ( ` ${ answer . userChoice . first_name } \n ` ) ; } } else { console . log ( ` ${ answer . userChoice . first_name } ${ choice . userSecondChoice . name } \n ` ) ; } init ( ) ; } ) ; } ) ; }
This next inquirer prompt is within a function so this way if the user chose to cancel this inquirer prompt wouldn't run anyways.
This next inquirer prompt is within a function so this way if the user chose to cancel this inquirer prompt wouldn ' t run anyways .
// If the user chose to update the employee's manager // Or if the user chose to update the employee's role // Connection query to update the employee role or manager // Depending on what the user chose, this if statement will log the appropriate response