import axiosClient from '../axios/axios'; import { API_ROUTES } from '@/constants/apiRoutes'; import type { Role, RoleListParams, RoleListResponse, RoleRequest, } from '@/types'; export const roleService = { getRoles: async (params?: RoleListParams): Promise => { const response = await axiosClient.get( API_ROUTES.ROLES.BASE, { 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 => { const response = await axiosClient.get(API_ROUTES.ROLES.DETAIL(id)); return response.data; }, saveRole: async (payload: RoleRequest): Promise => { const response = payload.id ? await axiosClient.put(API_ROUTES.ROLES.BASE, payload) : await axiosClient.post(API_ROUTES.ROLES.BASE, payload); return response.data; }, updateRoleStatus: async (id: number, isActive: boolean): Promise => { const response = await axiosClient.patch( API_ROUTES.ROLES.STATUS(id), { is_active: isActive, }, ); return response.data; }, };