-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
182 lines (171 loc) · 4.91 KB
/
app.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
const Manager = require("./lib/Manager");
const Engineer = require("./lib/Engineer");
const Intern = require("./lib/Intern");
const inquirer = require("inquirer");
const path = require("path");
const fs = require("fs");
const OUTPUT_DIR = path.resolve(__dirname, "output");
const outputPath = path.join(OUTPUT_DIR, "team.html");
const render = require("./lib/htmlRenderer");
const EmployeeQuestions = [];
const employees = [];
// Write code to use inquirer to gather information about the development team members,
// and to create objects for each team member (using the correct classes as blueprints!)
//Manager Questions
function managerPrompt() {
inquirer
.prompt([
{
type: "input",
name: "name",
message: "What is the employee's name?",
},
{
type: "input",
name: "id",
message: "What is the employee's id?",
},
{
type: "input",
name: "email",
message: "What is the employee's email?",
},
{
type: "input",
name: "officeNumber",
message: "What is the employee's office number?",
},
])
.then(function (managerAnswers) {
console.log(managerAnswers);
const manager = new Manager(
managerAnswers.name,
managerAnswers.id,
managerAnswers.email,
managerAnswers.officeNumber
);
employees.push(manager);
addNewEmp();
});
}
// Engineer Questions
function engineerPrompt() {
inquirer
.prompt([
{
type: "input",
name: "name",
message: "What is the employee's name?",
},
{
type: "input",
name: "id",
message: "What is the employee's id?",
},
{
type: "input",
name: "email",
message: "What is the employee's email?",
},
{
type: "input",
name: "github",
message: "What is the employee's Github account?",
},
])
.then(function (engineerAnswers) {
console.log(engineerAnswers);
const engineer = new Engineer(
engineerAnswers.name,
engineerAnswers.id,
engineerAnswers.email,
engineerAnswers.github
);
employees.push(engineer);
addNewEmp();
});
}
// Intern Questions
function internPrompt() {
inquirer
.prompt([
{
type: "input",
name: "name",
message: "What is the employee's name?",
},
{
type: "input",
name: "id",
message: "What is the employee's id?",
},
{
type: "input",
name: "email",
message: "What is the employee's email?",
},
{
type: "input",
name: "school",
message: "What school did the employee attend?",
},
])
.then(function (internAnswers) {
console.log(internAnswers);
const intern = new Intern(
internAnswers.name,
internAnswers.id,
internAnswers.email,
internAnswers.school
);
employees.push(intern);
addNewEmp();
});
}
// Adding a new employee
function addNewEmp() {
inquirer
.prompt([
{
type: "list",
name: "selection",
message: "Which type of team member would you like to add?",
choices: ["Manager", "Engineer", "Intern", "Build my team."],
},
])
.then(function (answers) {
switch (answers.selection) {
case "Manager":
managerPrompt();
break;
case "Engineer":
engineerPrompt();
break;
case "Intern":
internPrompt();
break;
default:
employeeTeam();
}
});
}
// After the user has input all employees desired, call the `render` function (required
// above) and pass in an array containing all employee objects; the `render` function will
// generate and return a block of HTML including templated divs for each employee!
function employeeTeam() {
return fs.writeFileSync(outputPath, render(employees));
}
addNewEmp();
// After you have your html, you're now ready to create an HTML file using the HTML
// returned from the `render` function. Now write it to a file named `team.html` in the
// `output` folder. You can use the variable `outputPath` above target this location.
// Hint: you may need to check if the `output` folder exists and create it if it
// does not.
// HINT: each employee type (manager, engineer, or intern) has slightly different
// information; write your code to ask different questions via inquirer depending on
// employee type.
// HINT: make sure to build out your classes first! Remember that your Manager, Engineer,
// and Intern classes should all extend from a class named Employee; see the directions
// for further information. Be sure to test out each class and verify it generates an
// object with the correct structure and methods. This structure will be crucial in order
// for the provided `render` function to work! ```