Compare commits

..

2 Commits

Author SHA1 Message Date
joelthomastrenser 1e8fd2829f Fix PR review comments and refactor menu helper logic
Changes:
- Added name parameter to createTechnician for consistency
- Added function headers for notification-related methods in InventoryManagementService
- Used variables for notification title and message instead of passing strings directly
- Fixed payment reminder notification message formatting
- Moved common helper functions to MenuHelper.h
- Updated CustomerMenu to use shared helper functions instead of duplicate code
- Added missing includes in MenuHelper.h
- Removed redundant helper code from CustomerMenu.cpp
- Minor formatting and comment cleanup
2026-05-25 15:46:11 +05:30
joelthomastrenser 28e4b17c63 Merge branch 'feature-file-management' into feature-1551-1561-1708 2026-05-25 14:24:21 +05:30
12 changed files with 308 additions and 226 deletions
@@ -55,6 +55,7 @@ Parameter: const std::string& username - customer
const std::string& phone - customers phone number const std::string& phone - customers phone number
Return type: void Return type: void
*/ */
void Controller::createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone) void Controller::createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone)
{ {
m_userManagementService.createUser(username, name, password, email, phone, util::UserType::CUSTOMER); m_userManagementService.createUser(username, name, password, email, phone, util::UserType::CUSTOMER);
@@ -71,7 +72,7 @@ const User* Controller::getAuthenticatedUser()
return m_authenticationManagementService.getAuthenticatedUser(); return m_authenticationManagementService.getAuthenticatedUser();
} }
void Controller::createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone) void Controller::createTechnician(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone)
{ {
} }
@@ -43,7 +43,7 @@ public:
void changePassword(const std::string& newPassword); void changePassword(const std::string& newPassword);
void createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone); void createCustomer(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone);
const User* getAuthenticatedUser(); const User* getAuthenticatedUser();
void createTechnician(const std::string& username, const std::string& password, const std::string& email, const std::string& phone); void createTechnician(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone);
void updateUserDetails(const std::string& email, const std::string& phone); void updateUserDetails(const std::string& email, const std::string& phone);
util::Map<std::string, const Service*> getServices(); util::Map<std::string, const Service*> getServices();
util::Map<std::string, const ComboPackage*> getComboPackages(); util::Map<std::string, const ComboPackage*> getComboPackages();
@@ -42,8 +42,6 @@ public:
const std::string& vehicleNumber, const std::string& vehicleNumber,
const std::string& vehicleBrand, const std::string& vehicleBrand,
const std::string& vehicleModel, const std::string& vehicleModel,
const std::string& assignedTechnicianId,
User* assignedTechnician,
double discountPercentage double discountPercentage
); );
ServiceBooking( ServiceBooking(
@@ -7,6 +7,7 @@ Description: Implements the InventoryManagementService class, which manages inve
Author: Trenser Author: Trenser
Date: 22-May-2026 Date: 22-May-2026
*/ */
#include <stdexcept> #include <stdexcept>
#include "Config.h" #include "Config.h"
#include "Enums.h" #include "Enums.h"
@@ -21,6 +22,14 @@ Date: 22-May-2026
util::Map<std::string, User*> InventoryManagementService::m_observers{}; util::Map<std::string, User*> InventoryManagementService::m_observers{};
/*
Function: attach
Description: Adds a user to the observer list for receiving inventory notifications.
Parameters:
- user: User*, pointer to the user to be attached as an observer
Returns:
- None
*/
void InventoryManagementService::attach(User* user) void InventoryManagementService::attach(User* user)
{ {
if (user) if (user)
@@ -33,6 +42,14 @@ void InventoryManagementService::attach(User* user)
} }
} }
/*
Function: detach
Description: Removes a user from the observer list so they no longer receive inventory notifications.
Parameters:
- user: User*, pointer to the user to be detached from the observer list
Returns:
- None
*/
void InventoryManagementService::detach(User* user) void InventoryManagementService::detach(User* user)
{ {
if (user) if (user)
@@ -45,6 +62,18 @@ void InventoryManagementService::detach(User* user)
} }
} }
/*
Function: sendNotification
Description: Sends a notification to a user if they are subscribed as an observer.
Parameters:
- user: User*, pointer to the user receiving the notification
- title: std::string, title of the notification
- message: std::string, body/content of the notification
Returns:
- None
Throws:
- std::runtime_error if notification creation fails
*/
void InventoryManagementService::sendNotification(User* user, const std::string& title, const std::string& message) void InventoryManagementService::sendNotification(User* user, const std::string& title, const std::string& message)
{ {
if (user) if (user)
@@ -71,20 +100,39 @@ void InventoryManagementService::sendNotification(User* user, const std::string&
} }
} }
/*
Function: sendLowStockAlertsToAdmins (static helper)
Description: Sends low stock alert notifications to all admin users for a given inventory item.
Parameters:
- inventoryManagementService: InventoryManagementService&, service used to send notifications
- inventoryItem: const InventoryItem*, pointer to the low-stock inventory item
- adminUsers: const util::Vector<User*>&, list of admin users to notify
Returns:
- None
*/
static void sendLowStockAlertsToAdmins(InventoryManagementService& inventoryManagementService, const InventoryItem* inventoryItem, const util::Vector<User*>& adminUsers) static void sendLowStockAlertsToAdmins(InventoryManagementService& inventoryManagementService, const InventoryItem* inventoryItem, const util::Vector<User*>& adminUsers)
{ {
int adminUsersSize = adminUsers.getSize(); int adminUsersSize = adminUsers.getSize();
for (int index = 0; index < adminUsersSize; index++) for (int index = 0; index < adminUsersSize; index++)
{ {
std::string title = "Low Stock Alert";
std::string message = "The inventory item with ID " + inventoryItem->getId() + " has very low quantity in the inventory";
inventoryManagementService.sendNotification( inventoryManagementService.sendNotification(
adminUsers[index], adminUsers[index],
"Low Stock Alert", title,
"The inventory item with ID " + inventoryItem->getId() + message
" has very low quantity in the inventory"
); );
} }
} }
/*
Function: sendLowStockAlerts
Description: Sends alerts to user for inventory items with low stock
Parameters:
- None
Returns:
- None
*/
void InventoryManagementService::sendLowStockAlerts() void InventoryManagementService::sendLowStockAlerts()
{ {
auto& inventoryItems = m_dataStore.getInventoryItems(); auto& inventoryItems = m_dataStore.getInventoryItems();
@@ -115,7 +163,6 @@ void InventoryManagementService::sendLowStockAlerts()
} }
} }
/* /*
Function: getObserverIDs Function: getObserverIDs
Description: Retrieves the IDs of all observers currently attached to the Description: Retrieves the IDs of all observers currently attached to the
@@ -19,7 +19,6 @@ Date: 20-May-2026
#include "User.h" #include "User.h"
#include "Utility.h" #include "Utility.h"
util::Map<std::string, User*> PaymentManagementService::m_observers{}; util::Map<std::string, User*> PaymentManagementService::m_observers{};
/* /*
@@ -128,9 +127,9 @@ void PaymentManagementService::sendPaymentReminders()
User* customer = serviceBooking->getCustomer(); User* customer = serviceBooking->getCustomer();
if (customer) if (customer)
{ {
sendNotification(customer, std::string title = "Payment Reminder";
"Payment Reminder", std::string message = "Your payment for Invoice ID " + invoice->getId() + " is still pending. Please complete the payment.";
"Your payment for Invoice ID " + invoice->getId() + " is still pending.Please complete the payment." + invoice->getId()); sendNotification(customer, title, message);
} }
} }
} }
@@ -60,9 +60,9 @@ void ServiceManagementService::purchaseService(const util::Vector<std::string>&
throw std::runtime_error("Failed to create service booking"); throw std::runtime_error("Failed to create service booking");
} }
serviceBookingMap[serviceBooking->getId()] = serviceBooking; serviceBookingMap[serviceBooking->getId()] = serviceBooking;
sendNotification(authenticatedUser, std::string title = "Service Booking succeeded";
"Service Booking succeeded", std::string message = "Your service booking has been successfully placed with ID " + serviceBooking->getId();
"Your service booking has been successfully placed with ID " + serviceBooking->getId()); sendNotification(authenticatedUser, title, message);
} }
/* /*
@@ -99,9 +99,9 @@ void ServiceManagementService::purchaseComboPackage(const std::string& comboPack
throw std::runtime_error("Failed to create combo package service booking"); throw std::runtime_error("Failed to create combo package service booking");
} }
serviceBookingMap[serviceBooking->getId()] = serviceBooking; serviceBookingMap[serviceBooking->getId()] = serviceBooking;
sendNotification(authenticatedUser, std::string title = "Combo Package Service Booking succeeded";
"Combo Package Service Booking succeeded", std::string message = "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId();
"Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId()); sendNotification(authenticatedUser, title, message);
} }
util::Map<std::string, User*> ServiceManagementService::m_observers{}; util::Map<std::string, User*> ServiceManagementService::m_observers{};
@@ -11,6 +11,7 @@ Date: 22-May-2026
#pragma once #pragma once
#include <stdexcept> #include <stdexcept>
#include <string>
#include <fstream> #include <fstream>
#include "Vector.h" #include "Vector.h"
#include "Map.h" #include "Map.h"
@@ -12,6 +12,7 @@ Date:19-May-2026
#include "InventoryItem.h" #include "InventoryItem.h"
#include "NotificationManagementService.h" #include "NotificationManagementService.h"
#include "Service.h" #include "Service.h"
#include "ComboPackage.h"
namespace util namespace util
{ {
@@ -35,14 +36,14 @@ namespace util
} }
/* /*
Function: calculateComboServiceEstimatedCost Function: calculateComboServiceEstimatedCost
Description: Calculates the estimated total cost of a combo package by summing Description: Calculates the estimated total cost of a combo package by summing
the labor and parts costs of all services included in the package. the labor and parts costs of all services included in the package.
Parameter: const ComboPackage* comboPackage - pointer to the combo package object Parameter: const ComboPackage* comboPackage - pointer to the combo package object
Return type: double - estimated total cost of the combo package Return type: double - estimated total cost of the combo package
*/ */
inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackage) inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackage)
{ {
double cost = 0; double cost = 0;
auto& services = comboPackage->getServices(); auto& services = comboPackage->getServices();
int servicesSize = services.getSize(); int servicesSize = services.getSize();
@@ -52,24 +53,24 @@ inline double calculateComboServiceEstimatedCost(const ComboPackage* comboPackag
cost += calculatePartsCost(service) + service->getLaborCost(); cost += calculatePartsCost(service) + service->getLaborCost();
} }
return cost; return cost;
} }
/* /*
Function: loadObservers Function: loadObservers
Description: Loads observer IDs from a file and attaches the corresponding users Description: Loads observer IDs from a file and attaches the corresponding users
to the notification management service. Validates that each observer ID to the notification management service. Validates that each observer ID
exists in the datastore before attaching. exists in the datastore before attaching.
Parameters: Parameters:
- filePath: const std::string&, path to the file containing observer IDs - filePath: const std::string&, path to the file containing observer IDs
- service: NotificationManagementService*, pointer to the notification service - service: NotificationManagementService*, pointer to the notification service
- dataStore: DataStore&, reference to the datastore containing users - dataStore: DataStore&, reference to the datastore containing users
Returns: Returns:
- void - void
Throws: Throws:
- std::runtime_error if an observer ID is invalid (not found in datastore) - std::runtime_error if an observer ID is invalid (not found in datastore)
*/ */
inline void loadObservers(const std::string& filePath, NotificationManagementService* service, DataStore& dataStore) inline void loadObservers(const std::string& filePath, NotificationManagementService* service, DataStore& dataStore)
{ {
auto observerIDs = util::loadRecords(filePath); auto observerIDs = util::loadRecords(filePath);
auto& users = dataStore.getUsers(); auto& users = dataStore.getUsers();
for (int index = 0; index < observerIDs.getSize(); index++) for (int index = 0; index < observerIDs.getSize(); index++)
@@ -82,20 +83,21 @@ inline void loadObservers(const std::string& filePath, NotificationManagementSer
} }
service->attach(users.getValueAt(userIndex)); service->attach(users.getValueAt(userIndex));
} }
} }
/* /*
Function: saveObservers Function: saveObservers
Description: Saves the current observer IDs from the notification management service Description: Saves the current observer IDs from the notification management service
to a file for persistence. to a file for persistence.
Parameters: Parameters:
- filePath: const std::string&, path to the file where observer IDs will be saved - filePath: const std::string&, path to the file where observer IDs will be saved
- service: NotificationManagementService*, pointer to the notification service - service: NotificationManagementService*, pointer to the notification service
Returns: Returns:
- void - void
*/ */
inline void saveObservers(const std::string& filePath, NotificationManagementService* service) inline void saveObservers(const std::string& filePath, NotificationManagementService* service)
{ {
auto observerIDs = service->getObserverIDs(); auto observerIDs = service->getObserverIDs();
util::saveRecords(filePath, observerIDs); util::saveRecords(filePath, observerIDs);
}
} }
@@ -15,7 +15,6 @@ Date:19-May-2026
#include "MenuHelper.h" #include "MenuHelper.h"
#include "OutputHelper.h" #include "OutputHelper.h"
#include "Service.h" #include "Service.h"
#include "Utility.h"
#include "Validator.h" #include "Validator.h"
#include "Vector.h" #include "Vector.h"
@@ -25,6 +24,7 @@ Description: Displays the customer menu and handles user input until logout is s
Parameter: None Parameter: None
Return type: void Return type: void
*/ */
void CustomerMenu::showMenu() void CustomerMenu::showMenu()
{ {
while (true) while (true)
@@ -125,19 +125,7 @@ Return type: void
*/ */
void CustomerMenu::changePassword() void CustomerMenu::changePassword()
{ {
std::string newPassword; changePasswordHelper(m_controller);
util::clear();
std::cout << "Enter new password: ";
util::read(newPassword);
m_controller.changePassword(newPassword);
if (!util::isPasswordValid(newPassword))
{
std::cout << "Error: Password is not strong enough!";
util::pressEnter();
return;
}
std::cout << "Password changed successfully";
util::pressEnter();
} }
/* /*
@@ -171,55 +159,6 @@ void CustomerMenu::updateDetails()
util::pressEnter(); util::pressEnter();
} }
/*
Function: selectServiceFromServices
Description: Displays active services and allows the customer to select one by index.
Parameter: const util::Map<std::string, const Service*>& services - list of services
Return type: const Service* - selected service
*/
static const Service* selectServiceFromServices(const util::Map<std::string, const Service*>& services)
{
util::Map<int, const Service*> activeServicesMap;
int currentIndex = 1;
int userInputIndex;
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(15) << "Service ID"
<< std::setw(25) << "Service Name"
<< std::setw(15) << "Estimated Cost"
<< std::endl;
for (int index = 0; index < services.getSize(); index++)
{
const Service* currentService = services.getValueAt(index);
if (currentService->getState() != util::State::ACTIVE)
{
continue;
}
activeServicesMap.insert(currentIndex, currentService);
double partsCost = calculatePartsCost(currentService);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentService->getId()
<< std::setw(25) << currentService->getName()
<< std::setw(15) << (currentService->getLaborCost() + partsCost)
<< std::endl;
currentIndex++;
}
if (activeServicesMap.getSize() == 0)
{
std::cout << "No active services available." << std::endl;
return nullptr;
}
std::cout << "Enter service index: ";
util::read(userInputIndex);
if (activeServicesMap.find(userInputIndex) == -1)
{
std::cout << "Invalid service index." << std::endl;
return nullptr;
}
return activeServicesMap[userInputIndex];
}
/* /*
Function: selectService Function: selectService
Description: Allows the customer to select a service, provide vehicle details, Description: Allows the customer to select a service, provide vehicle details,
@@ -253,54 +192,6 @@ void CustomerMenu::selectService()
util::pressEnter(); util::pressEnter();
} }
/*
Function: selectComboPackageFromPackages
Description: Displays active combo packages and allows the customer to select one by index.
Parameter: const util::Map<std::string, const ComboPackage*>& comboPackages - list of combo packages
Return type: const ComboPackage* - selected combo package
*/
static const ComboPackage* selectComboPackageFromPackages(const util::Map<std::string, const ComboPackage*>& comboPackages)
{
util::Map<int, const ComboPackage*> activeComboPackages;
int currentIndex = 1;
int userInputIndex;
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(15) << "Combo Package ID"
<< std::setw(15) << "Combo Package Name"
<< std::setw(15) << "Estimate Cost"
<< std::endl;
for (int index = 0; index < comboPackages.getSize(); index++)
{
const ComboPackage* currentComboPackage = comboPackages.getValueAt(index);
if (currentComboPackage->getState() != util::State::ACTIVE)
{
continue;
}
activeComboPackages.insert(currentIndex, currentComboPackage);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentComboPackage->getId()
<< std::setw(25) << currentComboPackage->getPackageName()
<< std::setw(15) << calculateComboServiceEstimatedCost(currentComboPackage)
<< std::endl;
currentIndex++;
}
if (activeComboPackages.getSize() == 0)
{
std::cout << "No active combo packages available." << std::endl;
return nullptr;
}
std::cout << "Enter combo package index: ";
util::read(userInputIndex);
if (activeComboPackages.find(userInputIndex) == -1)
{
std::cout << "Invalid combo package index." << std::endl;
return nullptr;
}
return activeComboPackages[userInputIndex];
}
/* /*
Function: selectComboPackage Function: selectComboPackage
Description: Allows the customer to select a combo package, provide vehicle details, Description: Allows the customer to select a combo package, provide vehicle details,
@@ -357,38 +248,6 @@ void CustomerMenu::viewNotifications()
viewAndDeleteNotification(m_controller); 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 Function: configureNotifications
@@ -7,6 +7,7 @@ Description: Header file declaring the CustomerMenu class, which provides
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
#pragma once #pragma once
#include "Controller.h" #include "Controller.h"
@@ -16,6 +16,10 @@ Date: 21-May-2026
#include "Notification.h" #include "Notification.h"
#include "OutputHelper.h" #include "OutputHelper.h"
#include "Vector.h" #include "Vector.h"
#include "Validator.h"
#include "Service.h"
#include "ComboPackage.h"
#include "Utility.h"
/* /*
Function: selectNotification Function: selectNotification
@@ -112,3 +116,172 @@ inline void viewAndDeleteNotification(Controller& controller)
controller.deleteNotification(selectedNotification->getId()); controller.deleteNotification(selectedNotification->getId());
util::pressEnter(); util::pressEnter();
} }
/*
Function: changePassword
Description: Helper function to change password
Parameter: controller: Reference to the Controller object used to manage notifications.
Return type: void
*/
inline void changePasswordHelper(Controller& controller)
{
std::string newPassword;
while (true)
{
util::clear();
std::cout << "Enter new password: ";
util::read(newPassword);
if (!util::isPasswordValid(newPassword))
{
std::cout << "Error: Password is not strong enough!\n";
util::pressEnter();
continue;
}
controller.changePassword(newPassword);
std::cout << "Password changed successfully\n";
util::pressEnter();
break;
}
}
/*
Function: selectServiceFromServices
Description: Displays active services and allows the customer to select one by index.
Parameter: const util::Map<std::string, const Service*>& services - list of services
Return type: const Service* - selected service
*/
inline const Service* selectServiceFromServices(const util::Map<std::string, const Service*>& services)
{
util::Map<int, const Service*> activeServicesMap;
int currentIndex = 1;
int userInputIndex;
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(15) << "Service ID"
<< std::setw(25) << "Service Name"
<< std::setw(15) << "Estimated Cost"
<< std::endl;
for (int index = 0; index < services.getSize(); index++)
{
const Service* currentService = services.getValueAt(index);
if (currentService->getState() != util::State::ACTIVE)
{
continue;
}
activeServicesMap.insert(currentIndex, currentService);
double partsCost = util::calculatePartsCost(currentService);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentService->getId()
<< std::setw(25) << currentService->getName()
<< std::setw(15) << (currentService->getLaborCost() + partsCost)
<< std::endl;
currentIndex++;
}
if (activeServicesMap.getSize() == 0)
{
std::cout << "No active services available." << std::endl;
return nullptr;
}
std::cout << "Enter service index: ";
util::read(userInputIndex);
if (activeServicesMap.find(userInputIndex) == -1)
{
std::cout << "Invalid service index." << std::endl;
return nullptr;
}
return activeServicesMap[userInputIndex];
}
/*
Function: selectComboPackageFromPackages
Description: Displays active combo packages and allows the customer to select one by index.
Parameter: const util::Map<std::string, const ComboPackage*>& comboPackages - list of combo packages
Return type: const ComboPackage* - selected combo package
*/
inline const ComboPackage* selectComboPackageFromPackages(const util::Map<std::string, const ComboPackage*>& comboPackages)
{
util::Map<int, const ComboPackage*> activeComboPackages;
int currentIndex = 1;
int userInputIndex;
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(15) << "Combo Package ID"
<< std::setw(15) << "Combo Package Name"
<< std::setw(15) << "Estimate Cost"
<< std::endl;
for (int index = 0; index < comboPackages.getSize(); index++)
{
const ComboPackage* currentComboPackage = comboPackages.getValueAt(index);
if (currentComboPackage->getState() != util::State::ACTIVE)
{
continue;
}
activeComboPackages.insert(currentIndex, currentComboPackage);
std::cout << std::left
<< std::setw(10) << currentIndex
<< std::setw(15) << currentComboPackage->getId()
<< std::setw(25) << currentComboPackage->getPackageName()
<< std::setw(15) << util::calculateComboServiceEstimatedCost(currentComboPackage)
<< std::endl;
currentIndex++;
}
if (activeComboPackages.getSize() == 0)
{
std::cout << "No active combo packages available." << std::endl;
return nullptr;
}
std::cout << "Enter combo package index: ";
util::read(userInputIndex);
if (activeComboPackages.find(userInputIndex) == -1)
{
std::cout << "Invalid combo package index." << std::endl;
return nullptr;
}
return activeComboPackages[userInputIndex];
}
/*
Function: sendLowStockAlertsToAdmins (static helper)
Description: Sends low stock alert notifications to all admin users for a given inventory item.
Parameters:
- inventoryManagementService: InventoryManagementService&, service used to send notifications
- inventoryItem: const InventoryItem*, pointer to the low-stock inventory item
- adminUsers: const util::Vector<User*>&, list of admin users to notify
Returns:
- None
*/
/*
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.
*/
inline 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();
}
}
@@ -5,6 +5,7 @@ Description: Implementation file containing the method definitions of the
and customer registration logic. and customer registration logic.
Author: Trenser Author: Trenser
Date:19-May-2026 Date:19-May-2026
*/ */
#include "UserInterface.h" #include "UserInterface.h"
#include "InputHelper.h" #include "InputHelper.h"