diff --git a/src/components/ResourceScheduleViewerComponent.vue b/src/components/ResourceScheduleViewerComponent.vue index 1c2a70d..3e4e467 100644 --- a/src/components/ResourceScheduleViewerComponent.vue +++ b/src/components/ResourceScheduleViewerComponent.vue @@ -172,8 +172,8 @@ function monthFormatter() { function getEvents(scope: ResourceIntervalScope) { const resourceEvents = scheduleStore.getBoatReservations( - scope.resource.id, - date.extractDate(selectedDate.value, 'YYYY-MM-DD') + date.extractDate(selectedDate.value, 'YYYY-MM-DD'), + scope.resource.$id ); return resourceEvents.map((event) => { diff --git a/src/pages/schedule/BoatScheduleView.vue b/src/pages/schedule/BoatScheduleView.vue index 3b81623..9696d99 100644 --- a/src/pages/schedule/BoatScheduleView.vue +++ b/src/pages/schedule/BoatScheduleView.vue @@ -1,12 +1,94 @@ diff --git a/src/stores/schedule.ts b/src/stores/schedule.ts index 7670b88..a207a0c 100644 --- a/src/stores/schedule.ts +++ b/src/stores/schedule.ts @@ -3,11 +3,7 @@ import { ref } from 'vue'; import { Boat, useBoatStore } from './boat'; import { date } from 'quasar'; import { DateOptions } from 'quasar'; -import { - Timestamp, - parseTimestamp, - TimestampArray, -} from '@quasar/quasar-ui-qcalendar'; +import { Timestamp } from '@quasar/quasar-ui-qcalendar'; import { timeStamp } from 'console'; export type StatusTypes = 'tentative' | 'confirmed' | 'pending' | undefined; @@ -21,6 +17,10 @@ export type Reservation = { status?: StatusTypes; }; +/* TODO: Figure out how best to separate out where qcalendar bits should be. + e.g.: Should there be any qcalendar stuff in this store? Or should we have just JS Date + objects in here? */ + export type Timeblock = { start: Timestamp; end: Timestamp; @@ -52,7 +52,7 @@ function getSampleReservations(): Reservation[] { user: 'John Smith', start: '12:00', end: '15:00', - boat: 1, + boat: '1', status: 'confirmed', }, { @@ -60,7 +60,7 @@ function getSampleReservations(): Reservation[] { user: 'Bob Barker', start: '18:00', end: '21:00', - boat: 1, + boat: '1', status: 'confirmed', }, { @@ -68,7 +68,7 @@ function getSampleReservations(): Reservation[] { user: 'Peter Parker', start: '9:00', end: '12:00', - boat: 2, + boat: '2', status: 'tentative', }, { @@ -76,7 +76,7 @@ function getSampleReservations(): Reservation[] { user: 'Vince McMahon', start: '15:00', end: '18:00', - boat: 2, + boat: '2', status: 'pending', }, { @@ -84,7 +84,7 @@ function getSampleReservations(): Reservation[] { user: 'Heather Graham', start: '09:00', end: '12:00', - boat: 3, + boat: '3', status: 'confirmed', }, { @@ -92,7 +92,7 @@ function getSampleReservations(): Reservation[] { user: 'Lawrence Fishburne', start: '18:00', end: '21:00', - boat: 3, + boat: '3', }, ]; const boatStore = useBoatStore(); @@ -110,7 +110,7 @@ function getSampleReservations(): Reservation[] { }; return sampleData.map((entry): Reservation => { - const boat = boatStore.boats.find((b) => b.id == entry.boat); + const boat = boatStore.boats.find((b) => b.$id == entry.boat); return { id: entry.id, user: entry.user, @@ -131,17 +131,16 @@ export const useScheduleStore = defineStore('schedule', () => { const getTimeblocksForDate = (date: Date): Timeblock[] => timeblocks; const getBoatReservations = ( - boat: number | string, - curDate: Date + searchDate: Date, + boat?: string ): Reservation[] => { return reservations.value.filter((x) => { return ( - (x.start.getDate() == curDate.getDate() || - x.end.getDate() == curDate.getDate()) && - x.resource != undefined && - (typeof boat == 'number' - ? x.resource.id == boat - : x.resource.name == boat) + ((x.start.getDate() == searchDate.getDate() || + x.end.getDate() == searchDate.getDate()) && // Part of reservation falls on day + x.resource != undefined && // A boat is defined + !boat) || + x.resource.$id == boat // A specific boat has been passed, and matches ); }); }; @@ -153,7 +152,7 @@ export const useScheduleStore = defineStore('schedule', () => { ): Reservation[] => { const overlapped = reservations.value.filter( (entry: Reservation) => - entry.resource.id == resource.id && + entry.resource.$id == resource.$id && entry.start < end && entry.end > start );