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>
33 lines
1.1 KiB
TypeScript
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 }
|
|
}
|