Browse Source

sort by team staff alloc

tags/Baseline_180220205_Frontend
MSI\derek 10 months ago
parent
commit
6b59e1ac6e
2 changed files with 12 additions and 2 deletions
  1. +1
    -0
      src/components/CreateProject/CreateProject.tsx
  2. +11
    -2
      src/components/CreateProject/StaffAllocation.tsx

+ 1
- 0
src/components/CreateProject/CreateProject.tsx View File

@@ -684,6 +684,7 @@ const CreateProject: React.FC<Props> = ({
allTasks={allTasks} allTasks={allTasks}
grades={grades} grades={grades}
allStaffs={allStaffs} allStaffs={allStaffs}
teamLeads={teamLeads}
/> />
} }
{<Milestone allTasks={allTasks} isActive={tabIndex === 3} />} {<Milestone allTasks={allTasks} isActive={tabIndex === 3} />}


+ 11
- 2
src/components/CreateProject/StaffAllocation.tsx View File

@@ -38,7 +38,14 @@ import { Task } from "@/app/api/tasks";
import { Grade } from "@/app/api/grades"; import { Grade } from "@/app/api/grades";
import { StaffResult } from "@/app/api/staff"; import { StaffResult } from "@/app/api/staff";


const staffComparator = (a: StaffResult, b: StaffResult) => {
const staffComparator = (a: StaffResult, b: StaffResult, teamLeads: StaffResult[]) => {
const priorityTeamId = teamLeads[0]?.teamId;
if (a.teamId === priorityTeamId && b.teamId !== priorityTeamId) {
return -1;
}
if (a.teamId !== priorityTeamId && b.teamId === priorityTeamId) {
return 1;
}
return ( return (
a.team?.localeCompare(b.team) || a.team?.localeCompare(b.team) ||
a.grade?.localeCompare(b.grade) || a.grade?.localeCompare(b.grade) ||
@@ -52,6 +59,7 @@ export interface Props {
defaultManhourBreakdownByGrade?: { [gradeId: number]: number }; defaultManhourBreakdownByGrade?: { [gradeId: number]: number };
allTasks: Task[]; allTasks: Task[];
grades: Grade[]; grades: Grade[];
teamLeads: StaffResult[];
} }


const StaffAllocation: React.FC<Props> = ({ const StaffAllocation: React.FC<Props> = ({
@@ -60,12 +68,13 @@ const StaffAllocation: React.FC<Props> = ({
isActive, isActive,
defaultManhourBreakdownByGrade, defaultManhourBreakdownByGrade,
grades, grades,
teamLeads,
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { setValue, getValues, watch } = useFormContext<CreateProjectInputs>(); const { setValue, getValues, watch } = useFormContext<CreateProjectInputs>();


const [filteredStaff, setFilteredStaff] = React.useState( const [filteredStaff, setFilteredStaff] = React.useState(
allStaffs.sort(staffComparator),
allStaffs.sort((a, b) => staffComparator(a, b, teamLeads)),
); );
const selectedStaffIds = watch("allocatedStaffIds"); const selectedStaffIds = watch("allocatedStaffIds");




Loading…
Cancel
Save