Skip to content

#5 Show User's Own Complaints #5 (Added complaint viewing for loggedin user) #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
@@ -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;
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
@@ -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