feat: add sort order to agent profile field value queries by section and field position
This commit is contained in:
@@ -1071,7 +1071,7 @@ export class AgentsService {
|
|||||||
throw new NotFoundException('Agent profile not found');
|
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({
|
const fieldValues = await this.prisma.agentProfileFieldValue.findMany({
|
||||||
where: { agentProfileId: profile.id },
|
where: { agentProfileId: profile.id },
|
||||||
include: {
|
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)
|
// 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');
|
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({
|
const fieldValues = await this.prisma.agentProfileFieldValue.findMany({
|
||||||
where: { agentProfileId: profile.id },
|
where: { agentProfileId: profile.id },
|
||||||
include: {
|
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)
|
// Helper to resolve a raw value to its option label (for SELECT/RADIO/MULTI_SELECT fields)
|
||||||
|
|||||||
Reference in New Issue
Block a user