feat: Implement dynamic agent profile editing by introducing new services and dynamic UI components.

This commit is contained in:
pradeepkumar
2026-01-24 20:36:22 +05:30
parent cb2e17c759
commit 5e2b3d8e83
12 changed files with 1133 additions and 705 deletions

View File

@@ -0,0 +1,66 @@
import api from './api';
// Types
export interface AgentType {
id: string;
name: string;
slug: string;
description: string | null;
}
export interface AgentProfile {
id: string;
userId: string;
firstName: string;
lastName: string;
slug: string;
email: string | null;
phone: string | null;
bio: string | null;
avatar: string | null;
licenseNumber: string | null;
experience: number | null;
specializations: string[];
languages: string[];
serviceAreas: string[];
rating: number | null;
reviewCount: number;
isVerified: boolean;
isFeatured: boolean;
isActive: boolean;
agentTypeId: string | null;
agentType: AgentType | null;
user?: {
id: string;
email: string;
avatar: string | null;
};
}
interface ApiResponse<T> {
success: boolean;
data: T;
message?: string;
}
// Agents Service for Web
class AgentsService {
private basePath = '/agents';
async getMyProfile(): Promise<AgentProfile> {
const response = await api.get<ApiResponse<AgentProfile>>(`${this.basePath}/profile/me`);
return response.data.data;
}
async getAgentById(id: string): Promise<AgentProfile> {
const response = await api.get<ApiResponse<AgentProfile>>(`${this.basePath}/${id}`);
return response.data.data;
}
async updateProfile(data: Partial<AgentProfile>): Promise<AgentProfile> {
const response = await api.put<ApiResponse<AgentProfile>>(`${this.basePath}/profile`, data);
return response.data.data;
}
}
export const agentsService = new AgentsService();