From a395dcee34c020b2ce0a9e49f21ceeb8a6b7b58c Mon Sep 17 00:00:00 2001 From: Bryann Yeap Kok Keong Date: Tue, 8 Nov 2022 22:47:06 +0800 Subject: [PATCH] [offers][chore] Add sorting dashboard offers by company name --- apps/portal/prisma/seed-analysis.ts | 7 +++---- apps/portal/src/server/router/offers/offers.ts | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/apps/portal/prisma/seed-analysis.ts b/apps/portal/prisma/seed-analysis.ts index 74d96822..ab249a57 100644 --- a/apps/portal/prisma/seed-analysis.ts +++ b/apps/portal/prisma/seed-analysis.ts @@ -23,17 +23,16 @@ const seedAnalysis = async () => { while (i < profilesWithoutAnalysis.length) { const profile = profilesWithoutAnalysis[i]; + await generateAnalysis({ ctx: { prisma, session: null }, input: { profileId: profile.id }, }); - i++; - - console.log(i, ': Analysis generated for profile with id', profile.id); + console.log(++i, ': Analysis generated for profile with id', profile.id); } - console.log(i, ' analysis generated'); + console.log(i, 'analysis generated'); }; Promise.all([seedAnalysis()]) diff --git a/apps/portal/src/server/router/offers/offers.ts b/apps/portal/src/server/router/offers/offers.ts index ef425121..ff0d16af 100644 --- a/apps/portal/src/server/router/offers/offers.ts +++ b/apps/portal/src/server/router/offers/offers.ts @@ -17,6 +17,7 @@ const getOrder = (prefix: string) => { }; const sortingKeysMap = { + companyName: 'companyName', monthYearReceived: 'monthYearReceived', totalCompensation: 'totalCompensation', totalYoe: 'totalYoe', @@ -138,6 +139,14 @@ export const offersRouter = createRouter().query('list', { monthYearReceived: 'desc', }, ] + : sortingKey === sortingKeysMap.companyName + ? [ + { + company: { + name: order, + }, + }, + ] : { monthYearReceived: 'desc' }, where: { AND: [ @@ -268,6 +277,14 @@ export const offersRouter = createRouter().query('list', { monthYearReceived: 'desc', }, ] + : sortingKey === sortingKeysMap.companyName + ? [ + { + company: { + name: order, + }, + }, + ] : { monthYearReceived: 'desc' }, where: { AND: [