From cd692a6f3bc81580531aae21a75d19a83a0045c5 Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Tue, 21 May 2024 16:32:31 -0400 Subject: [PATCH] Fix login bug. Improve reservations --- package.json | 3 +- src/boot/appwrite.ts | 53 ++++++----- .../boat/BoatScheduleTableComponent.vue | 3 +- src/pages/LoginPage.vue | 12 ++- src/pages/schedule/BoatReservationPage.vue | 88 +++++++++---------- src/router/index.ts | 11 +-- src/stores/reservation.ts | 1 + src/stores/sampledata/schedule.ts | 7 ++ src/stores/schedule.types.ts | 1 + yarn.lock | 5 ++ 10 files changed, 103 insertions(+), 81 deletions(-) diff --git a/package.json b/package.json index 39e6d34..eb0ce6c 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "file": "^0.2.2", "pinia": "^2.1.7", "vue": "3", - "vue-router": "4" + "vue-router": "4", + "vue3-google-login": "^2.0.26" }, "devDependencies": { "@quasar/app-vite": "^1.9.1", diff --git a/src/boot/appwrite.ts b/src/boot/appwrite.ts index ea03ab5..943299a 100644 --- a/src/boot/appwrite.ts +++ b/src/boot/appwrite.ts @@ -1,5 +1,12 @@ import { boot } from 'quasar/wrappers'; -import { Client, Account, Databases, Functions, ID } from 'appwrite'; +import { + Client, + Account, + Databases, + Functions, + ID, + AppwriteException, +} from 'appwrite'; import { useAuthStore } from 'src/stores/auth'; import { Dialog, Notify } from 'quasar'; import type { Router } from 'vue-router'; @@ -90,7 +97,7 @@ async function logout() { }); } -function login(email: string, password: string) { +async function login(email: string, password: string) { const notification = Notify.create({ type: 'primary', position: 'top', @@ -100,31 +107,31 @@ function login(email: string, password: string) { group: false, }); const authStore = useAuthStore(); - authStore - .login(email, password) - .then(() => { - notification({ - type: 'positive', - message: 'Logged in!', - timeout: 2000, - spinner: false, - icon: 'check_circle', - }); - console.log('Redirecting to index page'); - appRouter.replace({ name: 'index' }); - }) - .catch(function (reason: Error) { - notification({ - type: 'negative', - message: 'Login failed.', - timeout: 1, - }); + try { + await authStore.login(email, password); + notification({ + type: 'positive', + message: 'Logged in!', + timeout: 2000, + spinner: false, + icon: 'check_circle', + }); + console.log('Redirecting to index page'); + appRouter.replace({ name: 'index' }); + } catch (error: unknown) { + notification({ + type: 'negative', + message: 'Login failed.', + timeout: 2000, + }); + if (error instanceof AppwriteException) { Dialog.create({ title: 'Login Error!', - message: reason.message, + message: error.message, persistent: true, }); - }); + } + } } export { client, diff --git a/src/components/scheduling/boat/BoatScheduleTableComponent.vue b/src/components/scheduling/boat/BoatScheduleTableComponent.vue index a218f1d..fda3054 100644 --- a/src/components/scheduling/boat/BoatScheduleTableComponent.vue +++ b/src/components/scheduling/boat/BoatScheduleTableComponent.vue @@ -52,7 +52,8 @@ ) " > - {{ getUserName(reservation.user) || 'loading...' }} + {{ getUserName(reservation.user) || 'loading...' }}
+ {{ reservation.reason }} diff --git a/src/pages/LoginPage.vue b/src/pages/LoginPage.vue index 7aee481..976231c 100644 --- a/src/pages/LoginPage.vue +++ b/src/pages/LoginPage.vue @@ -30,8 +30,8 @@ filled > @@ -44,7 +44,7 @@ > --> - + @@ -69,8 +69,12 @@ diff --git a/src/pages/schedule/BoatReservationPage.vue b/src/pages/schedule/BoatReservationPage.vue index 3f7fd57..360dd40 100644 --- a/src/pages/schedule/BoatReservationPage.vue +++ b/src/pages/schedule/BoatReservationPage.vue @@ -1,7 +1,7 @@