Remove conflicting blocks

This commit is contained in:
2024-05-17 21:41:11 -04:00
parent c3ee739366
commit 369bbc4960
2 changed files with 10 additions and 46 deletions

View File

@@ -177,9 +177,16 @@ function selectBlock(event: MouseEvent, scope: DayBodyScope, block: Interval) {
const boatBlocks = computed((): Record<string, Interval[]> => {
return scheduleStore
.getIntervalsForDate(selectedDate.value)
.reduce((result, tb) => {
if (!result[tb.boatId]) result[tb.boatId] = [];
result[tb.boatId].push(tb);
.reduce((result, interval) => {
if (!result[interval.boatId]) result[interval.boatId] = [];
if (
!reservationStore.isResourceTimeOverlapped(
interval.boatId,
new Date(interval.start),
new Date(interval.end)
)
)
result[interval.boatId].push(interval);
return result;
}, <Record<string, Interval[]>>{});
});
@@ -203,34 +210,6 @@ function getBoatReservations(scope: DayBodyScope): Reservation[] {
return boat ? boatReservations.value[boat.$id] : [];
}
// function changeEvent({ start }: { start: string }) {
// const newBlocks = scheduleStore.getIntervalsForDate(start);
// const reservations = scheduleStore.getReservationsByDate(
// parsed(start) as Timestamp
// );
// boats.value.map((boat) => {
// boat.reservations = reservations.filter(
// (reservation) => reservation.resource === boat
// );
// boat.blocks = newBlocks.filter(
// (block) =>
// block.boatId === boat.$id &&
// boat.reservations?.filter(
// (r: Reservation) =>
// r.start <
// date.addToDate(makeDateTime(parsed(block.end) as Timestamp), {
// hours: 4,
// }) &&
// r.end >
// date.addToDate(makeDateTime(parsed(block.start) as Timestamp), {
// hours: 4,
// })
// ).length == 0
// );
// });
// setTimeout(() => calendar.value?.scrollToTime('09:00'), 100); // Should figure out why we need this setTimeout...
// }
const disabledBefore = computed(() => {
const todayTs = parseTimestamp(today()) as Timestamp;
return addToDate(todayTs, { day: -1 }).date;