-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
113 lines (106 loc) · 4.55 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
const inquirer = require('inquirer');
const chalk = require('chalk')
const mysql = require('mysql2');
const cTable = require('console.table');
const showAllDep = require('./js/departmentFunc');
const showAllRoles = require('./js/rolesFunc');
const showAllEmployees = require('./js/employeesFunc');
const addDepartment = require('./js/addDep');
const { addRole } = require('./js/addRole');
const { addEmployee } = require('./js/addEmployee');
const { updateEmployee }= require('./js/updateEmployee');
const { updateManager } = require('./js/updateManager');
const viewEmpByMan = require('./js/viewEmpByMan');
const viewEmpByDep = require('./js/viewEmpByDep');
const { deleteDepartment, deleteRole, deleteEmployee } = require('./js/delete');
const getDepBudget = require('./js/depBudget');
const db = require('./db/connection');
//welcome users with init function
function init() {
console.log(chalk.cyan(`
███████ ███ ███ ██████ ██ ██████ ██ ██ ███████ ███████ ███ ███ █████ ███ ██ █████ ██████ ███████ ██████
██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██
█████ ██ ████ ██ ██████ ██ ██ ██ ████ █████ █████ ██ ████ ██ ███████ ██ ██ ██ ███████ ██ ███ █████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ██ ██ ██ ███████ ██████ ██ ███████ ███████ ██ ██ ██ ██ ██ ████ ██ ██ ██████ ███████ ██ ██
`));
promptUser();
}
//promptUser function that will be called again after the selected choice functions
module.exports = promptUser = async () => {
const data = await inquirer
.prompt (
{
type: 'list',
name: 'action',
message: 'What would you like to do?',
choices: [
'View all departments',
'View all roles',
'View all employees',
'Add a department',
'Add a role',
'Add an employee',
'Update an employee',
'Update employee manager',
'View employees by manager',
'View employees by department',
'Delete department',
'Delete role',
'Delete employee',
'View department budget',
'Exit app'
]})
switch(data.action) {
case "View all departments" :
showAllDep();
break;
case "View all roles":
showAllRoles();
break;
case "View all employees":
showAllEmployees();
break;
case "Add a department":
addDepartment();
break;
case "Add a role":
addRole();
break;
case 'Add an employee':
addEmployee();
break;
case 'Update an employee':
updateEmployee();
break;
case 'Update employee manager':
updateManager();
break;
case 'View employees by manager':
viewEmpByMan();
break;
case 'View employees by department':
viewEmpByDep();
break;
case 'Delete department':
deleteDepartment();
break;
case 'Delete role':
deleteRole();
break;
case 'Delete employee':
deleteEmployee();
break;
case 'View department budget':
getDepBudget();
break;
case 'Exit app':
console.log(chalk.cyan(`
========================
====Exiting App=========
========================`));
db.end();
break;
}
}
init();