update profile section
This commit is contained in:
@@ -37,6 +37,8 @@ export type {
|
||||
UpdateSectionDto,
|
||||
AssignSectionDto,
|
||||
UpdateAssignmentDto,
|
||||
SectionOrderItem,
|
||||
AgentTypeSectionsResponse,
|
||||
} from './profile-sections.service';
|
||||
|
||||
// Profile Fields Service
|
||||
|
||||
@@ -66,6 +66,26 @@ export interface UpdateAssignmentDto {
|
||||
isRequired?: boolean;
|
||||
}
|
||||
|
||||
export interface SectionOrderItem {
|
||||
sectionId: string;
|
||||
sortOrder: number;
|
||||
isRequired?: boolean;
|
||||
}
|
||||
|
||||
export interface AgentTypeSectionsResponse {
|
||||
agentType: {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
};
|
||||
sections: (ProfileSection & {
|
||||
isRequired: boolean;
|
||||
isGlobal: boolean;
|
||||
effectiveSortOrder: number;
|
||||
hasCustomOrder: boolean;
|
||||
})[];
|
||||
}
|
||||
|
||||
// Profile Sections Service
|
||||
class ProfileSectionsService {
|
||||
private basePath = '/profile-sections';
|
||||
@@ -121,6 +141,26 @@ class ProfileSectionsService {
|
||||
async removeFromAgentType(sectionId: string, agentTypeId: string): Promise<void> {
|
||||
await api.delete(`${this.basePath}/${sectionId}/assignment/${agentTypeId}`);
|
||||
}
|
||||
|
||||
// Agent Type Sections methods
|
||||
async getSectionsForAgentType(agentTypeId: string, includeFields = true): Promise<AgentTypeSectionsResponse> {
|
||||
const url = includeFields
|
||||
? `${this.basePath}/agent-type/${agentTypeId}`
|
||||
: `${this.basePath}/agent-type/${agentTypeId}?includeFields=false`;
|
||||
const response = await api.get<ApiResponse<AgentTypeSectionsResponse>>(url);
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
async updateSectionOrderForAgentType(
|
||||
agentTypeId: string,
|
||||
sectionOrders: SectionOrderItem[]
|
||||
): Promise<{ success: boolean; updated: number }> {
|
||||
const response = await api.patch<ApiResponse<{ success: boolean; updated: number }>>(
|
||||
`${this.basePath}/agent-type/${agentTypeId}/order`,
|
||||
{ sectionOrders }
|
||||
);
|
||||
return response.data.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const profileSectionsService = new ProfileSectionsService();
|
||||
|
||||
Reference in New Issue
Block a user