Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ComplaintBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ bool ComplaintBox::loginUser(bool isAdmin) {

if (success) {
cout << GREEN << "Login successful!\n" << RESET;
string fetchSql = "SELECT category, subCategory, message FROM complaints WHERE username = '" + uname + "';";
cout << "\nYour Complaints:\n";
bool found = false;

sqlite3_exec(db, fetchSql.c_str(), [](void* foundPtr, int argc, char** argv, char** colName) -> int {
*(bool*)foundPtr = true;
cout << "\nCategory: " << argv[0]
<< "\nSub-category: " << argv[1]
<< "\nMessage: " << argv[2] << "\n";
return 0;
}, &found, &errMsg);

if (!found) {
cout << "No complaints found.\n";
}
return true;
} else {
cout << RED << "Invalid credentials!\n" << RESET;
Expand Down
Binary file added complaintbox
Binary file not shown.
36 changes: 25 additions & 11 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,31 @@ int main() {
int choiceNum = 0;

do {
cout << BOLDVIOLET << "\n==== Complaint Box Menu ====\n" << RESET;
cout << CYAN << "1. Register User\n"
<< "2. Register Admin\n"
<< "3. User Login\n"
<< "4. Admin Login\n"
<< "5. File Complaint\n"
<< "6. Export Complaints to CSV\n"
<< "7. Search Complaints\n"
<< "8. Exit\n" << RESET;

cout << WHITE << "Choice: " << RESET;
// Double-line box top
cout << BOLDVIOLET << u8"╔════════════════════════════════════════════════════╗\n";
cout << u8"║ 🗂️ COMPLAINT BOX MENU ║\n";
cout << u8"╠════════════════════════════════════════════════════╣\n";

// Menu options with dividers
cout << u8"║ 1. Register as User ║\n";
cout << u8"╟────────────────────────────────────────────────────╢\n";
cout << u8"║ 2. Register as Admin ║\n";
cout << u8"╟────────────────────────────────────────────────────╢\n";
cout << u8"║ 3. Login as User ║\n";
cout << u8"╟────────────────────────────────────────────────────╢\n";
cout << u8"║ 4. Login as Admin ║\n";
cout << u8"╟────────────────────────────────────────────────────╢\n";
cout << u8"║ 5. File a Complaint ║\n";
cout << u8"╟────────────────────────────────────────────────────╢\n";
cout << u8"║ 6. Export Complaints to CSV ║\n";
cout << u8"╟────────────────────────────────────────────────────╢\n";
cout << u8"║ 7. Search Complaints ║\n";
cout << u8"╟────────────────────────────────────────────────────╢\n";
cout << u8"║ 8. Exit ║\n";
cout << u8"╚════════════════════════════════════════════════════╝\n" << RESET;

// Input prompt
cout << WHITE << "\n👉 Enter your choice (1-8): " << RESET;
cin >> choice;

// <<<<<<< Fix/crash-main-menu
Expand Down