feat(sessions): add missing language, sortKey, and sortOrder filtering support

- Add language field with ISO 639-1 validation to sessionFilterSchema
- Add sortKey enum with startTime, category, language, sentiment, sessionId options
- Add sortOrder enum with asc/desc options
- Update tRPC router to support new filtering and sorting parameters
- Uncomment frontend code to enable full filtering functionality
- Add comprehensive validation tests for new schema fields

Resolves commented out filter options in app/dashboard/sessions/page.tsx lines 491-502
This commit is contained in:
2025-07-13 23:07:28 +02:00
parent 1427f05390
commit 04d415f2cc
4 changed files with 58 additions and 6 deletions

View File

@ -21,8 +21,18 @@ export const dashboardRouter = router({
getSessions: companyProcedure
.input(sessionFilterSchema)
.query(async ({ input, ctx }) => {
const { search, sentiment, category, startDate, endDate, page, limit } =
input;
const {
search,
sentiment,
category,
language,
startDate,
endDate,
sortKey,
sortOrder,
page,
limit,
} = input;
// Build where clause
const where: Prisma.SessionWhereInput = {
@ -44,6 +54,10 @@ export const dashboardRouter = router({
where.category = category;
}
if (language) {
where.language = language;
}
if (startDate || endDate) {
where.startTime = {};
if (startDate) {
@ -89,7 +103,7 @@ export const dashboardRouter = router({
orderBy: { order: "asc" },
},
},
orderBy: { startTime: "desc" },
orderBy: { [sortKey]: sortOrder },
skip: (page - 1) * limit,
take: limit,
});