-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.js
More file actions
65 lines (55 loc) · 1.49 KB
/
dashboard.js
File metadata and controls
65 lines (55 loc) · 1.49 KB
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
// Require dependencies
const inquirer = require("inquirer");
const colors = require('colors');
colors.setTheme({
input: 'blue',
verbose: 'cyan',
prompt: 'white',
info: 'green',
data: 'grey',
warn: 'yellow',
error: 'red',
silly: 'rainbow'
});
// Require connection
const mysql = require("mysql");
const config = require('./config/config.js');
// Require Customer, Manager, and Supervisor files
const Customer = require('./app/bamazonCustomer.js');
const Manager = require('./app/bamazonManager.js');
const Supervisor = require('./app/bamazonSupervisor.js');
const connection = mysql.createConnection(config);
connection.connect((err) => {
if (err) { throw err }
else { displayDashboard() }
});
// Display Dashboard
function displayDashboard() {
inquirer
.prompt([
{
type: "list",
message: "Please select desired view:",
choices: ['Customer','Manager','Supervisor','Exit'],
name: "command"
}
]).then(function (answer) {
start(answer.command);
})
}
function start(command) {
switch (command) {
case 'Customer':
Customer.startCustomerView();
break;
case 'Manager':
Manager.startManagerView();
break;
case 'Supervisor':
Supervisor.startSupervisorView();
break;
case 'Exit':
connection.end();
break;
}
}