More work on timeblocks
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m0s
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m0s
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { Boat } from './boat';
|
||||
import { Timestamp, parseDate } from '@quasar/quasar-ui-qcalendar';
|
||||
import {
|
||||
Timestamp,
|
||||
parseDate,
|
||||
parsed,
|
||||
compareDate,
|
||||
} from '@quasar/quasar-ui-qcalendar';
|
||||
|
||||
import { Reservation, Timeblock } from './schedule.types';
|
||||
import { weekdayBlocks, getSampleReservations } from './sampledata/schedule';
|
||||
import {
|
||||
getSampleReservations,
|
||||
getSampleTimeBlocks,
|
||||
} from './sampledata/schedule';
|
||||
|
||||
export const useScheduleStore = defineStore('schedule', () => {
|
||||
// TODO: Implement functions to dynamically pull this data.
|
||||
const reservations = ref<Reservation[]>(getSampleReservations());
|
||||
const timeblocks = weekdayBlocks;
|
||||
|
||||
const getTimeblocksForDate = (date: Timestamp): Timeblock[] => {
|
||||
return timeblocks.map((t) => {
|
||||
return {
|
||||
// Update all the start/end times with the passed in date
|
||||
...t,
|
||||
start: { ...date, ...t.start },
|
||||
end: { ...date, ...t.end },
|
||||
};
|
||||
});
|
||||
const getTimeblocksForDate = (date: string): Timeblock[] => {
|
||||
return getSampleTimeBlocks().filter((b) =>
|
||||
compareDate(parsed(b.start) as Timestamp, parsed(date) as Timestamp)
|
||||
);
|
||||
};
|
||||
|
||||
const getBoatReservations = (
|
||||
@@ -27,7 +29,6 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
boat?: string
|
||||
): Reservation[] => {
|
||||
return reservations.value.filter((x) => {
|
||||
console.log(searchDate);
|
||||
return (
|
||||
((parseDate(x.start)?.date == searchDate.date ||
|
||||
parseDate(x.end)?.date == searchDate.date) && // Part of reservation falls on day
|
||||
@@ -38,6 +39,21 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
});
|
||||
};
|
||||
|
||||
// const getConflicts = (timeblock: Timeblock, boat: Boat) => {
|
||||
// const start = date.buildDate({
|
||||
// hour: timeblock.start.hour,
|
||||
// minute: timeblock.start.minute,
|
||||
// second: 0,
|
||||
// millisecond: 0,
|
||||
// });
|
||||
// const end = date.buildDate({
|
||||
// hour: timeblock.end.hour,
|
||||
// minute: timeblock.end.minute,
|
||||
// second: 0,
|
||||
// millisecond: 0,
|
||||
// });
|
||||
// return scheduleStore.getConflictingReservations(boat, start, end);
|
||||
// };
|
||||
const getConflictingReservations = (
|
||||
resource: Boat,
|
||||
start: Date,
|
||||
|
||||
Reference in New Issue
Block a user