(Feat-Fix): Lots of fixes.
This commit is contained in:
@@ -262,24 +262,23 @@ export const DashboardPage: React.FC = () => {
|
|||||||
e.department_id === supervisor.department_id,
|
e.department_id === supervisor.department_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get employees without a contractor but in this department (e.g., swapped employees)
|
// Find employees swapped INTO this department (without a specific target contractor)
|
||||||
// But exclude employees who have an active swap with an original contractor
|
const swappedIntoThisDept = activeSwaps
|
||||||
const unassignedEmployees = employees.filter(
|
.filter((s) => s.target_department_id === supervisor.department_id && !s.target_contractor_id)
|
||||||
(e) =>
|
.map((swap) => {
|
||||||
e.role === "Employee" &&
|
const emp = employees.find((e) => e.id === swap.employee_id);
|
||||||
getEffectiveDepartmentId(e.id, e.department_id) === supervisor.department_id &&
|
const originalContractor = employees.find((e) => e.id === swap.original_contractor_id);
|
||||||
!e.contractor_id &&
|
return emp ? { emp, originalContractor, swap } : null;
|
||||||
!activeSwaps.find((s) => s.employee_id === e.id && s.original_contractor_id),
|
})
|
||||||
);
|
.filter((x): x is NonNullable<typeof x> => x !== null);
|
||||||
|
|
||||||
const contractorNodes = deptContractors.map((contractor) => {
|
const contractorNodes = deptContractors.map((contractor) => {
|
||||||
// Include employees whose original contractor (from swap) is this one
|
// Include employees whose original contractor is this one (they belong here)
|
||||||
// OR whose current contractor is this one AND they're not swapped away
|
|
||||||
const contractorEmployees = employees.filter(
|
const contractorEmployees = employees.filter(
|
||||||
(e) => e.role === "Employee" && getEffectiveContractorId(e.id, e.contractor_id) === contractor.id,
|
(e) => e.role === "Employee" && getEffectiveContractorId(e.id, e.contractor_id) === contractor.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Find employees swapped INTO this contractor (target_contractor_id matches)
|
// Find employees swapped INTO this specific contractor
|
||||||
const swappedInEmployees = activeSwaps
|
const swappedInEmployees = activeSwaps
|
||||||
.filter((s) => s.target_contractor_id === contractor.id)
|
.filter((s) => s.target_contractor_id === contractor.id)
|
||||||
.map((swap) => employees.find((e) => e.id === swap.employee_id))
|
.map((swap) => employees.find((e) => e.id === swap.employee_id))
|
||||||
|
|||||||
Reference in New Issue
Block a user