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

33 lines
1.1 KiB
TypeScript

import type { TaskType, TaskTypeWrite } from './dto/task-type'
import type { HydraCollection } from '~/utils/api'
import { extractHydraMembers } from '~/utils/api'
export function useTaskTypeService() {
const api = useApi()
async function getAll(): Promise<TaskType[]> {
const data = await api.get<HydraCollection<TaskType>>('/task_types')
return extractHydraMembers(data)
}
async function create(payload: TaskTypeWrite): Promise<TaskType> {
return api.post<TaskType>('/task_types', payload as Record<string, unknown>, {
toastSuccessKey: 'taskTypes.created',
})
}
async function update(id: number, payload: Partial<TaskTypeWrite>): Promise<TaskType> {
return api.patch<TaskType>(`/task_types/${id}`, payload as Record<string, unknown>, {
toastSuccessKey: 'taskTypes.updated',
})
}
async function remove(id: number): Promise<void> {
await api.delete(`/task_types/${id}`, {}, {
toastSuccessKey: 'taskTypes.deleted',
})
}
return { getAll, create, update, remove }
}