Cleanup linting messages. Also, break some things

This commit is contained in:
2024-05-04 12:08:16 -04:00
parent c92f737612
commit fa4d83e42d
13 changed files with 196 additions and 174 deletions

View File

@@ -9,17 +9,18 @@ import {
} from '@quasar/quasar-ui-qcalendar';
import { Reservation, Timeblock } from './schedule.types';
import {
getSampleReservations,
getSampleTimeBlocks,
} from './sampledata/schedule';
import { AppwriteIds, databases } from 'src/boot/appwrite';
export const useScheduleStore = defineStore('schedule', () => {
// TODO: Implement functions to dynamically pull this data.
const reservations = ref<Reservation[]>(getSampleReservations());
const timeblocks = ref<Timeblock[]>(getSampleTimeBlocks());
const reservations = ref<Reservation[]>([]);
const timeblocks = ref<Timeblock[]>([]);
const getTimeblocksForDate = (date: string): Timeblock[] => {
// TODO: This needs to actually make sure we have the dates we need, stay in sync, etc.
if (!timeblocks.value) {
fetchTimeBlocks();
}
return timeblocks.value.filter((b) =>
compareDate(parsed(b.start) as Timestamp, parsed(date) as Timestamp)
);
@@ -40,6 +41,17 @@ export const useScheduleStore = defineStore('schedule', () => {
});
};
async function fetchTimeBlocks() {
try {
const response = await databases.listDocuments(
AppwriteIds.databaseId,
AppwriteIds.collection.timeBlock
);
timeblocks.value = response.documents as Timeblock[];
} catch (error) {
console.error('Failed to fetch timeblocks', error);
}
}
// const getConflicts = (timeblock: Timeblock, boat: Boat) => {
// const start = date.buildDate({
// hour: timeblock.start.hour,
@@ -55,6 +67,7 @@ export const useScheduleStore = defineStore('schedule', () => {
// });
// return scheduleStore.getConflictingReservations(boat, start, end);
// };
const getConflictingReservations = (
resource: Boat,
start: Date,