This commit is contained in:
pradeepkumar
2026-01-24 03:33:48 +05:30
parent 7b8b43f998
commit 909c22dc45
11 changed files with 2246 additions and 7 deletions

View File

@@ -0,0 +1,66 @@
import api, { ApiResponse } from './api';
// Types
export interface AgentType {
id: string;
name: string;
description: string | null;
icon: string | null;
isActive: boolean;
sortOrder: number;
createdAt: string;
updatedAt: string;
_count?: {
agents: number;
};
}
export interface CreateAgentTypeDto {
name: string;
description?: string;
icon?: string;
isActive?: boolean;
sortOrder?: number;
}
export interface UpdateAgentTypeDto {
name?: string;
description?: string;
icon?: string;
isActive?: boolean;
sortOrder?: number;
}
// Agent Types Service
class AgentTypesService {
private basePath = '/agent-types';
async getAll(includeInactive = false): Promise<AgentType[]> {
const url = includeInactive
? `${this.basePath}?includeInactive=true`
: this.basePath;
const response = await api.get<ApiResponse<AgentType[]>>(url);
return response.data.data;
}
async getById(id: string): Promise<AgentType> {
const response = await api.get<ApiResponse<AgentType>>(`${this.basePath}/${id}`);
return response.data.data;
}
async create(data: CreateAgentTypeDto): Promise<AgentType> {
const response = await api.post<ApiResponse<AgentType>>(this.basePath, data);
return response.data.data;
}
async update(id: string, data: UpdateAgentTypeDto): Promise<AgentType> {
const response = await api.patch<ApiResponse<AgentType>>(`${this.basePath}/${id}`, data);
return response.data.data;
}
async delete(id: string): Promise<void> {
await api.delete(`${this.basePath}/${id}`);
}
}
export const agentTypesService = new AgentTypesService();