Fix bug
Some checks failed
Build BAB Application Deployment Artifact / build (push) Failing after 2m6s
Some checks failed
Build BAB Application Deployment Artifact / build (push) Failing after 2m6s
This commit is contained in:
@@ -71,7 +71,7 @@
|
|||||||
">
|
">
|
||||||
{{ getUserName(reservation.user) || 'loading...' }}
|
{{ getUserName(reservation.user) || 'loading...' }}
|
||||||
<br />
|
<br />
|
||||||
<q-chip>{{ reservation.reason }}</q-chip>
|
<q-chip class="gt-md">{{ reservation.reason }}</q-chip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,7 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<q-card
|
||||||
|
clas="q-ma-md"
|
||||||
|
bordered
|
||||||
|
v-if="!reservations">
|
||||||
|
<q-card-section>
|
||||||
|
<div class="text-h6">You don't have any bookings!</div>
|
||||||
|
<div class="text-h8">Why don't you go make one?</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-actions>
|
||||||
|
<q-btn
|
||||||
|
color="primary"
|
||||||
|
icon="event"
|
||||||
|
:size="`1.25em`"
|
||||||
|
label="Book Now"
|
||||||
|
rounded
|
||||||
|
class="full-width"
|
||||||
|
:align="'left'"
|
||||||
|
to="/schedule/book" />
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
<template
|
<template
|
||||||
v-for="(booking, index) in sortedBookings"
|
v-else
|
||||||
:key="booking.$id">
|
v-for="(reservation, index) in sortedBookings"
|
||||||
|
:key="reservation.$id">
|
||||||
<q-toolbar
|
<q-toolbar
|
||||||
class="bg-secondary glossy text-white"
|
class="bg-secondary glossy text-white"
|
||||||
v-if="showMarker(index, sortedBookings)">
|
v-if="showMarker(index, sortedBookings)">
|
||||||
@@ -9,20 +30,23 @@
|
|||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
<q-card
|
<q-card
|
||||||
bordered
|
bordered
|
||||||
:class="isPast(booking.end) ? 'text-blue-grey-6' : ''"
|
:class="isPast(reservation.end) ? 'text-blue-grey-6' : ''"
|
||||||
class="q-ma-md">
|
class="q-ma-md">
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<div class="row items-center no-wrap">
|
<div class="row items-center no-wrap">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="text-h6">
|
<div class="text-h6">
|
||||||
{{ boatStore.getBoatById(booking.resource)?.name }}
|
{{ boatStore.getBoatById(reservation.resource)?.name }}
|
||||||
</div>
|
</div>
|
||||||
<div class="text-subtitle2">
|
<div class="text-subtitle2">
|
||||||
<p>Start: {{ formatDate(booking.start) }}</p>
|
<p>
|
||||||
<p>End: {{ formatDate(booking.end) }}</p>
|
Start: {{ formatDate(reservation.start) }}
|
||||||
|
<br />
|
||||||
|
End: {{ formatDate(reservation.end) }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<!-- <div class="col-auto">
|
||||||
<q-btn
|
<q-btn
|
||||||
color="grey-7"
|
color="grey-7"
|
||||||
round
|
round
|
||||||
@@ -33,45 +57,84 @@
|
|||||||
auto-close>
|
auto-close>
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-item clickable>
|
<q-item clickable>
|
||||||
<q-item-section>Remove Card</q-item-section>
|
<q-item-section>remove card</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item clickable>
|
<q-item clickable>
|
||||||
<q-item-section>Send Feedback</q-item-section>
|
<q-item-section>send feedback</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item clickable>
|
<q-item clickable>
|
||||||
<q-item-section>Share</q-item-section>
|
<q-item-section>share</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
</q-list>
|
</q-list>
|
||||||
</q-menu>
|
</q-menu>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-card-section>Some more information here...</q-card-section>
|
<!-- <q-card-section>Some more information here...</q-card-section> -->
|
||||||
|
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
||||||
<q-card-actions>
|
<q-card-actions v-if="!isPast(reservation.end)">
|
||||||
<q-btn flat>Action 1</q-btn>
|
<q-btn
|
||||||
<q-btn flat>Action 2</q-btn>
|
flat
|
||||||
|
@click="modifyReservation(reservation)">
|
||||||
|
Modify
|
||||||
|
</q-btn>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
@click="cancelReservation(reservation)">
|
||||||
|
Cancel
|
||||||
|
</q-btn>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
</template>
|
</template>
|
||||||
|
<q-dialog v-model="cancelDialog">
|
||||||
|
<q-card>
|
||||||
|
<q-card-section class="row items-center">
|
||||||
|
<q-avatar
|
||||||
|
icon="stop"
|
||||||
|
color="negative"
|
||||||
|
text-color="white" />
|
||||||
|
<span class="q-ml-sm">
|
||||||
|
This will delete your reservation for
|
||||||
|
{{ boatStore.getBoatById(currentReservation?.resource) }} on
|
||||||
|
{{ formatDate(currentReservation?.start) }}
|
||||||
|
</span>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-actions align="right">
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
label="Cancel"
|
||||||
|
color="primary"
|
||||||
|
v-close-popup />
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
label="Delete"
|
||||||
|
color="negative"
|
||||||
|
@click="reservationStore.deleteReservation(Reservation)"
|
||||||
|
v-close-popup />
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useBoatStore } from 'src/stores/boat';
|
import { useBoatStore } from 'src/stores/boat';
|
||||||
import { useReservationStore } from 'src/stores/reservation';
|
import { useReservationStore } from 'src/stores/reservation';
|
||||||
import { Reservation } from 'src/stores/schedule.types';
|
import { Reservation } from 'src/stores/schedule.types';
|
||||||
import { formatDate } from 'src/utils/schedule';
|
import { formatDate } from 'src/utils/schedule';
|
||||||
import { computed, onMounted } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
const reservationStore = useReservationStore();
|
const reservationStore = useReservationStore();
|
||||||
const bookings = reservationStore.getUserReservations();
|
const reservations = reservationStore.getUserReservations();
|
||||||
const boatStore = useBoatStore();
|
const boatStore = useBoatStore();
|
||||||
|
const currentReservation = ref<Reservation>();
|
||||||
|
const cancelDialog = ref(false);
|
||||||
|
|
||||||
const sortedBookings = computed(() =>
|
const sortedBookings = computed(() =>
|
||||||
bookings.value
|
reservations.value
|
||||||
?.slice()
|
?.slice()
|
||||||
.sort((a, b) => new Date(b.start).getTime() - new Date(a.start).getTime())
|
.sort((a, b) => new Date(b.start).getTime() - new Date(a.start).getTime())
|
||||||
);
|
);
|
||||||
@@ -100,6 +163,15 @@ const showMarker = (
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const cancelReservation = (reservation: Reservation) => {
|
||||||
|
currentReservation.value = reservation;
|
||||||
|
cancelDialog.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const modifyReservation = (reservation: Reservation) => {
|
||||||
|
return reservation;
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
boatStore.fetchBoats();
|
boatStore.fetchBoats();
|
||||||
reservationStore.fetchUserReservations();
|
reservationStore.fetchUserReservations();
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ export const useBoatStore = defineStore('boat', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getBoatById = (id: string): Boat | null => {
|
const getBoatById = (id: string | null | undefined): Boat | null => {
|
||||||
return boats.value.find((b) => b.$id === id) || null;
|
if (!id) return null;
|
||||||
|
return boats.value?.find((b) => b.$id === id) || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return { boats, fetchBoats, getBoatById };
|
return { boats, fetchBoats, getBoatById };
|
||||||
|
|||||||
@@ -60,6 +60,32 @@ export const useReservationStore = defineStore('reservation', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deleteReservation = async (
|
||||||
|
reservation: string | Reservation | null | undefined
|
||||||
|
) => {
|
||||||
|
if (!reservation) return false;
|
||||||
|
let id;
|
||||||
|
if (typeof reservation === 'string') {
|
||||||
|
id = reservation;
|
||||||
|
} else if ('$id' in reservation && typeof reservation.$id === 'string') {
|
||||||
|
id = reservation.$id;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await databases.deleteDocument(
|
||||||
|
AppwriteIds.databaseId,
|
||||||
|
AppwriteIds.collection.interval,
|
||||||
|
id
|
||||||
|
);
|
||||||
|
reservations.value.delete(id);
|
||||||
|
console.info(`Deleted reservation: ${id}`);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error deleting reservation: ' + e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Set the loading state for dates
|
// Set the loading state for dates
|
||||||
const setDateLoaded = (start: Date, end: Date, state: LoadingTypes) => {
|
const setDateLoaded = (start: Date, end: Date, state: LoadingTypes) => {
|
||||||
if (start > end) return [];
|
if (start > end) return [];
|
||||||
@@ -160,6 +186,7 @@ export const useReservationStore = defineStore('reservation', () => {
|
|||||||
return {
|
return {
|
||||||
getReservationsByDate,
|
getReservationsByDate,
|
||||||
createReservation,
|
createReservation,
|
||||||
|
deleteReservation,
|
||||||
fetchReservationsForDateRange,
|
fetchReservationsForDateRange,
|
||||||
isReservationOverlapped,
|
isReservationOverlapped,
|
||||||
isResourceTimeOverlapped,
|
isResourceTimeOverlapped,
|
||||||
|
|||||||
Reference in New Issue
Block a user