Files
Lesstime/frontend/services/task-groups.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

40 lines
1.4 KiB
TypeScript

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