mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 12:32:10 +01:00
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:
@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user