Implement review fixes
Changes: - Strengthened UserManagementService::updateUserDetails by checking duplicates only when email/phone are changed, preventing false errors - Updated AdminMenu::viewStockLevels header text from "View Stock Level" to "View Stock Levels" for consistency - Cleaned up CustomerMenu::updateDetails by removing unused user list retrieval and improving header/message formatting
This commit is contained in:
+7
-1
@@ -113,15 +113,21 @@ void UserManagementService::updateUserDetails(const std::string& userID, const s
|
||||
{
|
||||
throw std::runtime_error("User does not exist!\n");
|
||||
}
|
||||
User* user = usersMap.getValueAt(index);
|
||||
if (email != user->getEmail())
|
||||
{
|
||||
if (util::isEmailDuplicate(email, usersMap))
|
||||
{
|
||||
throw std::runtime_error("Email already exists!\n");
|
||||
}
|
||||
}
|
||||
if (phone != user->getPhone())
|
||||
{
|
||||
if (util::isPhoneDuplicate(phone, usersMap))
|
||||
{
|
||||
throw std::runtime_error("Phone number already exists!\n");
|
||||
}
|
||||
User* user = usersMap.getValueAt(index);
|
||||
}
|
||||
user->setEmail(email);
|
||||
user->setPhone(phone);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ void AdminMenu::viewStockLevels()
|
||||
util::clear();
|
||||
auto inventoryItems = m_controller.getInventoryItems();
|
||||
bool hasActiveItems = false;
|
||||
std::cout << "View Stock Level" << std::endl;
|
||||
std::cout << "View Stock Levels" << std::endl;
|
||||
if (inventoryItems.isEmpty())
|
||||
{
|
||||
std::cout << "No items found in Inventory.\n";
|
||||
|
||||
@@ -143,7 +143,6 @@ Return type: void
|
||||
void CustomerMenu::updateDetails()
|
||||
{
|
||||
std::string email, phone;
|
||||
util::Map<std::string, const User*> userList = m_controller.getUsers();
|
||||
util::clear();
|
||||
std::cout << "Update Details\n";
|
||||
std::cout << "Enter new email: ";
|
||||
|
||||
Reference in New Issue
Block a user