144a8a4685
LST-69 (3.2) front. Client portal UI on the phase-1 backend. - New frontend/modules/client-portal/ layer: /portal (project cards from the client's allowedProjects via /me), /portal/projects/[id] (tickets list, detail modal, create modal with document upload), client-tickets service + DTO, CT-XXX formatting. - Front tenancy: auth.global.ts redirects a pure ROLE_CLIENT to /portal and blocks internal routes; portal pages open to any authenticated user. - Admin: UserDrawer manages client accounts (ROLE_CLIENT + client + allowedProjects); new "Tickets client" admin tab (list, filters, status change with required comment on reject, detail modal). - Kanban/my-tasks: client-ticket icon + tooltip when task.clientTicket is set (data via task:read, no extra call). TaskDocument upload generalized with a clientTicketId prop. getContent uses native fetch (text response). - i18n portal/clientTicket keys; sidebar /portal item (module client-portal). nuxt build passes; /portal routes present, existing routes intact.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import type { UserData, UserWrite } from './dto/user-data'
|
|
import type { HydraCollection } from '~/utils/api'
|
|
import { extractHydraMembers } from '~/utils/api'
|
|
|
|
export function useUserService() {
|
|
const api = useApi()
|
|
|
|
async function getAll(): Promise<UserData[]> {
|
|
const data = await api.get<HydraCollection<UserData>>('/users')
|
|
return extractHydraMembers(data)
|
|
}
|
|
|
|
async function getById(id: number): Promise<UserData> {
|
|
return api.get<UserData>(`/users/${id}`)
|
|
}
|
|
|
|
async function create(payload: UserWrite): Promise<UserData> {
|
|
return api.post<UserData>('/users', payload as Record<string, unknown>, {
|
|
toastSuccessKey: 'users.created',
|
|
})
|
|
}
|
|
|
|
async function update(id: number, payload: Partial<UserWrite>): Promise<UserData> {
|
|
return api.patch<UserData>(`/users/${id}`, payload as Record<string, unknown>, {
|
|
toastSuccessKey: 'users.updated',
|
|
})
|
|
}
|
|
|
|
async function remove(id: number): Promise<void> {
|
|
await api.delete(`/users/${id}`, {}, {
|
|
toastSuccessKey: 'users.deleted',
|
|
})
|
|
}
|
|
|
|
return { getAll, getById, create, update, remove }
|
|
}
|