-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-start.js
More file actions
141 lines (122 loc) · 6.17 KB
/
Copy path01-start.js
File metadata and controls
141 lines (122 loc) · 6.17 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
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
import { question, keyInYNStrict, questionInt } from "readline-sync";
import recordsPage from "./11-records.js";
import invoicePage from "./12-invoice-management.js";
import financialPage from "./13-financial-reporting.js";
import paymentPage from "./14-payment.js";
import backupPage from "./15-backup.js";
let users = [
{ username: "admin", password: "1234" },
{ username: "user", password: "1234" },
];
//https://dev.to/lakatos88/ascii-themes-node-js-cli-interface-to-generate-themed-ascii-art-4ck8
startApp();
function startApp() {
console.clear();
console.log(
"=================================================================================="
);
console.log(`
█████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ██╗████████╗██╗███╗ ██╗ ██████╗
██╔══██╗██╔════╝██╔════╝██╔═══██╗██║ ██║████╗ ██║╚══██╔══╝██║████╗ ██║██╔════╝
███████║██║ ██║ ██║ ██║██║ ██║██╔██╗ ██║ ██║ ██║██╔██╗ ██║██║ ███╗
██╔══██║██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██║ ██║██║╚██╗██║██║ ██║
██║ ██║╚██████╗╚██████╗╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ██║██║ ╚████║╚██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ `);
console.log(
"=================================================================================="
);
const username = question("Enter your username: ");
// let user = users.filter((user) => user.username === username);
// user = user[0];
let user = users.find((user) => user.username === username);
if (!user) {
return console.log("Username not found. Please try again.");
}
const password = question("Enter your password: ");
if (user.password !== password) {
return console.log("Incorrect password. Please try again.");
}
if (username === "admin") {
adminPanel();
} else {
accountingPage();
}
}
function adminPanel() {
console.clear();
console.log("Welcome Admin!");
const newUsername = question("Enter new username for user: ");
const newPassword = question("Enter new password for user: ");
users.push({ username: newUsername, password: newPassword });
console.log(`User ${newUsername} has been created successfully!`);
const continueApp = keyInYNStrict("Do you want to return to the start menu?");
if (continueApp) {
startApp();
} else {
console.log("Exiting the application...");
return;
}
}
export function accountingPage() {
console.clear();
console.log(
"========================================================================================"
);
console.log(`
█████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ██╗████████╗██╗███╗ ██╗ ██████╗
██╔══██╗██╔════╝██╔════╝██╔═══██╗██║ ██║████╗ ██║╚══██╔══╝██║████╗ ██║██╔════╝
███████║██║ ██║ ██║ ██║██║ ██║██╔██╗ ██║ ██║ ██║██╔██╗ ██║██║ ███╗
██╔══██║██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██║ ██║██║╚██╗██║██║ ██║
██║ ██║╚██████╗╚██████╗╚██████╔╝╚██████╔╝██║ ╚████║ ██║ ██║██║ ╚████║╚██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ `);
console.log(
"========================================================================================"
);
console.log(
"|| Main Menu: ||"
);
console.log(
"|| 1. Income and Expense Records ||"
);
console.log(
"|| 2. Invoice Management ||"
);
console.log(
"|| 3. Financial Reporting ||"
);
console.log(
"|| 4. Payment ||"
);
console.log(
"|| 5. Data Backup ||"
);
console.log(
"|| 6. Exit Application ||"
);
console.log(
"========================================================================================"
);
const choice = questionInt("Enter a choice (1-6): ");
if (choice === 1) {
console.clear();
recordsPage();
} else if (choice === 2) {
console.clear();
invoicePage();
} else if (choice === 3) {
console.clear();
financialPage();
} else if (choice === 4) {
console.clear();
paymentPage();
} else if (choice === 5) {
console.clear();
backupPage();
} else if (choice === 6) {
console.clear();
console.log("Application exited.");
return;
} else {
console.log("Invalid choice. Try again.");
}
}