Sorted out a bunch of reactivity issues
This commit is contained in:
@@ -50,7 +50,8 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
currentUser.value = await account.get();
|
||||
}
|
||||
|
||||
function getUserNameById(id: string) {
|
||||
function getUserNameById(id: string | undefined | null): string {
|
||||
if (!id) return 'No User';
|
||||
try {
|
||||
if (!userNames.value[id]) {
|
||||
userNames.value[id] = '';
|
||||
|
||||
@@ -47,6 +47,19 @@ export const useReservationStore = defineStore('reservation', () => {
|
||||
setDateLoaded(startDate, endDate, 'error');
|
||||
}
|
||||
};
|
||||
const getReservationById = async (id: string) => {
|
||||
try {
|
||||
const response = await databases.getDocument(
|
||||
AppwriteIds.databaseId,
|
||||
AppwriteIds.collection.reservation,
|
||||
id
|
||||
);
|
||||
return response as Reservation;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch reservation: ', error);
|
||||
}
|
||||
};
|
||||
|
||||
const createReservation = async (reservation: Reservation) => {
|
||||
try {
|
||||
const response = await databases.createDocument(
|
||||
@@ -75,7 +88,6 @@ export const useReservationStore = defineStore('reservation', () => {
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log(id);
|
||||
try {
|
||||
await databases.deleteDocument(
|
||||
AppwriteIds.databaseId,
|
||||
@@ -203,6 +215,7 @@ export const useReservationStore = defineStore('reservation', () => {
|
||||
|
||||
return {
|
||||
getReservationsByDate,
|
||||
getReservationById,
|
||||
createReservation,
|
||||
deleteReservation,
|
||||
fetchReservationsForDateRange,
|
||||
|
||||
@@ -10,6 +10,8 @@ export type Reservation = Partial<Models.Document> & {
|
||||
status?: StatusTypes;
|
||||
reason: string;
|
||||
comment: string;
|
||||
members?: string[];
|
||||
guests?: string[];
|
||||
};
|
||||
|
||||
// 24 hrs in advance only 2 weekday, and 1 weekend slot
|
||||
|
||||
Reference in New Issue
Block a user