- 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
77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
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
|
|
}
|
|
}
|
|
) |