Implement Review Fixes

<UserStory> EMP002 : Deactivate Employee </UserStory>

<Changes>
- Updated employee listing to display in a tabular format with headers
- Renamed helper function from listActiveEmployees to listEmployees
- Updated error messages
- Removed blank spaces
</Changes>

<Review>
Smitha Mohan
</Review>
This commit is contained in:
Princy Jerin
2026-04-08 10:29:06 +05:30
committed by Joel Thomas
parent f85614ecc5
commit daf33e1aab
2 changed files with 46 additions and 44 deletions
@@ -1,4 +1,3 @@
#include <iostream> #include <iostream>
#include "HRManagerMenu.h" #include "HRManagerMenu.h"
#include "InputHelper.h" #include "InputHelper.h"
@@ -111,39 +110,39 @@ bool HRManagerMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
{ {
//case 1: /*case 1:
// m_zenvyController.applyLeave(); m_zenvyController.applyLeave();
// break;
//case 2:
// m_zenvyController.viewPayslip();
// break;
//case 3:
// m_zenvyController.viewPayslipHistory();
// break;
//case 4:
// m_zenvyController.viewEmployees();
// break;
//case 5:
// m_zenvyController.searchEmployee();
// break;
//case 6:
// m_zenvyController.viewNotifications();
// break;
//case 7:
// m_zenvyController.viewAnnouncements();
// break;
case 8:
createEmployee(m_zenvyController);
break; break;
//case 9: case 2:
// m_zenvyController.regularizeAttenance(); m_zenvyController.viewPayslip();
// break; break;
//case 10: case 3:
// m_zenvyController.updateLeaveRequest(); m_zenvyController.viewPayslipHistory();
// break; break;
//case 11: case 4:
// m_zenvyController.registercandidateAsEmployee(); m_zenvyController.viewEmployees();
// break; break;
case 5:
m_zenvyController.searchEmployee();
break;
case 6:
m_zenvyController.viewNotifications();
break;
case 7:
m_zenvyController.viewAnnouncements();
break;
case 8:
m_zenvyController.createEmployee();
break;
case 9:
m_zenvyController.regularizeAttenance();
break;
case 10:
m_zenvyController.updateLeaveRequest();
break;
case 11:
m_zenvyController.registercandidateAsEmployee();
break;*/
case 12: case 12:
updateProfile(m_zenvyController); updateProfile(m_zenvyController);
break; break;
+14 -11
View File
@@ -8,7 +8,7 @@
#include "ZenvyController.h" #include "ZenvyController.h"
#include "MenuHelper.h" #include "MenuHelper.h"
#include "InputHelper.h" #include "InputHelper.h"
#include"OutputHelper.h" #include "OutputHelper.h"
inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController) inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController)
{ {
@@ -49,20 +49,22 @@ inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController)
} }
inline std::map<int, std::shared_ptr<const Employee>> listActiveEmployees(const std::shared_ptr<ZenvyController>& controller) inline std::map<int, std::shared_ptr<const Employee>> listEmployees(const std::shared_ptr<ZenvyController>& controller)
{ {
auto employees = controller->getEmployees(); auto employees = controller->getEmployees();
std::map<int, std::shared_ptr<const Employee>> employeeList; std::map<int, std::shared_ptr<const Employee>> employeeList;
std::cout << std::left
<< std::setw(5) << "Index"
<< std::setw(15) << "ID"
<< std::setw(25) << "Name"
<< "\n";
int index = 1; int index = 1;
std::cout << "Active Employees:\n";
for (auto& activeEmployees : employees) for (auto& activeEmployees : employees)
{ {
std::cout << std::setw(3) << index << ". " std::cout << std::left
<< std::setw(10) << "ID: " << std::setw(5) << index
<< std::setw(10) << activeEmployees->getEmployeeId() << std::setw(15) << activeEmployees->getEmployeeId()
<< " | " << std::setw(25) << activeEmployees->getEmployeeName()
<< std::setw(10) << "Name: "
<< std::setw(20) << activeEmployees->getEmployeeName()
<< "\n"; << "\n";
employeeList[index] = activeEmployees; employeeList[index] = activeEmployees;
++index; ++index;
@@ -76,12 +78,13 @@ inline std::map<int, std::shared_ptr<const Employee>> listActiveEmployees(const
void deactivateEmployee(const std::shared_ptr<ZenvyController>& controller) void deactivateEmployee(const std::shared_ptr<ZenvyController>& controller)
{ {
auto employeeList = listActiveEmployees(controller); auto employeeList = listEmployees(controller);
if (employeeList.empty()) if (employeeList.empty())
{ {
return; return;
} }
int choice; int choice;
util::clear();
std::cout << "\nEnter the index of the employee to deactivate: "; std::cout << "\nEnter the index of the employee to deactivate: ";
util::read(choice); util::read(choice);
auto iterator = employeeList.find(choice); auto iterator = employeeList.find(choice);
@@ -100,6 +103,6 @@ void deactivateEmployee(const std::shared_ptr<ZenvyController>& controller)
} }
else else
{ {
std::cout << "Invalid selection.\n"; std::cout << "Invalid index.\n";
} }
} }