UI Enhancements
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { Boat } from './boat';
|
||||
import { Timestamp } from '@quasar/quasar-ui-qcalendar';
|
||||
import { Timestamp, today } from '@quasar/quasar-ui-qcalendar';
|
||||
|
||||
import { Interval, IntervalRecord } from './schedule.types';
|
||||
import { AppwriteIds, databases } from 'src/boot/appwrite';
|
||||
@@ -13,6 +13,7 @@ export const useIntervalStore = defineStore('interval', () => {
|
||||
const intervals = ref<Map<string, Interval>>(new Map());
|
||||
const intervalDates = ref<IntervalRecord>({});
|
||||
const reservationStore = useReservationStore();
|
||||
const selectedDate = ref<string>(today());
|
||||
|
||||
const getIntervals = (date: Timestamp | string, boat?: Boat): Interval[] => {
|
||||
const searchDate = typeof date === 'string' ? date : date.date;
|
||||
@@ -39,8 +40,6 @@ export const useIntervalStore = defineStore('interval', () => {
|
||||
boat?: Boat
|
||||
): Interval[] => {
|
||||
return computed(() => {
|
||||
console.log(boat);
|
||||
console.log(getIntervals(date, boat));
|
||||
return getIntervals(date, boat).filter((interval) => {
|
||||
return !reservationStore.isResourceTimeOverlapped(
|
||||
interval.resource,
|
||||
@@ -51,6 +50,14 @@ export const useIntervalStore = defineStore('interval', () => {
|
||||
}).value;
|
||||
};
|
||||
|
||||
async function fetchInterval(id: string): Promise<Interval> {
|
||||
return (await databases.getDocument(
|
||||
AppwriteIds.databaseId,
|
||||
AppwriteIds.collection.interval,
|
||||
id
|
||||
)) as Interval;
|
||||
}
|
||||
|
||||
async function fetchIntervals(dateString: string) {
|
||||
try {
|
||||
const response = await databases.listDocuments(
|
||||
@@ -128,8 +135,10 @@ export const useIntervalStore = defineStore('interval', () => {
|
||||
getIntervals,
|
||||
getAvailableIntervals,
|
||||
fetchIntervals,
|
||||
fetchInterval,
|
||||
createInterval,
|
||||
updateInterval,
|
||||
deleteInterval,
|
||||
selectedDate,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user