Fix/Round Robin (#6121)

* Identify owner for a timeslot and check busyness against his schedule only

* Fix TS errors

* Fix flatmap

* Fix xisting unit tests

* Prevent duplicate slots by merging, userId -> userIds (multi)

* Small fix to potential undefined

* Moved duplicate prevention to buildSlots function

* Apply date override on a per user basis

* Prevent -1 being added to computedLocalAvailability

* Removed console.log

* Apply override properly on COLLECTIVE

* Default timeZone to UTC when undefined

* isSame doesn't work when the day shifts, isBetween instead

* Iterate over all slot.userIds schedules to identify the first user schedule that matches

* add round-robin test

Co-authored-by: Alex van Andel <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-12-21 19:32:42 +00:00
1 parent ed02c10f54
commit 0e0a78c47e
10 files changed
+221 -87

No files matched your search

@@ -31,7 +31,7 @@ export default function TeamAvailabilityTimes(props: Props) {
}
);
const times = !isLoading
const slots = !isLoading
? getSlots({
frequency: props.frequency,
inviteeDate: props.selectedDate,
@@ -44,18 +44,18 @@ export default function TeamAvailabilityTimes(props: Props) {
return (
<div className={classNames("min-w-60 flex-grow p-5 pl-0", props.className)}>
{props.HeaderComponent}
{isLoading && times.length === 0 && <Loader />}
{!isLoading && times.length === 0 && (
{isLoading && slots.length === 0 && <Loader />}
{!isLoading && slots.length === 0 && (
<div className="flex flex-col items-center justify-center pt-4">
<span className="text-sm text-gray-500">No Available Slots</span>
</div>
)}
{times.map((time) => (
<div key={time.format()} className="flex flex-row items-center">
{slots.map((slot) => (
<div key={slot.time.format()} className="flex flex-row items-center">
<a
className="min-w-48 border-brand text-bookingdarker hover:bg-brand hover:text-brandcontrast dark:hover:bg-darkmodebrand dark:hover:text-darkmodebrandcontrast mb-2 mr-3 block flex-grow rounded-sm border bg-white py-2 text-center font-medium dark:border-transparent dark:bg-gray-600 dark:text-neutral-200 dark:hover:border-black dark:hover:bg-black dark:hover:text-white"
data-testid="time">
{time.format("HH:mm")}
{slot.time.format("HH:mm")}
</a>
</div>
))}
@@ -35,7 +35,7 @@ export default function TeamAvailabilityTimes(props: Props) {
}
);
const times = !isLoading
const slots = !isLoading
? getSlots({
frequency: props.frequency,
inviteeDate: props.selectedDate,
@@ -48,8 +48,8 @@ export default function TeamAvailabilityTimes(props: Props) {
return (
<div className={classNames("min-w-60 flex-grow pl-0", props.className)}>
{props.HeaderComponent}
{isLoading && times.length === 0 && <SkeletonLoader />}
{!isLoading && times.length === 0 ? (
{isLoading && slots.length === 0 && <SkeletonLoader />}
{!isLoading && slots.length === 0 ? (
<div className="flex flex-col items-center justify-center pt-4">
<span className="text-sm text-gray-500">{t("no_available_slots")}</span>
</div>
@@ -57,12 +57,12 @@ export default function TeamAvailabilityTimes(props: Props) {
<>{!isLoading && <p className="mb-3 text-sm text-gray-600">{t("time_available")}</p>}</>
)}
<div className="max-h-[390px] overflow-scroll">
{times.map((time) => (
<div key={time.format()} className="flex flex-row items-center ">
{slots.map((slot) => (
<div key={slot.time.format()} className="flex flex-row items-center ">
<a
className="min-w-48 border-brand text-bookingdarker mb-2 mr-3 block flex-grow rounded-md border bg-white py-2 text-center font-medium dark:border-transparent dark:bg-gray-600 dark:text-neutral-200 "
data-testid="time">
{time.tz(props.selectedTimeZone.toString()).format("HH:mm")}
{slot.time.tz(props.selectedTimeZone.toString()).format("HH:mm")}
</a>
</div>
))}