Skip to content

Commit

Permalink
Show '-' in staffing if consultant has not started yet or quit (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
idamand authored May 29, 2024
1 parent 0e07035 commit f734997
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
7 changes: 6 additions & 1 deletion frontend/src/components/FilteredConsultantsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FilteredContext } from "@/hooks/ConsultantFilterProvider";

export default function StaffingTable() {
const {
numWorkHours,
filteredConsultants,
weeklyTotalBillable,
weeklyTotalBillableAndOffered,
Expand Down Expand Up @@ -111,7 +112,11 @@ export default function StaffingTable() {
</thead>
<tbody>
{filteredConsultants.map((consultant) => (
<ConsultantRows key={consultant.id} consultant={consultant} />
<ConsultantRows
key={consultant.id}
consultant={consultant}
numWorkHours={numWorkHours}
/>
))}
</tbody>
<StaffingSums
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/Staffing/ConsultantRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import Image from "next/image";

export default function ConsultantRows({
consultant,
numWorkHours,
}: {
consultant: ConsultantReadModel;
numWorkHours: number;
}) {
const [currentConsultant, setCurrentConsultant] =
useState<ConsultantReadModel>(consultant);
Expand Down Expand Up @@ -226,6 +228,7 @@ export default function ConsultantRows({
columnCount={columnCount}
isLastCol={index == currentConsultant.bookings.length - 1}
isSecondLastCol={index == currentConsultant.bookings.length - 2}
numWorkHours={numWorkHours}
/>
))}
</tr>
Expand Down
31 changes: 28 additions & 3 deletions frontend/src/components/Staffing/WeekCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function WeekCell(props: {
columnCount: number;
isLastCol: boolean;
isSecondLastCol: boolean;
numWorkHours: number;
}) {
const {
bookedHoursPerWeek: bookedHoursPerWeek,
Expand All @@ -26,6 +27,7 @@ export function WeekCell(props: {
columnCount,
isLastCol,
isSecondLastCol,
numWorkHours,
} = props;

let pillNumber = 0;
Expand Down Expand Up @@ -152,11 +154,34 @@ export function WeekCell(props: {
isListElementVisible ? "normal-medium" : "normal"
}`}
>
{bookedHoursPerWeek.bookingModel.totalBillable.toLocaleString(
"nb-No",
)}
{bookedHoursPerWeek.bookingModel.totalPlannedAbsences > 0 &&
checkIfNotStartedOrQuit(consultant, bookedHoursPerWeek, numWorkHours)
? "-"
: bookedHoursPerWeek.bookingModel.totalBillable.toLocaleString(
"nb-No",
)}
</p>
</div>
</td>
);
}

function checkIfNotStartedOrQuit(
consultant: ConsultantReadModel,
bookedHoursPerWeek: BookedHoursPerWeek,
numWorkHours: number,
) {
const project = consultant.detailedBooking.find(
(b) => b.bookingDetails.projectName == "Ikke startet eller sluttet",
);
const hours = project?.hours.find(
(h) => h.week == bookedHoursPerWeek.sortableWeek,
);

if (!hours?.hours) return false;

return (
hours?.hours ==
numWorkHours - bookedHoursPerWeek.bookingModel.totalHolidayHours
);
}
1 change: 1 addition & 0 deletions frontend/src/hooks/staffing/useConsultantsFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function useConsultantsFilter() {
);

return {
numWorkHours,
filteredConsultants,
weeklyTotalBillable,
weeklyTotalBillableAndOffered,
Expand Down

0 comments on commit f734997

Please sign in to comment.