{"size": 3416, "ext": "js", "max_stars_repo_path": "Develop/app.js", "max_stars_repo_name": "reinerbonsol/Team-Profile-Generator-Hw-10", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Develop/app.js", "max_issues_repo_name": "reinerbonsol/Team-Profile-Generator-Hw-10", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Develop/app.js", "max_forks_repo_name": "reinerbonsol/Team-Profile-Generator-Hw-10", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.2264150943, "max_line_length": 93, "alphanum_fraction": 0.4262295082}
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 render = require("./lib/htmlRenderer");
const OUTPUT_DIR = path.resolve(__dirname, "output");
const outputPath = path.join(OUTPUT_DIR, "team.html");

const employees = [];

function addMember() {
    inquirer.prompt([{
        type: "input",
        message: "Enter the name associated with team member",
        name: "name"
    },
    {
        type: "list",
        message: "Select role associated with team member",
        name: "role",
        choices: [
            "Intern",
            "Engineer",
            "Manager"
        ],

    },
    {
        type: "input",
        message: "Enter the ID associated with team member",
        name: "id"
    },
    {
        type: "input",
        message: "Enter the email associated with team member",
        name: "email"
    }])
        .then(function ({ name, role, id, email }) {
            let roleReturn = "";
            if (role === "Intern") {
                roleReturn = "school name";
            } else if (role === "Engineer") {
                roleReturn = "Github username";
            } else {
                roleReturn = "office phone number";
            }
            inquirer.prompt([{
                type: "input",
                message: `Enter ${roleReturn} associated with team member`,
                name: "roleReturn"
            },
            {
                type: "list",
                message: "Would you like to add more team members?",
                name: "addTeamMember",
                choices: [
                    "yes",
                    "no"
                ],

            }])
                .then(function ({ roleReturn, addTeamMember }) {
                    let newMember;
                    if (role === "Intern") {
                        newMember = new Intern(name, id, email, roleReturn);
                    } else if (role === "Engineer") {
                        newMember = new Engineer(name, id, email, roleReturn);
                    } else {
                        newMember = new Manager(name, id, email, roleReturn);
                    }
                    employees.push(newMember);
                    console.log(employees);
                        if (addTeamMember === "yes") {
                            addMember();
                        } else{
                            buildSquad();
                            console.log('Team Members added to team.html');
                        };
                        // else {
                        //     somekindoffunction();
                        //     console.log("team members created");
                        //     // fs.appendFile(outputPath, function (err) {
                        //     //     if (err) {
                        //     //         console.log(err);
                        //     //     };
                        //     // });
                        //     // console.log("Team Members added and created in team.html");
                        // }
                });
        });
};



function buildSquad() {
    if(!fs.existsSync(OUTPUT_DIR)){
        fs.mkdirSync(OUTPUT_DIR)
    };
    fs.writeFileSync(outputPath, render(employees));

}

addMember();
