feat: add sort order to agent profile field value queries by section and field position

This commit is contained in:
pradeepkumar
2026-04-15 23:54:37 +05:30
parent 678630fa8e
commit 623fb9283f

View File

@@ -1071,7 +1071,7 @@ export class AgentsService {
throw new NotFoundException('Agent profile not found');
}
// Get all field values for this profile
// Get all field values for this profile, ordered by admin-defined section + field sort order
const fieldValues = await this.prisma.agentProfileFieldValue.findMany({
where: { agentProfileId: profile.id },
include: {
@@ -1092,6 +1092,10 @@ export class AgentsService {
},
},
},
orderBy: [
{ field: { section: { sortOrder: 'asc' } } },
{ field: { sortOrder: 'asc' } },
],
});
// Helper to resolve a raw value to its option label (for SELECT/RADIO/MULTI_SELECT fields)
@@ -1150,7 +1154,7 @@ export class AgentsService {
throw new NotFoundException('Agent profile not found');
}
// Get all field values for this profile
// Get all field values for this profile, ordered by admin-defined section + field sort order
const fieldValues = await this.prisma.agentProfileFieldValue.findMany({
where: { agentProfileId: profile.id },
include: {
@@ -1171,6 +1175,10 @@ export class AgentsService {
},
},
},
orderBy: [
{ field: { section: { sortOrder: 'asc' } } },
{ field: { sortOrder: 'asc' } },
],
});
// Helper to resolve a raw value to its option label (for SELECT/RADIO/MULTI_SELECT fields)