conflict fixed

This commit is contained in:
Kalana B. Thilakarathna
2026-10-18 23:22:04 +05:30
103 changed files with 45836 additions and 1053 deletions
+23 -25
View File
@@ -1,41 +1,38 @@
import { api } from '@/lib/api'
import type {
PaginatedResponse,
UserResponse,
RoleResponse,
PermissionResponse,
} from '@/types/api'
import type { PageParams } from './master'
import type { UserResponse, RoleResponse, PermissionResponse } from '@/types/api'
// ─── Users ────────────────────────────────────────────────────────────────────
export interface UserBody {
export interface CreateUserBody {
username: string
password: string
fullName: string
roleId: string
reportsToUserId?: string | null
password?: string
isActive?: boolean
}
export interface UserListParams extends PageParams {
roleId?: string
search?: string
export interface UpdateUserBody {
fullName: string
}
export const users = {
list: (params?: UserListParams) =>
api.get<PaginatedResponse<UserResponse>>('/users', { params }).then(r => r.data),
list: () =>
api.get<UserResponse[]>('/users').then(r => r.data),
get: (id: string) =>
api.get<UserResponse>(`/users/${id}`).then(r => r.data),
create: (body: UserBody) =>
create: (body: CreateUserBody) =>
api.post<UserResponse>('/users', body).then(r => r.data),
update: (id: string, body: Partial<UserBody>) =>
update: (id: string, body: UpdateUserBody) =>
api.put<UserResponse>(`/users/${id}`, body).then(r => r.data),
assignRole: (id: string, roleId: string) =>
api.put<UserResponse>(`/users/${id}/role`, { roleId }).then(r => r.data),
deactivate: (id: string) =>
api.delete(`/users/${id}`),
}
// ─── Roles ────────────────────────────────────────────────────────────────────
@@ -43,11 +40,6 @@ export const users = {
export interface RoleBody {
name: string
level: number
isActive?: boolean
}
export interface RoleWithPermissions extends RoleResponse {
permissions: PermissionResponse[]
}
export const roles = {
@@ -55,16 +47,22 @@ export const roles = {
api.get<RoleResponse[]>('/roles').then(r => r.data),
get: (id: string) =>
api.get<RoleWithPermissions>(`/roles/${id}`).then(r => r.data),
api.get<RoleResponse>(`/roles/${id}`).then(r => r.data),
getPermissions: (id: string) =>
api.get<PermissionResponse[]>(`/roles/${id}/permissions`).then(r => r.data),
create: (body: RoleBody) =>
api.post<RoleResponse>('/roles', body).then(r => r.data),
update: (id: string, body: Partial<RoleBody>) =>
update: (id: string, body: RoleBody) =>
api.put<RoleResponse>(`/roles/${id}`, body).then(r => r.data),
assignPermissions: (id: string, permissionIds: string[]) =>
api.put(`/roles/${id}/permissions`, { permissionIds }).then(r => r.data),
deactivate: (id: string) =>
api.delete(`/roles/${id}`),
}
// ─── Permissions ──────────────────────────────────────────────────────────────