This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
manageTeam.js
63 lines (59 loc) · 1.74 KB
/
manageTeam.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
const inquirer = require("inquirer");
const main = require("./main");
const output = require("./output");
const users = require("./users");
const team = require("./team");
const projects = require("./projects");
const Choices = {
GetTeamMembers: "Get my team members",
AddTeamMember: "Add a team member",
RemoveTeamMember: "Remove a team member",
ProjectMenu: "Return to project",
MainMenu: "Return to main menu",
LogOut: "Log out / Quit",
};
async function manageTeamMenu(partition) {
const projectPartition = partition;
try {
const answers = await inquirer.prompt({
type: "rawlist",
name: "manageTeamMenu",
message: "What would you like to do?",
choices: [...Object.values(Choices), new inquirer.Separator()],
});
switch (answers.manageTeamMenu) {
case Choices.GetTeamMembers: {
await team.getTeamMembers();
return manageTeamMenu(projectPartition);
}
case Choices.AddTeamMember: {
await team.addTeamMember();
return manageTeamMenu();
}
case Choices.RemoveTeamMember: {
await team.removeTeamMember();
return manageTeamMenu(projectPartition);
}
case Choices.ProjectMenu: {
return projects.projectMenu(projectPartition);
}
case Choices.MainMenu: {
return main.mainMenu();
}
case Choices.LogOut: {
const loggedOut = await users.logOut();
if (!loggedOut) {
output.error("Error logging out");
} else output.result("You have been logged out. Use Ctrl-C to quit.");
return;
}
default: {
return manageTeamMenu();
}
}
} catch (err) {
output.error(err.message);
return;
}
};
exports.manageTeamMenu = manageTeamMenu;