diff --git a/src/App.vue b/src/App.vue
index f1d212e..ea4a4fa 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -4,10 +4,7 @@
diff --git a/src/components/scheduling/boat/BoatScheduleTableComponent.vue b/src/components/scheduling/boat/BoatScheduleTableComponent.vue
index b73e4e3..cc6dbea 100644
--- a/src/components/scheduling/boat/BoatScheduleTableComponent.vue
+++ b/src/components/scheduling/boat/BoatScheduleTableComponent.vue
@@ -70,11 +70,10 @@ import {
parseTimestamp,
parseDate,
addToDate,
- getDate,
} from '@quasar/quasar-ui-qcalendar';
import CalendarHeaderComponent from './CalendarHeaderComponent.vue';
-import { ref, computed } from 'vue';
+import { ref, computed, onMounted } from 'vue';
import { useBoatStore } from 'src/stores/boat';
import { useScheduleStore } from 'src/stores/schedule';
import { useAuthStore } from 'src/stores/auth';
@@ -90,6 +89,12 @@ const selectedDate = ref(today());
const calendar = ref(null);
+onMounted(async () => {
+ await useBoatStore().fetchBoats();
+ await scheduleStore.fetchIntervals();
+ await scheduleStore.fetchIntervalTemplates();
+});
+
function handleSwipe({ ...event }) {
event.direction === 'right' ? calendar.value?.prev() : calendar.value?.next();
}
@@ -169,18 +174,24 @@ function selectBlock(event: MouseEvent, scope: DayBodyScope, block: Interval) {
: (selectedBlock.value = block);
}
-interface BoatBlocks {
- [key: string]: Interval[];
-}
-
-const boatBlocks = computed((): BoatBlocks => {
+const boatBlocks = computed((): Record => {
return scheduleStore
.getIntervalsForDate(selectedDate.value)
.reduce((result, tb) => {
if (!result[tb.boatId]) result[tb.boatId] = [];
result[tb.boatId].push(tb);
return result;
- }, {});
+ }, >{});
+});
+
+const boatReservations = computed((): Record => {
+ return reservationStore
+ .getReservationsByDate(selectedDate.value)
+ .reduce((result, reservation) => {
+ if (!result[reservation.resource]) result[reservation.resource] = [];
+ result[reservation.resource].push(reservation);
+ return result;
+ }, >{});
});
function getBoatBlocks(scope: DayBodyScope): Interval[] {
@@ -189,9 +200,7 @@ function getBoatBlocks(scope: DayBodyScope): Interval[] {
}
function getBoatReservations(scope: DayBodyScope): Reservation[] {
const boat = boats.value[scope.columnIndex];
- return boat
- ? reservationStore.getReservationsByDate(getDate(scope.timestamp), boat.$id)
- : [];
+ return boat ? boatReservations.value[boat.$id] : [];
}
// function changeEvent({ start }: { start: string }) {
diff --git a/src/stores/reservation.ts b/src/stores/reservation.ts
index 801a562..d6021b8 100644
--- a/src/stores/reservation.ts
+++ b/src/stores/reservation.ts
@@ -1,29 +1,109 @@
import { defineStore } from 'pinia';
import type { Reservation } from './schedule.types';
-import { ref } from 'vue';
+import { computed, ref } from 'vue';
import { AppwriteIds, databases } from 'src/boot/appwrite';
import { Query } from 'appwrite';
import { date } from 'quasar';
-import { Timestamp, parseDate } from '@quasar/quasar-ui-qcalendar';
+import { Timestamp, parseDate, today } from '@quasar/quasar-ui-qcalendar';
export const useReservationStore = defineStore('reservation', () => {
+ type LoadingTypes = 'loaded' | 'pending' | undefined;
const reservations = ref