diff --git a/quasar.config.js b/quasar.config.js
index 34a9798..f9102ce 100644
--- a/quasar.config.js
+++ b/quasar.config.js
@@ -84,11 +84,11 @@ module.exports = configure(function (/* ctx */) {
port: 4000,
strictport: true,
// For reverse-proxying via haproxy
- hmr: {
- clientPort: 443,
- protocol: 'wss',
- timeout: 0,
- },
+ // hmr: {
+ // clientPort: 443,
+ // protocol: 'wss',
+ // timeout: 0,
+ // },
},
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
diff --git a/src/components/ResourceScheduleViewerComponent.vue b/src/components/ResourceScheduleViewerComponent.vue
index b4a8b20..54492bd 100644
--- a/src/components/ResourceScheduleViewerComponent.vue
+++ b/src/components/ResourceScheduleViewerComponent.vue
@@ -24,80 +24,115 @@
/>
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
diff --git a/src/pages/schedule/BoatReservationPage.vue b/src/pages/schedule/BoatReservationPage.vue
index 2e0e3e0..a9c6019 100644
--- a/src/pages/schedule/BoatReservationPage.vue
+++ b/src/pages/schedule/BoatReservationPage.vue
@@ -1,7 +1,7 @@
-
+
@@ -60,7 +60,33 @@
-
+
+
+
+
+
+
+
+
@@ -97,7 +123,12 @@
-
+
@@ -114,6 +145,7 @@
v-if="endDateOrTime"
>
+
- Booking Duration: {{ bookingDuration }} hours
+ Booking Duration: {{ bookingDuration }}
+
+
+
@@ -145,35 +182,63 @@ import { ref, computed } from 'vue';
import { useAuthStore } from 'src/stores/auth';
import { Boat, useBoatStore } from 'src/stores/boat';
import { date } from 'quasar';
+import ResourceScheduleViewerComponent from 'src/components/ResourceScheduleViewerComponent.vue';
+import { makeDateTime } from '@quasar/quasar-ui-qcalendar';
const auth = useAuthStore();
const boats = useBoatStore().boats;
+const dateFormat = 'ddd MMM D, YYYY h:mm A';
const startDateOrTime = ref(true);
const endDateOrTime = ref(true);
+const showSchedule = ref(false);
const bookingForm = ref({
name: auth.currentUser?.name,
boat: undefined,
- startDate: date.formatDate(new Date(), 'ddd MMM D, YYYY h:mm A'),
+ startDate: date.formatDate(new Date(), dateFormat),
endDate: date.formatDate(
date.addToDate(new Date(), { hours: 2 }),
- 'ddd MMM D, YYYY h:mm A'
+ dateFormat
),
});
+const onReset = () => {
+ // TODO
+};
+
+const onSubmit = () => {
+ // TODO
+};
+
+const onClickDate = (data) => {
+ console.log(data);
+};
+const onClickTime = (data) => {
+ bookingForm.value.boat = data.scope.resource;
+ bookingForm.value.startDate = date.formatDate(
+ date.addToDate(makeDateTime(data.scope.timestamp), { hours: 5 }), // A terrible hack to convert back to EST. TODO: FIX!!!!
+ dateFormat
+ );
+ showSchedule.value = false;
+ console.log(bookingForm.value.startDate);
+};
const bookingDuration = computed(() => {
const diff = date.getDateDiff(
bookingForm.value.endDate,
bookingForm.value.startDate,
- 'hours'
+ 'minutes'
);
- return diff > 0 ? diff : 'Invalid.';
+ return diff <= 0
+ ? 'Invalid'
+ : (diff > 60 ? Math.trunc(diff / 60) + ' hours' : '') +
+ (diff % 60 > 0 ? ' ' + (diff % 60) + ' minutes' : '');
});
const limitDate = (startDate: string) => {
return date.isBetweenDates(
startDate,
new Date(),
- date.addToDate(new Date(), { days: 21 })
+ date.addToDate(new Date(), { days: 21 }),
+ { inclusiveFrom: true, inclusiveTo: true, onlyDate: true }
);
};
diff --git a/src/pages/schedule/BoatScheduleView.vue b/src/pages/schedule/BoatScheduleView.vue
index 1675e69..3b81623 100644
--- a/src/pages/schedule/BoatScheduleView.vue
+++ b/src/pages/schedule/BoatScheduleView.vue
@@ -5,4 +5,8 @@
diff --git a/src/stores/boat.ts b/src/stores/boat.ts
index 3f3774c..eb5e082 100644
--- a/src/stores/boat.ts
+++ b/src/stores/boat.ts
@@ -3,7 +3,7 @@ import { defineStore } from 'pinia';
// const boatSource = null;
export interface Boat {
- id: string;
+ id: number;
name: string;
class?: string;
year?: number;
@@ -25,7 +25,7 @@ export interface Boat {
const getSampleData = () => [
{
- id: '1',
+ id: 1,
name: 'ProjectX',
class: 'J/27',
year: 1981,
@@ -50,7 +50,7 @@ and rough engine performance.`,
],
},
{
- id: '2',
+ id: 2,
name: 'Take5',
class: 'J/27',
year: 1985,
@@ -58,7 +58,7 @@ and rough engine performance.`,
iconsrc: '/src/assets/take5_avatar32.png',
},
{
- id: '3',
+ id: 3,
name: 'WeeBeestie',
class: 'Capri 25',
year: 1989,
diff --git a/src/stores/booking.ts b/src/stores/booking.ts
deleted file mode 100644
index 70d250c..0000000
--- a/src/stores/booking.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { defineStore } from 'pinia';
-import { Boat } from './boat';
-import { reactive } from 'vue';
-
-export type Booking = {
- start: string;
- title: string;
- duration: number;
- left?: number;
- width?: number;
-};
-
-export const useBookingStore = defineStore('bookings', () => {
- const bookings = reactive<{ [key: string]: Booking[] }>({
- 1: [
- { start: '06:00', title: 'John Smith', duration: 90 },
- { start: '12:00', title: 'Bob Barker', duration: 60 },
- ],
- 2: [
- { start: '08:00', title: 'Peter Parker', duration: 120 },
- { start: '11:00', title: 'Vince McMahon', duration: 240 },
- ],
- 3: [
- { start: '08:00', title: 'Heather Graham', duration: 240 },
- { start: '14:00', title: 'Lawrence Fishburne', duration: 60 },
- ],
- });
-
- // So nested... Trying to do something perhaps too complicated?
- // const bookingsForResource = (boatid: string) => (bookings) => {
- // return bookings.filter((booking: Booking) => booking.key == boatid )
- // }
- // },
-
- // actions: {
- // increment () {
- // this.counter++;
- // }
- // }
- return { bookings };
-});
diff --git a/src/stores/schedule.ts b/src/stores/schedule.ts
new file mode 100644
index 0000000..15cedba
--- /dev/null
+++ b/src/stores/schedule.ts
@@ -0,0 +1,95 @@
+import { defineStore } from 'pinia';
+import { ref } from 'vue';
+import { Boat, useBoatStore } from './boat';
+import { date } from 'quasar';
+import { DateOptions } from 'quasar';
+
+export interface Reservation {
+ user: string;
+ start: Date;
+ end: Date;
+ resource: Boat;
+ reservationDate: Date;
+ status?: string;
+}
+
+function getSampleData(): Reservation[] {
+ const sampleData = [
+ {
+ user: 'John Smith',
+ start: '12:00',
+ end: '14:00',
+ boat: 1,
+ status: 'confirmed',
+ },
+ {
+ user: 'Bob Barker',
+ start: '18:00',
+ end: '20:00',
+ boat: 1,
+ status: 'confirmed',
+ },
+ {
+ user: 'Peter Parker',
+ start: '8:00',
+ end: '10:00',
+ boat: 2,
+ status: 'tentative',
+ },
+ {
+ user: 'Vince McMahon',
+ start: '13:00',
+ end: '17:00',
+ boat: 2,
+ status: 'pending',
+ },
+ {
+ user: 'Heather Graham',
+ start: '06:00',
+ end: '09:00',
+ boat: 3,
+ status: 'confirmed',
+ },
+ { user: 'Lawrence Fishburne', start: '18:00', end: '20:00', boat: 3 },
+ ];
+ const boatStore = useBoatStore();
+ const now = new Date();
+ const splitTime = (x: string): string[] => {
+ return x.split(':');
+ };
+ const makeOpts = (x: string[]): DateOptions => {
+ return { hour: parseInt(x[0]), minute: parseInt(x[1]) };
+ };
+
+ return sampleData.map((entry): Reservation => {
+ const boat = boatStore.boats.find((b) => b.id == entry.boat);
+ return {
+ user: entry.user,
+ start: date.adjustDate(now, makeOpts(splitTime(entry.start))),
+ end: date.adjustDate(now, makeOpts(splitTime(entry.end))),
+ resource: boat,
+ reservationDate: now,
+ status: entry.status,
+ };
+ });
+}
+
+export const useScheduleStore = defineStore('schedule', () => {
+ const reservations = ref(getSampleData());
+ const getBoatReservations = (
+ boat: number | string,
+ curDate: Date
+ ): Reservation[] => {
+ console.log(reservations.value);
+ return reservations.value.filter((x) => {
+ return (
+ (x.start.getDate() == curDate.getDate() ||
+ x.end.getDate() == curDate.getDate()) &&
+ (typeof boat == 'number'
+ ? x.resource.id == boat
+ : x.resource.name == boat)
+ );
+ });
+ };
+ return { reservations, getBoatReservations };
+});
diff --git a/src/stores/schedule/index.js b/src/stores/schedule/index.js
deleted file mode 100644
index 2ba5722..0000000
--- a/src/stores/schedule/index.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import { defineStore } from 'pinia';
-import state from './state';
-import * as getters from './getters';
-import * as mutations from './mutations';
-import * as actions from './actions';
-
-export const useScheduleStore = defineStore('schedule', {
- state,
- getters,
- mutations,
- actions,
-});
diff --git a/src/stores/schedule/schedule.ts b/src/stores/schedule/schedule.ts
deleted file mode 100644
index d0140bd..0000000
--- a/src/stores/schedule/schedule.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { defineStore } from 'pinia';
-export interface Reservation {
- user: string;
- startdate: Date;
- enddate: Date;
- resource: string;
- reservationDate: Date;
-}
-
-export const useScheduleStore = defineStore('schedule', {
- state: () => ({
- counter: 0,
- }),
-
- getters: {
- doubleCount(state) {
- return state.counter * 2;
- },
- },
-
- actions: {
- increment() {
- this.counter++;
- },
- },
-});