diff --git a/src/boot/appwrite.ts b/src/boot/appwrite.ts index 17bc3b3..5b9b861 100644 --- a/src/boot/appwrite.ts +++ b/src/boot/appwrite.ts @@ -14,54 +14,68 @@ import type { Router } from 'vue-router'; const client = new Client(); -const VITE_APPWRITE_API_ENDPOINT = import.meta.env.VITE_APPWRITE_API_ENDPOINT; -const VITE_APPWRITE_API_PROJECT = import.meta.env.VITE_APPWRITE_API_PROJECT; +const API_ENDPOINT = import.meta.env.VITE_APPWRITE_API_ENDPOINT; +const API_PROJECT = import.meta.env.VITE_APPWRITE_API_PROJECT; -if (VITE_APPWRITE_API_ENDPOINT && VITE_APPWRITE_API_PROJECT) { - client - .setEndpoint(VITE_APPWRITE_API_ENDPOINT) - .setProject(VITE_APPWRITE_API_PROJECT); +if (API_ENDPOINT && API_PROJECT) { + client.setEndpoint(API_ENDPOINT).setProject(API_PROJECT); } else { console.error( 'Must configure VITE_APPWRITE_API_ENDPOINT and VITE_APPWRITE_API_PROJECT' ); } -const pwresetUrl = process.env.DEV - ? 'http://localhost:4000/pwreset' - : 'https://oys.undock.ca/pwreset'; +type AppwriteIDConfig = { + databaseId: string; + collection: { + boat: string; + reservation: string; + skillTags: string; + task: string; + taskTags: string; + interval: string; + intervalTemplate: string; + }; + function: { + userinfo: string; + }; +}; -const AppwriteIds = process.env.DEV - ? { - databaseId: '65ee1cbf9c2493faf15f', - collection: { - boat: 'boat', - reservation: 'reservation', - skillTags: 'skillTags', - task: 'task', - taskTags: 'taskTags', - interval: 'interval', - intervalTemplate: 'intervalTemplate', - }, - function: { - userinfo: 'userinfo', - }, - } - : { - databaseId: 'bab_prod', - collection: { - boat: 'boat', - reservation: 'reservation', - skillTags: 'skillTags', - task: 'task', - taskTags: 'taskTags', - interval: 'interval', - intervalTemplate: 'intervalTemplate', - }, - function: { - userinfo: '664038294b5473ef0c8d', - }, - }; +let AppwriteIds = {}; + +if (API_ENDPOINT === 'https://apidev.bab.toal.ca/v1') { + AppwriteIds = { + databaseId: '65ee1cbf9c2493faf15f', + collection: { + boat: 'boat', + reservation: 'reservation', + skillTags: 'skillTags', + task: 'task', + taskTags: 'taskTags', + interval: 'interval', + intervalTemplate: 'intervalTemplate', + }, + function: { + userinfo: 'userinfo', + }, + }; +} else if (API_ENDPOINT === 'https://appwrite.oys.undock.ca/v1') { + AppwriteIds = { + databaseId: 'bab_prod', + collection: { + boat: 'boat', + reservation: 'reservation', + skillTags: 'skillTags', + task: 'task', + taskTags: 'taskTags', + interval: 'interval', + intervalTemplate: 'intervalTemplate', + }, + function: { + userinfo: '664038294b5473ef0c8d', + }, + }; +} const account = new Account(client); const databases = new Databases(client); @@ -146,7 +160,7 @@ async function login(email: string, password: string) { } async function resetPassword(email: string) { - await account.createRecovery(email, pwresetUrl); + await account.createRecovery(email, window.location.origin + '/pwreset'); } export { diff --git a/src/components/boat/BoatPreviewComponent.vue b/src/components/boat/BoatPreviewComponent.vue index db478d2..3982d00 100644 --- a/src/components/boat/BoatPreviewComponent.vue +++ b/src/components/boat/BoatPreviewComponent.vue @@ -3,7 +3,7 @@ + class="q-ma-sm">