Bootcamp student here. I am trying to generate a team profile together. Upon the manager information input, I am able to decide whether I want to add whether an engineer, intern, or no further entry. However, when I select the Engineer option, the application is supposed to show another inquirer prompt for the engineer information input. This current code is not letting me do so and actually ending the process on the terminal. Where did I go wrong?
const inquirer = require("inquirer");
const fs = require("fs");
const path = require("path");
const Engineer = require("./lib/Engineer");
const Intern = require("./lib/Intern");
const Manager = require("./lib/Manager");
const DIST_DIR = path.resolve(__dirname, "dist");
const distPath = path.join(DIST_DIR, "team.html");
const render = require("./src/renderHTML");
let teamMembers = [];
let teamIDs = [];
function startApp() {
function addManager() {
inquirer
.prompt([
{
type: "input",
name: "managerName",
message: "What is the your name?",
validate: (input) => {
if (input) {
return true;
} else {
console.log("Please enter your name to continue!");
return false;
}
},
}, (other questions here)
])
.then((answers) => {
const manager = new Manager(
answers.managerName,
answers.managerID,
answers.managerEmail,
answers.managerOffice
);
teamMembers.push(manager);
teamIDs.push(answers.managerID);
addTeamMember();
});
}
function addTeamMember() {
inquirer
.prompt([
{
type: "list",
name: "member",
message: `Select which team member you'd like to add to your team!`,
choices: ["Engineer", "Intern", "No team members to add"],
},
])
.then((answers) => {
switch (answers.memberChoice) {
case "Engineer":
generateEng(); <----- This is the area I'm having trouble with
break; When I select Engineer, it should run generateEng()
case "Intern": But is instead stopping code execution, via terminal
generateInt();
break;
default:
makeTeam();
}
});
}
function generateEng() {
inquirer
.prompt([
{
type: "input",
name: "engName",
message: `What is the engineer's name?`,
validate: (input) => {
if (input) {
return true;
} else {
console.log("Please enter the engineer's name to continue!");
return false;
}
},
}, (other questions here)
])
.then((answers) => {
const engineer = new Engineer(
answers.engName,
answers.engID,
answers.engEmail,
answers.engGithub
);
teamMembers.push(engineer);
teamIDs.push(answers.engID);
addTeamMember();
});
}
function generateInt() {
inquirer
.prompt([
{
type: "input",
name: "Name",
message: `What is the intern's name?`,
validate: (input) => {
if (input) {
return true;
} else {
console.log("Please enter the intern's name to continue!");
return false;
}
},
}, (other questions here)
])
.then((answers) => {
const intern = new Intern(
answers.intName,
answers.intID,
answers.intEmail,
answers.intGithub
);
teamMembers.push(intern);
teamIDs.push(intID);
addTeamMember();
});
}
function makeTeam() {
fs.writeFileSync(distPath, render(teamMembers), "utf-8");
}
addManager();
}
startApp();
instead of answers.memberChoice it should be answers.member