refactor : rename TaskType to TaskTag across the stack

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-13 08:20:21 +01:00
parent dbae1f7536
commit 56275a9ebe
16 changed files with 216 additions and 117 deletions

View File

@@ -1,11 +1,11 @@
export type TaskType = {
export type TaskTag = {
id: number
'@id'?: string
label: string
color: string
}
export type TaskTypeWrite = {
export type TaskTagWrite = {
label: string
color: string
}

View File

@@ -1,7 +1,7 @@
import type { UserData } from './user-data'
import type { Project } from './project'
import type { Task } from './task'
import type { TaskType } from './task-type'
import type { TaskTag } from './task-tag'
export type TimeEntry = {
id: number
@@ -13,7 +13,7 @@ export type TimeEntry = {
user: UserData
project: Project | null
task: Task | null
types: TaskType[]
tags: TaskTag[]
}
export type TimeEntryWrite = {
@@ -24,5 +24,5 @@ export type TimeEntryWrite = {
user: string
project?: string | null
task?: string | null
types?: string[]
tags?: string[]
}

View File

@@ -0,0 +1,32 @@
import type { TaskTag, TaskTagWrite } from './dto/task-tag'
import type { HydraCollection } from '~/utils/api'
import { extractHydraMembers } from '~/utils/api'
export function useTaskTagService() {
const api = useApi()
async function getAll(): Promise<TaskTag[]> {
const data = await api.get<HydraCollection<TaskTag>>('/task_tags')
return extractHydraMembers(data)
}
async function create(payload: TaskTagWrite): Promise<TaskTag> {
return api.post<TaskTag>('/task_tags', payload as Record<string, unknown>, {
toastSuccessKey: 'taskTags.created',
})
}
async function update(id: number, payload: Partial<TaskTagWrite>): Promise<TaskTag> {
return api.patch<TaskTag>(`/task_tags/${id}`, payload as Record<string, unknown>, {
toastSuccessKey: 'taskTags.updated',
})
}
async function remove(id: number): Promise<void> {
await api.delete(`/task_tags/${id}`, {}, {
toastSuccessKey: 'taskTags.deleted',
})
}
return { getAll, create, update, remove }
}

View File

@@ -1,32 +0,0 @@
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 }
}