text: // node modules
  generateHTML = require('./src/generateHTML');
  const inquirer = require('inquirer');
  const fs = require('fs');
  // team profiles
  const Manager = require('./lib/Manager');
  const Engineer = require('./lib/Engineer');
  const Intern = require('./lib/Intern');
  
  
  // team array
  const teamArray = [];
  
  const addManager = () => {
      return inquirer.prompt ([
          {
              type: 'input',
              name: 'name',
              message: "Enter manager's name",
              validate: nameInput => {
                  if (nameInput) {
                      return true;
                  } else {
                      console.log("Please enter manager's name!");
                      return false;
                  }
              }
          },
          {
              type: 'input',
              name: 'id',
              message: "Enter manager's ID",
              validate: nameInput => {
                  if (isNaN(nameInput)) {
                      console.log("Please enter manager's ID!");
                      return false;
                  } else {
                      return true;
                  }
              }  
          },
          {
              type: 'input',
              name: 'email',
              message: "Enter manager's email",
              validate: email => {
                  valid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)
                  if (valid) {
                      return true;
                  } else {
                      console.log("Please enter manager's email!");
                      return false;
                  }
              } 
          },
          {
              type: 'input',
              name: 'officeNumber',
              message: "Enter manager's office number",
              validate: nameInput => {
                  if (isNaN(nameInput)) {
                      console.log("Please enter manager's office number!");
                      return false;
                  } else {
                      return true;
                  }
              }
          }
      ])
      .then(managerInput => {
          const { name, id, email, officeNumber } = managerInput;
          const manager = new Manager (name, id, email, officeNumber);
  
          teamArray.push(manager);
          console.log(manager);
      })
  };
  
  const addEmployee = () => {
      console.log(`
      ============================
      Adding employees to the team
      ============================
      `);
      return inquirer.prompt ([
          {
              type: 'list',
              name: 'role',
              message: "Please choose your employee's role",
              choices: ['Engineer', 'Intern']
          },
          {
              type: 'input',
              name: 'name',
              message: "What is the name of the employee?",
              validate: nameInput => {
                  if (nameInput) {
                      return true;
                  } else {
                      console.log ("Please enter employee's name!");
                      return false;
                  }
              }
          },
          {
              type: 'input',
              name: 'id',
              message: "Enter employee's ID",
              validate: nameInput => {
                  if (isNaN(nameInput)) {
                      console.log ("Please enter employee's ID!");
                      return false;  
                  } else {
                      return true;  
                  }
              }
          },
          {
              type: 'input',
              name: 'email',
              message: "Enter employee's email",
              validate: email => {
                  valid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)
                  if (valid) {
                      return true;
                  } else {
                      console.log ("Please enter employee's email!");
                      return false;
                  }
              }
          },
          {
              type: 'input',
              name: 'github',
              message: "Enter employee's GitHub username",
              when: (input) => input.role === "Engineer",
              validate: nameInput => {
                  if (nameInput) {
                      return true;
                  } else {
                      console.log ("Please enter employee's GitHub username!");
                      return false;
                  }
              }
          },
          {
              type: 'input',
              name: 'school',
              message: "Enter intern's school?",
              when: (input) => input.role === "Intern",
              validate: nameInput => {
                  if (nameInput) {
                      return true;
                  } else {
                      console.log ("Please enter intern's school!");
                      return false;
                  }
              }
          },
          {
              type: 'confirm',
              name: 'confirmAddEmployee',
              message: 'Would you like to add more team members?',
              default: false
          }
      ])
      .then(employeeData => {
          let { name, id, email, role, github, school, confirmAddEmployee } = employeeData;
          let employee;
  
          if (role === 'Engineer') {
              employee = new Engineer (name, id, email, github);
              console.log(employee);
          } else if (role === 'Intern') {
              employee = new Intern (name, id, email, school);
              console.log(employee);
          }
          teamArray.push(employee);
          if (confirmAddEmployee) {
              return addEmployee(teamArray);
          } else {
              return teamArray;
          }
      })
  };
  
  
  // function to generate HTML page using file system
  const writeToFile = data => {
      fs.writeFile('./dist/index.html', data, err => {
          if(err) {
              console.log(err);
              return;
          } else {
              console.log('File has been created! Check out index.html')
          }
      })
  };
  addManager()
  .then(addEmployee)
  .then(teamArray => {
      return generateHTML(teamArray);
  })
  .then(pageHTML => {
      return writeToFile(pageHTML);
  })
  .catch(err => {
      console.log(err);
  });