From ddbf5eef0d2afe9e95e5640ef875415818c129bc Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Thu, 21 Nov 2024 08:08:18 +0100 Subject: [PATCH] Fix errors --- frontend/admin/src/types/index.ts | 13 ++++++++++++- frontend/admin/src/views/BookingsView.vue | 16 ++++++++-------- frontend/admin/src/views/DashboardView.vue | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/frontend/admin/src/types/index.ts b/frontend/admin/src/types/index.ts index 0e3ee4a..d4050c4 100644 --- a/frontend/admin/src/types/index.ts +++ b/frontend/admin/src/types/index.ts @@ -12,7 +12,7 @@ export interface Booking { id: string startTime: string endTime: string - status: 'completed' | 'pending' | 'cancelled' + status: 'CONFIRMED' | 'PENDING' | 'CANCELLED' notes: string totalPrice: string reminderSent: boolean @@ -25,6 +25,17 @@ export interface Booking { service: Service } +// This interface represents the simplified booking data used in views +export interface BookingView { + id: string | number; + customerName: string; + employeeName: string; + serviceName: string; + startTime: string; + status: 'CONFIRMED' | 'PENDING' | 'CANCELLED'; + notes?: string; +} + export interface Customer { id: string firstName: string diff --git a/frontend/admin/src/views/BookingsView.vue b/frontend/admin/src/views/BookingsView.vue index b9005e2..accb4ee 100644 --- a/frontend/admin/src/views/BookingsView.vue +++ b/frontend/admin/src/views/BookingsView.vue @@ -89,8 +89,8 @@ {{ booking.employeeName }} - - {{ getStatusText(booking.status.toUpperCase()) }} + + {{ getStatusText(booking.status?.toUpperCase() || '') }} @@ -130,11 +130,11 @@ import { onMounted, ref } from "vue"; import { useBookingStore } from "../stores/bookings"; import BookingEditModal from "../components/BookingEditModal.vue"; -import type { Booking } from '../types'; +import type { BookingView } from '../types'; const bookingStore = useBookingStore(); const isEditModalOpen = ref(false); -const selectedBooking = ref(null); +const selectedBooking = ref(null); const formatDateTime = (dateTime: string) => { try { @@ -159,7 +159,7 @@ const getStatusClass = (status: string) => { CANCELLED: "bg-red-100 text-red-800", }; return `inline-flex rounded-full px-2 text-xs font-semibold leading-5 ${ - classes[status as keyof typeof classes] + classes[status as keyof typeof classes] || 'bg-gray-100 text-gray-800' }`; }; @@ -169,10 +169,10 @@ const getStatusText = (status: string) => { CONFIRMED: "Bekreftet", CANCELLED: "Kansellert", }; - return statusMap[status as keyof typeof statusMap] || status; + return statusMap[status as keyof typeof statusMap] || "Ukjent"; }; -const openEditModal = (booking: Booking) => { +const openEditModal = (booking: BookingView) => { selectedBooking.value = booking; isEditModalOpen.value = true; }; @@ -182,7 +182,7 @@ const closeEditModal = () => { isEditModalOpen.value = false; }; -const handleSave = async (updatedBooking: Partial) => { +const handleSave = async (updatedBooking: Partial) => { if (!selectedBooking.value?.id) return; const success = await bookingStore.updateBooking(selectedBooking.value.id, updatedBooking); diff --git a/frontend/admin/src/views/DashboardView.vue b/frontend/admin/src/views/DashboardView.vue index 4e82112..12cbcdd 100644 --- a/frontend/admin/src/views/DashboardView.vue +++ b/frontend/admin/src/views/DashboardView.vue @@ -155,7 +155,7 @@ @click="handleView(booking)" data-test="view-button" > - Se + Vis