[offers][chore] Add sorting dashboard offers by company name

pull/541/head
Bryann Yeap Kok Keong 2 years ago
parent 237b08442e
commit a395dcee34

@ -23,17 +23,16 @@ const seedAnalysis = async () => {
while (i < profilesWithoutAnalysis.length) { while (i < profilesWithoutAnalysis.length) {
const profile = profilesWithoutAnalysis[i]; const profile = profilesWithoutAnalysis[i];
await generateAnalysis({ await generateAnalysis({
ctx: { prisma, session: null }, ctx: { prisma, session: null },
input: { profileId: profile.id }, 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()]) Promise.all([seedAnalysis()])

@ -17,6 +17,7 @@ const getOrder = (prefix: string) => {
}; };
const sortingKeysMap = { const sortingKeysMap = {
companyName: 'companyName',
monthYearReceived: 'monthYearReceived', monthYearReceived: 'monthYearReceived',
totalCompensation: 'totalCompensation', totalCompensation: 'totalCompensation',
totalYoe: 'totalYoe', totalYoe: 'totalYoe',
@ -138,6 +139,14 @@ export const offersRouter = createRouter().query('list', {
monthYearReceived: 'desc', monthYearReceived: 'desc',
}, },
] ]
: sortingKey === sortingKeysMap.companyName
? [
{
company: {
name: order,
},
},
]
: { monthYearReceived: 'desc' }, : { monthYearReceived: 'desc' },
where: { where: {
AND: [ AND: [
@ -268,6 +277,14 @@ export const offersRouter = createRouter().query('list', {
monthYearReceived: 'desc', monthYearReceived: 'desc',
}, },
] ]
: sortingKey === sortingKeysMap.companyName
? [
{
company: {
name: order,
},
},
]
: { monthYearReceived: 'desc' }, : { monthYearReceived: 'desc' },
where: { where: {
AND: [ AND: [

Loading…
Cancel
Save