-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
135 lines (108 loc) · 2.87 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
const inquirer = require("inquirer");
const fs = require("fs");
const generateHTML = require("./src/page-template");
const Employee = require("./lib/Employee");
const Engineer = require("./lib/Engineer");
const Intern = require("./lib/Intern");
const Manager = require("./lib/Manager");
const newStaffMemberData = [];
const questions = async () => {
const answers = await inquirer
.prompt([
{
type: "input",
message: "What is your name?",
name: "name",
},
{
type: "input",
message: "What is your ID number?",
name: "id",
},
{
type: "input",
message: "What is your email?",
name: "email",
},
{
type: "list",
message: "What is your role?",
name: "role",
choices: ["Engineer", "Intern", "Manager"],
},
])
if (answers.role === "Manager") {
const managerAns = await inquirer
.prompt([
{
type: "input",
message: "What is your office number?",
name: "officeNumber",
},
])
const newManager = new Manager (
answers.name,
answers.id,
answers.email,
managerAns.officeNumber
);
newStaffMemberData.push(newManager);
} else if (answers.role === "Engineer") {
const githubAns = await inquirer
.prompt([
{
type: "input",
message: "What is your GitHub user name?",
name: "github",
}
])
const newEngineer = new Engineer (
answers.name,
answers.id,
answers.email,
githubAns.github
);
newStaffMemberData.push(newEngineer);
} else if (answers.role === "Intern") {
const internAns = await inquirer
.prompt([
{
type: "input",
message: "What university did you attend?",
name: "school",
},
])
const newIntern = new Intern(
answers.name,
answers.id,
answers.email,
internAns.school
);
newStaffMemberData.push(newIntern);
}
};
async function prompQuestions() {
await questions()
const addMemberAns = await inquirer
.prompt([
{
name:'addMember',
type: 'list',
choices: ['Add a new member', 'Create team'],
message: "What would you like to do next?"
}
])
if (addMemberAns.addMember === 'Add a new member') {
return prompQuestions()
}
return createTeam();
}
prompQuestions();
function createTeam() {
console.log("new guy", newStaffMemberData)
fs.writeFileSync(
"./docs/index.html",
generateHTML(newStaffMemberData),
"utf-8"
);
}