feat(tasking): add projects feature and restructure backend
- Restructure backend code into Tasking module with organized endpoints - Add Project and Sprint entities with database migrations - Implement CRUD endpoints for projects (create, get, rename, delete) - Refactor task endpoints into Tasking namespace - Add integration test suite with Testcontainers and Respawn - Refactor frontend to use Pinia stores with dedicated API clients - Add DueDatePicker and DueTimePicker components for task scheduling - Add environment configuration for API base URL - Add infrastructure setup scripts for Docker/Postgres
This commit is contained in:
77
Tasker.Ui/src/stores/projectStore.ts
Normal file
77
Tasker.Ui/src/stores/projectStore.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { projectsApiClient } from '@/stores/projectsApiClient'
|
||||
import type { Project } from '@/stores/project'
|
||||
|
||||
export const useProjectStore = defineStore(
|
||||
'projectStore',
|
||||
() => {
|
||||
const projects = ref<Project[]>([])
|
||||
const isLoading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
projectsApiClient
|
||||
.getProjects()
|
||||
.then(t => projects.value = t)
|
||||
.catch(e => error.value = (e as Error).message)
|
||||
.finally(isLoading.value = false)
|
||||
|
||||
const fetchProjects = async () => {
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
projects.value = await projectsApiClient.getProjects()
|
||||
} catch (err) {
|
||||
error.value = (err as Error).message
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const addProject = async (project: project) => {
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const newProject = await projectsApiClient.createProject(project)
|
||||
projects.value.push(newProject)
|
||||
} catch (err) {
|
||||
error.value = (err as Error).message
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const completeProject = async (project: Project) => {
|
||||
isLoading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
if (project.completedOn) {
|
||||
await projectsApiClient.uncompleteProject(project.id)
|
||||
project.completedOn = null
|
||||
} else {
|
||||
project.completedOn = new Date().toISOString()
|
||||
await projectsApiClient.completeProject(
|
||||
{
|
||||
id: project.id,
|
||||
completedOn: project.completedOn
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = (err as Error).message
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
projects,
|
||||
isLoading,
|
||||
error,
|
||||
fetchProjects,
|
||||
addProject,
|
||||
completeProject
|
||||
}
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user