From 1179f92849af361bd9e7f88d012683f3f1e8b30a Mon Sep 17 00:00:00 2001 From: Avinash Rajesh Date: Wed, 17 Jun 2026 14:20:20 +0530 Subject: [PATCH] Notification Dialog Does Not Indicate Intended Recipient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Updated AdminMenu::handleNotificationEvent, CustomerMenu::handleNotificationEvent, and TechnicianMenu::handleNotificationEvent to retrieve the authenticated user and pass their name to displayNewNotification(). - Modified Menu::handleAccountDisabledEvent to append the authenticated user’s name to the message box title when available. - Refactored displayNewNotification() in MenuHelper.h to accept the authenticated user’s name as an additional parameter. - Enhanced notification display logic to append the user’s name to the notification title when present. - Added null checks to ensure safe handling when no authenticated user exists. FIxes #2080 --- .../views/AdminMenu.cpp | 8 ++++++- .../views/CustomerMenu.cpp | 8 ++++++- .../views/Menu.cpp | 8 ++++++- .../views/MenuHelper.h | 23 +++++++++++++------ .../views/TechnicianMenu.cpp | 8 ++++++- 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 68ec663..71882ba 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -163,7 +163,13 @@ Return type: void void AdminMenu::handleNotificationEvent() { auto notifications = m_controller.getNotifications(); - displayNewNotification(notifications); + const User* authenticatedUser = m_controller.getAuthenticatedUser(); + std::string name; + if (authenticatedUser) + { + name = authenticatedUser->getName(); + } + displayNewNotification(notifications, name); } /* diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index 3932fba..a9d7990 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -134,7 +134,13 @@ Return type: void void CustomerMenu::handleNotificationEvent() { auto notifications = m_controller.getNotifications(); - displayNewNotification(notifications); + const User* authenticatedUser = m_controller.getAuthenticatedUser(); + std::string name; + if (authenticatedUser) + { + name = authenticatedUser->getName(); + } + displayNewNotification(notifications, name); } /* diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.cpp index 2573c0e..e5881ff 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.cpp @@ -133,10 +133,16 @@ Return type: void void Menu::handleAccountDisabledEvent() { m_isMenuActive.store(false); + const User* authenticatedUser = m_controller.getAuthenticatedUser(); + std::string messageTitle = "Account Disabled"; + if (authenticatedUser) + { + messageTitle += " - " + authenticatedUser->getName(); + } MessageBoxA( GetConsoleWindow(), "Your account has been disabled.", - "Account Disabled", + messageTitle.c_str(), MB_OK | MB_ICONWARNING | MB_SETFOREGROUND | diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h index 0d0f695..a92bead 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -1415,9 +1415,10 @@ Description: Displays the most recent notification from the supplied notification collection. Parameter: util::Vector notifications - collection of notifications + const std::string& - The name of the user currently authenticated with the system Return type: void */ -inline void displayNewNotification(util::Vector notifications) +inline void displayNewNotification(util::Vector notifications, const std::string& name) { const Notification* notification = nullptr; size_t numberOfNotifications = notifications.getSize(); @@ -1435,10 +1436,18 @@ inline void displayNewNotification(util::Vector notificatio } } } - MessageBoxA( - GetConsoleWindow(), - notification->getMessage().c_str(), - notification->getTitle().c_str(), - MB_OK | - MB_ICONINFORMATION); + if (notification) + { + std::string messageTitle = notification->getTitle(); + if (!name.empty()) + { + messageTitle += " - " + name; + } + MessageBoxA( + GetConsoleWindow(), + notification->getMessage().c_str(), + messageTitle.c_str(), + MB_OK | + MB_ICONINFORMATION); + } } \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp index 4b090d8..ee4576c 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp @@ -108,7 +108,13 @@ Return type: void void TechnicianMenu::handleNotificationEvent() { auto notifications = m_controller.getNotifications(); - displayNewNotification(notifications); + const User* authenticatedUser = m_controller.getAuthenticatedUser(); + std::string name; + if (authenticatedUser) + { + name = authenticatedUser->getName(); + } + displayNewNotification(notifications, name); } /*