refactor: Configuration improvement
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m13s

This commit is contained in:
2024-06-17 15:37:45 -04:00
parent 6ec4a1e025
commit a409b0a5c7
2 changed files with 56 additions and 42 deletions

View File

@@ -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 = <AppwriteIDConfig>{};
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 {

View File

@@ -3,7 +3,7 @@
<q-card
v-for="boat in boats"
:key="boat.id"
class="mobile-card q-ma-sm">
class="q-ma-sm">
<q-card-section>
<q-img
:src="boat.imgSrc"