-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
116 lines (105 loc) · 3.7 KB
/
Copy pathmain.cpp
File metadata and controls
116 lines (105 loc) · 3.7 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
#include "AuthManager.hpp"
#include "NoteManager.hpp"
#include <iostream>
#include <filesystem>
using namespace std;
void showDashboard(const string& username) {
string userFolder = "userdata/" + username;
filesystem::create_directories(userFolder);
NoteManager noteManager(userFolder);
int choice;
do {
cout << "\n==== DASHBOARD ====\n";
cout << "Welcome, " << username << "!\n";
cout << "-------------------\n";
cout << "-------------------\n";
cout << "1. Add New Note\n";
cout << "-------------------\n";
cout << "2. View Your Notes\n";
cout << "-------------------\n";
cout << "3. Mark Favorite Note\n";
cout << "-------------------\n";
cout << "4. View Favorite Notes\n";
cout << "-------------------\n";
cout << "5. View To-Do Lists\n";
cout << "-------------------\n";
cout << "6. View Pins\n";
cout << "-------------------\n";
cout << "7. Logout\n";
cout << "-------------------\n";
cout << "Choose option: ";
cin >> choice;
cin.ignore();
switch (choice) {
case 1:
noteManager.addNote();
break;
case 2:
noteManager.viewNotes();
break;
case 3:
noteManager.markFavorite();
break;
case 4:
noteManager.viewFavorites();
break;
case 5:
noteManager.viewToDoLists();
break;
case 6:
noteManager.viewPins();
break;
case 7:
cout << "Logging out...\n";
break;
default:
cout << "Invalid option.\n";
}
} while (choice != 7);
}
int main() {
AuthManager auth;
int choice;
bool validInput;
cout << "\n";
cout << " .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n";
cout << " | |\n";
cout << " | W E L C O M E |\n";
cout << " | T O |\n";
cout << " | M A D |\n";
cout << " | (Minds and Dots) |\n";
cout << " | |\n";
cout << " .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n";
do {
cout << " .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n";
cout << " | 1. Login 2. Signup |\n";
cout << " | 3. Exit |\n";
cout << " .-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.\n";
cout << "\n Choose option: ";
validInput = true; // assume input will be valid
if (!(cin >> choice)) {
// Input was not an integer
cin.clear(); // clear error flags
cin.ignore(numeric_limits<streamsize>::max(), '\n'); // discard bad input
cout << "Invalid input. Please enter a number (1-3).\n";
validInput = false;
} else if (choice < 1 || choice > 3) {
cout << "Invalid option. Please choose between 1-3.\n";
validInput = false;
}
if (validInput) {
cin.ignore(); // ignore the newline character
if (choice == 1) {
string username;
if (auth.login(username)) {
showDashboard(username);
}
} else if (choice == 2) {
auth.signup();
} else if (choice == 3) {
cout << "Goodbye!\n";
}
}
} while (choice != 3 || !validInput);
return 0;
}