-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data for detailed booking and booking transformed for forecast rows (#…
…579)
- Loading branch information
1 parent
534a1b0
commit 3da9690
Showing
10 changed files
with
901 additions
and
133 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { BookingType, ConsultantReadModel } from "@/api-types"; | ||
import { | ||
getColorByStaffingType, | ||
getIconByBookingType, | ||
} from "@/components/Staffing/helpers/utils"; | ||
import React from "react"; | ||
import { | ||
transformDetailedBookingToMonthlyData, | ||
transformToMonthlyData, | ||
} from "./TransformWeekDataToMonth"; | ||
import { MonthlyDetailedBooking, MonthlyHours } from "@/types"; | ||
|
||
function isMonthBookingZeroHours( | ||
detailedBooking: MonthlyDetailedBooking, | ||
hoveredRowMonth: number, | ||
): boolean { | ||
return ( | ||
detailedBooking.hours.filter( | ||
(monthHours) => | ||
monthHours.month % 100 == hoveredRowMonth && monthHours.hours != 0, | ||
).length == 0 | ||
); | ||
} | ||
export function HoveredMonth(props: { | ||
hoveredRowMonth: number; | ||
consultant: ConsultantReadModel; | ||
isLastCol: boolean; | ||
isSecondLastCol: boolean; | ||
columnCount: number; | ||
}) { | ||
const { | ||
hoveredRowMonth: hoveredRowMonth, | ||
consultant, | ||
isLastCol, | ||
isSecondLastCol, | ||
columnCount, | ||
} = props; | ||
|
||
const bookings = transformToMonthlyData(consultant.bookings); | ||
const detailedBookings = transformDetailedBookingToMonthlyData( | ||
consultant.detailedBooking, | ||
); | ||
const nonZeroHoursDetailedBookings = detailedBookings.filter( | ||
(d) => !isMonthBookingZeroHours(d, hoveredRowMonth), | ||
); | ||
|
||
const freeTime = bookings.find((b) => b.month == hoveredRowMonth) | ||
?.bookingModel.totalSellableTime; | ||
if (freeTime && freeTime > 0) { | ||
nonZeroHoursDetailedBookings.push({ | ||
bookingDetails: { | ||
type: BookingType.Available, | ||
projectName: "", | ||
customerName: "Ledig Tid", | ||
projectId: 0, | ||
isBillable: false, | ||
}, | ||
hours: [ | ||
{ | ||
month: hoveredRowMonth, | ||
hours: | ||
bookings.find((b) => b.month == hoveredRowMonth)?.bookingModel | ||
.totalSellableTime || 0, | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
return ( | ||
<> | ||
<div | ||
className={`rounded-lg bg-white gap-3 min-w-[222px] p-3 shadow-xl absolute bottom-full mb-2 flex flex-col z-20 pointer-events-none ${ | ||
isLastCol || (isSecondLastCol && columnCount >= 26) | ||
? "right-0 " | ||
: "left-1/2 -translate-x-1/2" | ||
} ${nonZeroHoursDetailedBookings.length == 0 && "hidden"}`} | ||
> | ||
{nonZeroHoursDetailedBookings.map((detailedBooking, index) => ( | ||
<div | ||
key={index} | ||
className={`flex flex-row gap-2 justify-between items-center | ||
${ | ||
index < nonZeroHoursDetailedBookings.length - 1 && | ||
"pb-3 border-b border-black/10" | ||
}`} | ||
> | ||
<div className="flex flex-row gap-2 items-center"> | ||
<div | ||
className={`h-8 w-8 flex justify-center align-middle items-center rounded ${getColorByStaffingType( | ||
detailedBooking.bookingDetails.type, | ||
)}`} | ||
> | ||
{getIconByBookingType(detailedBooking.bookingDetails.type, 16)} | ||
</div> | ||
<div className="flex flex-col"> | ||
<p | ||
className={`xsmall text-black/75 ${ | ||
!( | ||
detailedBooking.bookingDetails.type == | ||
BookingType.Offer || | ||
detailedBooking.bookingDetails.type == BookingType.Booking | ||
) && "hidden" | ||
}`} | ||
> | ||
{detailedBooking.bookingDetails.projectName} | ||
</p> | ||
<p className="small text-black whitespace-nowrap"> | ||
{detailedBooking.bookingDetails.customerName} | ||
</p> | ||
</div> | ||
</div> | ||
<p className="small text-black/75"> | ||
{ | ||
detailedBooking.hours.find( | ||
(hour: MonthlyHours) => hour.month % 100 == hoveredRowMonth, | ||
)?.hours | ||
} | ||
</p> | ||
</div> | ||
))} | ||
</div> | ||
<div | ||
className={`absolute bottom-full mb-[2px] left-1/2 -translate-x-1/2 flex items-center z-50 w-0 h-0 border-l-[8px] border-l-transparent border-t-[8px] border-t-white border-r-[8px] border-r-transparent pointer-events-none ${ | ||
nonZeroHoursDetailedBookings.length == 0 && "hidden" | ||
}`} | ||
></div> | ||
</> | ||
); | ||
} |
Oops, something went wrong.