Merge branch 'feature-notification-management' into feature-1551-1561-1708

This commit is contained in:
2026-05-25 11:48:25 +05:30
40 changed files with 1983 additions and 58 deletions
@@ -1,7 +1,27 @@
/*
File: AdminMenu.cpp
Description: Implements the AdminMenu class which provides the administrators console interface
in the Vehicle Service Management System. Handles menu display, user input, and
admin-specific operations such as inventory management, technician management,
service creation, combo package management, job assignment, and notifications.
Author: Trenser
Date: 19-May-2026
*/
#include "AdminMenu.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "MenuHelper.h"
/*
Function: showMenu
Description: Displays the admin menu in a loop until the user chooses to logout.
Handles exceptions and ensures smooth user interaction.
Parameters:
- None
Returns:
- void
*/
void AdminMenu::showMenu()
{
bool isMenuActive = true;
@@ -84,6 +104,15 @@ void AdminMenu::removeComboPackage()
{
}
/*
Function: viewNotifications
Description: Displays notifications for the admin and allows deletion of notifications.
Parameters:
- None
Returns:
- void
*/
void AdminMenu::viewNotifications()
{
viewAndDeleteNotification(m_controller);
}
@@ -1,3 +1,12 @@
/*
File: AdminMenu.h
Description: Declares the AdminMenu class which provides the administrative console menu in the Vehicle Service Management System.
Supports operations such as inventory management, job assignment, service creation/removal, technician management,
combo package handling, notification viewing, and account management functions like logout and password change.
Author: Trenser
Date: 19-May-2026
*/
#pragma once
#include "Controller.h"
@@ -7,17 +7,17 @@ Author: Trenser
Date:19-May-2026
*/
#include <iomanip>
#include "CustomerMenu.h"
#include "Service.h"
#include "InventoryItem.h"
#include "ComboPackage.h"
#include "Service.h"
#include "CustomerMenu.h"
#include "InputHelper.h"
#include "InventoryItem.h"
#include "Map.h"
#include "MenuHelper.h"
#include "OutputHelper.h"
#include "Service.h"
#include "Utility.h"
#include "Validator.h"
#include "Vector.h"
#include "Utility.h"
#include "Map.h"
/*
Function: showMenu
@@ -344,10 +344,66 @@ void CustomerMenu::viewInvoices()
{
}
/*
Function: viewNotifications
Description: Displays notifications for the customer and allows deletion of notifications.
Parameters:
- None
Returns:
- void
*/
void CustomerMenu::viewNotifications()
{
viewAndDeleteNotification(m_controller);
}
/*
Function: getNotificationPreference (static helper)
Description: Helper function to configure notification preferences for a specific service.
Parameters:
- serviceName: Name of the service for which notifications are being configured.
Returns:
- bool: True if notifications are enabled, False if disabled.
*/
static bool getNotificationPreference(const std::string& serviceName)
{
int choice;
while (true)
{
util::clear();
std::cout << " Configure Notification Preferences\n";
std::cout << "\n" << serviceName << " Notifications\n";
std::cout << "1. Enable Notifications\n";
std::cout << "2. Disable Notifications\n";
std::cout << "Enter your choice: ";
util::read(choice);
if (choice == 1)
{
return true;
}
if (choice == 2)
{
return false;
}
std::cout << "\nInvalid choice. Please enter 1 or 2.\n";
util::pressEnter();
}
}
/*
Function: configureNotifications
Description: Allows the customer to configure notification preferences for payment and service management.
Parameters:
- None
Returns:
- void
*/
void CustomerMenu::configureNotifications()
{
}
bool paymentServiceNotifications = getNotificationPreference("Payment Management Service");
bool serviceManagementNotifications = getNotificationPreference("Service Management Service");
m_controller.configureNotifications(paymentServiceNotifications, serviceManagementNotifications);
util::clear();
std::cout << "Notification preferences updated successfully.\n";
util::pressEnter();
}
@@ -4,15 +4,18 @@ Description: Header file declaring the MenuHelper class, which provides
utility functions for menu-driven operations such as
notification selection and display.
Author: Trenser
Date:19-May-2026
Date: 21-May-2026
*/
#pragma once
#include <string>
#include <iomanip>
#include "Notification.h"
#include "Map.h"
#include <string>
#include "Controller.h"
#include "InputHelper.h"
#include "Map.h"
#include "Notification.h"
#include "OutputHelper.h"
#include "Vector.h"
/*
Function: selectNotification
@@ -29,6 +32,7 @@ inline const Notification* selectNotification(const util::Vector<const Notificat
std::cout << "No notifications available." << std::endl;
return nullptr;
}
util::Map<int, const Notification*> indexedNotifications;
std::cout << std::left
<< std::setw(6) << "Index"
<< std::setw(15) << "ID"
@@ -36,9 +40,9 @@ inline const Notification* selectNotification(const util::Vector<const Notificat
<< std::setw(25) << "Timestamp"
<< std::endl;
int currentIndex = 1;
for (int iterator = 0; iterator < notifications.getSize(); iterator++)
for (int index = 0; index < notifications.getSize(); index++)
{
const Notification* currentNotification = notifications[iterator];
const Notification* currentNotification = notifications[index];
if (currentNotification)
{
std::cout << std::left
@@ -47,16 +51,64 @@ inline const Notification* selectNotification(const util::Vector<const Notificat
<< std::setw(30) << currentNotification->getTitle()
<< std::setw(25) << currentNotification->getCreatedAt().toString()
<< std::endl;
indexedNotifications.insert(currentIndex, currentNotification);
currentIndex++;
}
}
int selectedIndex;
std::cout << "Select notification: ";
util::read(selectedIndex);
if (selectedIndex < 1 || selectedIndex > notifications.getSize())
if (!indexedNotifications.containsKey(selectedIndex))
{
std::cout << "Invalid selection." << std::endl;
return nullptr;
}
return notifications[selectedIndex - 1];
return indexedNotifications[selectedIndex];
}
/*
Function: displayNotification
Description: Displays detailed information about a single notification, including ID, title, timestamp, and message.
Parameters:
- notification: Pointer to the Notification object to be displayed.
Returns:
- void
*/
inline void displayNotification(const Notification* notification)
{
util::clear();
if (!notification)
{
std::cout << "Notification not found." << std::endl;
return;
}
std::cout << "Notification Details" << std::endl;
std::cout << "ID : " << notification->getId() << std::endl;
std::cout << "Title : " << notification->getTitle() << std::endl;
std::cout << "Timestamp : " << notification->getCreatedAt().toString() << std::endl;
std::cout << "Message : " << notification->getMessage() << std::endl;
}
/*
Function: viewAndDeleteNotification
Description: Allows the user to view a notification and then delete it from the system using the controller.
Parameters:
- controller: Reference to the Controller object used to manage notifications.
Returns:
- void
*/
inline void viewAndDeleteNotification(Controller& controller)
{
util::clear();
auto notifications = controller.getNotifications();
const Notification* selectedNotification = selectNotification(notifications);
if (!selectedNotification)
{
std::cout << "Failed to display notification!";
util::pressEnter();
return;
}
displayNotification(selectedNotification);
controller.deleteNotification(selectedNotification->getId());
util::pressEnter();
}
@@ -1,7 +1,26 @@
/*
File: TechnicianMenu.cpp
Description: Implements the TechnicianMenu class which provides the technicians console interface
in the Vehicle Service Management System. Handles menu display, user input, and
technician-specific operations such as completing jobs and viewing notifications.
Author: Trenser
Date: 19-May-2026
*/
#include "TechnicianMenu.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "MenuHelper.h"
/*
Function: showMenu
Description: Displays the technician menu in a loop until the user chooses to logout.
Handles exceptions and ensures smooth user interaction.
Parameters:
- None
Returns:
- void
*/
void TechnicianMenu::showMenu()
{
bool isMenuActive = true;
@@ -35,6 +54,15 @@ void TechnicianMenu::completeJob()
{
}
/*
Function: viewNotifications
Description: Displays notifications for the technician and allows deletion of notifications.
Parameters:
- None
Returns:
- void
*/
void TechnicianMenu::viewNotifications()
{
viewAndDeleteNotification(m_controller);
}
@@ -1,3 +1,11 @@
/*
File: TechnicianMenu.h
Description: Declares the TechnicianMenu class which provides the technician-facing console menu in the Vehicle Service Management System.
Supports operations such as viewing assigned jobs, completing jobs, and managing notifications.
Author: Trenser
Date: 19-May-2026
*/
#pragma once
#include "Controller.h"
@@ -22,6 +22,7 @@ Return type: void
*/
void UserInterface::run()
{
m_controller.runSystemChecks();
bool isMenuActive = true;
while (isMenuActive)
{