Przeglądaj źródła

sort by team staff alloc

tags/Baseline_180220205_Frontend
MSI\derek 10 miesięcy temu
rodzic
commit
6b59e1ac6e
2 zmienionych plików z 12 dodań i 2 usunięć
  1. +1
    -0
      src/components/CreateProject/CreateProject.tsx
  2. +11
    -2
      src/components/CreateProject/StaffAllocation.tsx

+ 1
- 0
src/components/CreateProject/CreateProject.tsx Wyświetl plik

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


+ 11
- 2
src/components/CreateProject/StaffAllocation.tsx Wyświetl plik

@@ -38,7 +38,14 @@ import { Task } from "@/app/api/tasks";
import { Grade } from "@/app/api/grades";
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 (
a.team?.localeCompare(b.team) ||
a.grade?.localeCompare(b.grade) ||
@@ -52,6 +59,7 @@ export interface Props {
defaultManhourBreakdownByGrade?: { [gradeId: number]: number };
allTasks: Task[];
grades: Grade[];
teamLeads: StaffResult[];
}

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

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



Ładowanie…
Anuluj
Zapisz