text: // index.js
  // test run
  // let test = "testName";
  // console.log(test);
  
  const fs = require("fs");
  const inquirer = require("inquirer");
  // const path = require("path");
  
  const Employee = require("./lib/Employee");
  const Engineer = require("./lib/Engineer");
  const Intern = require("./lib/Intern");
  const Manager = require("./lib/Manager");
  
  let manager = [];
  let engineer = [];
  let intern = [];
  
  // Start Function, calling inputs and html creation
  function initApp() {
    addMember();
    startHtml();
  }
  // Input Prompts
  function addMember() {
    inquirer
      .prompt([
        {
          message: "Enter teammates' name",
          name: "name",
        },
        {
          type: "list",
          message: "Select teammates' role",
          choices: ["Manager", "Engineer", "Intern"],
          name: "role",
        },
        {
          message: "Enter teammates' id",
          name: "id",
        },
        {
          message: "Enter teammates' email address",
          name: "email",
        },
      ])
      .then(function ({ name, role, id, email }) {
        let roleInfo = "";
        if (role === "Engineer") {
          roleInfo = "GitHub username";
        } else if (role === "Intern") {
          roleInfo = "school name";
        } else {
          roleInfo = "office phone number";
        }
        inquirer
          .prompt([
            {
              message: `Enter teammates' ${roleInfo}`,
              name: "roleInfo",
            },
            {
              type: "list",
              message: "Do you have more members to build?",
              choices: ["yes", "no"],
              name: "moreMembers",
            },
          ])
          .then(function ({ roleInfo, moreMembers }) {
            let newMember;
            if (role === "Engineer") {
              newMember = new Engineer(name, id, email, roleInfo);
            } else if (role === "Intern") {
              newMember = new Intern(name, id, email, roleInfo);
            } else {
              newMember = new Manager(name, id, email, roleInfo);
            }
            employees.push(newMember);
            addHtml(newMember).then(function () {
              if (moreMembers === "yes") {
                addMember();
              } else {
                finishHtml();
              }
            });
          });
      });
  }
  // END Prompts for Input
  
  // Creating HTML document ./dist/team.html
  function startHtml() {
    const html = `<!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <meta http-equiv="X-UA-Compatible" content="ie=edge">
          <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
          <script src="https://kit.fontawesome.com/c502137733.js"></script>
          <title>Teamwork Makes the Dream Work ;)</title>
      </head>
      <body>
          <nav class="navbar navbar-dark bg-dark mb-5">
              <span class="navbar-brand mb-0 h1 w-100 text-center"><h2>Members</h2></span>
          </nav>
          <div class="container">
              <div class="row">`;
    fs.writeFile("./dist/team.html", html, function (err) {
      if (err) {
        console.log(err);
      }
    });
    //   console.log("start");
  }
  
  function addHtml(member) {
    return new Promise(function (resolve, reject) {
      const name = member.getName();
      const role = member.getRole();
      const id = member.getId();
      const email = member.getEmail();
      let data = "";
      if (role === "Engineer") {
        const gitHub = member.getGithub();
        data = `<div class="col-6">
              <div class="card mx-auto mb-3" style="width: 18rem">
              <h5 class="card-header">${name}<br /><br /><i class="fas fa-glasses mr-2"></i>Engineer</h5>
              <ul class="list-group list-group-flush">
                  <li class="list-group-item">ID: ${id}</li>
                  <li class="list-group-item">Email Address: <a href="mailto:${email}"
                  >${email}</a
                >
              </li>
                  <li class="list-group-item">GitHub: ${gitHub}<a
                  href="https://github.com/${gitHub}"
                  target="_blank"
                  rel="noopener noreferrer"
                  >${gitHub}</a
                >
              </li>
              </ul>
              </div>
          </div>`;
      } else if (role === "Intern") {
        const school = member.getSchool();
        data = `<div class="col-6">
              <div class="card mx-auto mb-3" style="width: 18rem">
              <h5 class="card-header">${name}<br /><br /><i class="fas fa-user-graduate mr-2"></i>Intern</h5>
              <ul class="list-group list-group-flush">
                  <li class="list-group-item">ID: ${id}</li>
                  <li class="list-group-item">Email Address: <a href="mailto:${email}"
                  >${email}</a
                >
              </li>
                  <li class="list-group-item">School: ${school}</li>
              </ul>
              </div>
          </div>`;
      } else {
        const officePhone = member.getOfficeNumber();
        data = `<div class="col-6">
              <div class="card mx-auto mb-3" style="width: 18rem">
              <h5 class="card-header">${name}<br /><br /><i class="fas fa-mug-hot mr-2"></i>Manager</h5>
              <ul class="list-group list-group-flush">
                  <li class="list-group-item">ID: ${id}</li>
                  <li class="list-group-item">Email Address: <a href="mailto:${email}"
                  >${email}</a
                >
              </li>
                  <li class="list-group-item">Office Phone: ${officePhone}</li>
              </ul>
              </div>
          </div>`;
      }
      // console.log("adding team member");
      fs.appendFile("./dist/team.html", data, function (err) {
        if (err) {
          return reject(err);
        }
        return resolve();
      });
    });
  }
  
  function finishHtml() {
    const html = ` </div>
      </div>
      
  </body>
  </html>`;
  
    fs.appendFile("./dist/team.html", html, function (err) {
      if (err) {
        console.log(err);
      }
    });
    console.log("html ready!");
  }
  
  initApp();
  