Basic Task Display

This commit is contained in:
2024-03-30 11:45:59 -04:00
parent 435438aaa8
commit d752898865
11 changed files with 169 additions and 37 deletions

View File

@@ -11,9 +11,20 @@ export interface Task extends Models.Document {
completed: boolean;
}
export interface TaskTag extends Models.Document {
name: string;
description: string;
}
export interface SkillTag extends Models.Document {
name: string;
description: string;
}
export const useTaskStore = defineStore('tasks', {
state: () => ({
tasks: [] as Task[],
taskTags: [] as TaskTag[],
skillTags: [] as SkillTag[],
}),
actions: {
@@ -28,6 +39,30 @@ export const useTaskStore = defineStore('tasks', {
console.error('Failed to fetch tasks', error);
}
},
async fetchTaskTags() {
// This is fine for a small number of tags, but more than a few hundred tags, we'd need to optimize
try {
const response = await databases.listDocuments(
AppwriteIds.databaseId,
AppwriteIds.collectionIdTaskTags
);
this.taskTags = response.documents as TaskTag[];
} catch (error) {
console.error('Failed to fetch tasks', error);
}
},
async fetchSkillTags() {
// This is fine for a small number of tags, but more than a few hundred tags, we'd need to optimize
try {
const response = await databases.listDocuments(
AppwriteIds.databaseId,
AppwriteIds.collectionIdSkillTags
);
this.skillTags = response.documents as SkillTag[];
} catch (error) {
console.error('Failed to fetch tasks', error);
}
},
async addTask(task: Task) {
try {
const response = await databases.createDocument(