Started work on Schedule Management
This commit is contained in:
@@ -8,13 +8,19 @@ import {
|
||||
compareDate,
|
||||
} from '@quasar/quasar-ui-qcalendar';
|
||||
|
||||
import { Reservation, Timeblock } from './schedule.types';
|
||||
import {
|
||||
Reservation,
|
||||
TimeBlockTemplate,
|
||||
TimeTuple,
|
||||
Timeblock,
|
||||
} from './schedule.types';
|
||||
import { AppwriteIds, databases } from 'src/boot/appwrite';
|
||||
|
||||
export const useScheduleStore = defineStore('schedule', () => {
|
||||
// TODO: Implement functions to dynamically pull this data.
|
||||
const reservations = ref<Reservation[]>([]);
|
||||
const timeblocks = ref<Timeblock[]>([]);
|
||||
const timeblockTemplates = ref<TimeBlockTemplate[]>([]);
|
||||
|
||||
const getTimeblocksForDate = (date: string): Timeblock[] => {
|
||||
// TODO: This needs to actually make sure we have the dates we need, stay in sync, etc.
|
||||
@@ -55,6 +61,25 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
console.error('Failed to fetch timeblocks', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchTimeBlockTemplates() {
|
||||
try {
|
||||
const response = await databases.listDocuments(
|
||||
AppwriteIds.databaseId,
|
||||
AppwriteIds.collection.timeBlockTemplate
|
||||
);
|
||||
const res = response.documents.map((d) => {
|
||||
const timeTuples: TimeTuple[] = [];
|
||||
for (let i = 0; i < d.timeTuple.length; i += 2) {
|
||||
timeTuples.push([d.timeTuple[i], d.timeTuple[i + 1]]);
|
||||
}
|
||||
return { ...d, timeTuple: timeTuples };
|
||||
}) as TimeBlockTemplate[];
|
||||
timeblockTemplates.value = res;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch timeblock templates', error);
|
||||
}
|
||||
}
|
||||
// const getConflicts = (timeblock: Timeblock, boat: Boat) => {
|
||||
// const start = date.buildDate({
|
||||
// hour: timeblock.start.hour,
|
||||
@@ -117,10 +142,12 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
return {
|
||||
reservations,
|
||||
timeblocks,
|
||||
timeblockTemplates,
|
||||
getBoatReservations,
|
||||
getConflictingReservations,
|
||||
getTimeblocksForDate,
|
||||
fetchTimeBlocks,
|
||||
fetchTimeBlockTemplates,
|
||||
getNewId,
|
||||
addOrCreateReservation,
|
||||
isReservationOverlapped,
|
||||
|
||||
Reference in New Issue
Block a user