Files
Lesstime/frontend/services/tasks.ts
matthieu ac11690ad4 feat : add task management with kanban and backlog
Add kanban board with drag-and-drop, backlog section, task/group
drawers, DTOs, services, and i18n translations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:40:48 +01:00

35 lines
1.1 KiB
TypeScript

import type { Task, TaskWrite } from './dto/task'
import type { HydraCollection } from '~/utils/api'
import { extractHydraMembers } from '~/utils/api'
export function useTaskService() {
const api = useApi()
async function getByProject(projectId: number): Promise<Task[]> {
const data = await api.get<HydraCollection<Task>>('/tasks', {
project: `/api/projects/${projectId}`,
})
return extractHydraMembers(data)
}
async function create(payload: TaskWrite): Promise<Task> {
return api.post<Task>('/tasks', payload as Record<string, unknown>, {
toastSuccessKey: 'tasks.created',
})
}
async function update(id: number, payload: Partial<TaskWrite>): Promise<Task> {
return api.patch<Task>(`/tasks/${id}`, payload as Record<string, unknown>, {
toastSuccessKey: 'tasks.updated',
})
}
async function remove(id: number): Promise<void> {
await api.delete(`/tasks/${id}`, {}, {
toastSuccessKey: 'tasks.deleted',
})
}
return { getByProject, create, update, remove }
}