feat(project-management) : extract Projects/Tasks front into Nuxt module layer
Tranche 4 of LST-65. Companion to the backend module migration.
- Move pages (my-tasks, projects, projects/[id]/{index,groups,archives}),
18 components (project + task), 10 services and 10 DTOs into
frontend/modules/project-management/ (auto-detected layer).
- Rewrite explicit ~/services/* and ~/services/dto/* imports across 38
consumers (admin tabs, mail modals, dashboard, mail page, layout) including
the time-tracking module whose DTOs referenced project/task/task-tag.
- clients.ts and shared DTOs (client, user-data) stay at the root.
- Routes /my-tasks, /projects, /projects/:id(/groups|/archives) preserved;
i18n stays global.
nuxt build passes; routes confirmed.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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 }
|
||||
}
|
||||
Reference in New Issue
Block a user