feat: add role user modules and shared table updates

This commit is contained in:
2026-06-15 20:07:06 +05:30
parent 8d4ff49633
commit bea47d29d5
21 changed files with 1245 additions and 133 deletions

View File

@@ -0,0 +1,42 @@
import axiosClient from '../axios/axios';
import type { Role, RoleListParams, RoleListResponse, RoleRequest } from '@/types';
const ROLES_ENDPOINT = 'api/roles';
export const roleService = {
getRoles: async (params?: RoleListParams): Promise<RoleListResponse> => {
const response = await axiosClient.get<RoleListResponse>(ROLES_ENDPOINT, {
params: {
skip: params?.skip ?? 0,
limit: params?.limit ?? 10,
search_term: params?.search_term,
name: params?.name,
display_name: params?.display_name,
description: params?.description,
effective_status: params?.effective_status,
sort_by: params?.sort_by,
sort_order: params?.sort_order,
},
});
return response.data;
},
getRoleById: async (id: number): Promise<Role> => {
const response = await axiosClient.get<Role>(`${ROLES_ENDPOINT}/${id}`);
return response.data;
},
saveRole: async (payload: RoleRequest): Promise<Role> => {
const response = payload.id
? await axiosClient.put<Role>(ROLES_ENDPOINT, payload)
: await axiosClient.post<Role>(ROLES_ENDPOINT, payload);
return response.data;
},
updateRoleStatus: async (id: number, isActive: boolean): Promise<Role> => {
const response = await axiosClient.patch<Role>(`${ROLES_ENDPOINT}/${id}/status`, {
is_active: isActive,
});
return response.data;
},
};