File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,12 @@ import { TRPCError } from '@trpc/server';
22import { z } from 'zod' ;
33
44import { Semester as PlanSemester } from '@/components/planner/types' ;
5- import {
6- createNewYear ,
7- createSemesterCodeRange ,
8- isSemesterEarlier ,
9- isSemesterLater ,
10- } from '@/utils/utilFunctions' ;
5+ import { createNewYear , createSemesterCodeRange } from '@/utils/utilFunctions' ;
116
127import { protectedProcedure , router } from '../trpc' ;
138import { Prisma , SemesterCode , Semester } from '@prisma/client' ;
149import { ObjectId } from 'bson' ;
10+ import { isEarlierSemester } from '@/utils/plannerUtils' ;
1511
1612export const planRouter = router ( {
1713 // Protected route: route uses session user id to find user plans
@@ -53,6 +49,13 @@ export const planRouter = router({
5349 } ,
5450 } ) ;
5551
52+ // Make sure semesters are in right orer
53+ if ( planData && planData . semesters ) {
54+ planData . semesters = planData . semesters . sort ( ( a , b ) =>
55+ isEarlierSemester ( a . code , b . code ) ? - 1 : 1 ,
56+ ) ;
57+ }
58+
5659 if ( ! planData ) {
5760 throw new TRPCError ( {
5861 code : 'NOT_FOUND' ,
Original file line number Diff line number Diff line change @@ -367,6 +367,9 @@ export const userRouter = router({
367367 } ,
368368 } ,
369369 } ,
370+ orderBy : {
371+ semester : 'asc' ,
372+ } ,
370373 } ,
371374 } ,
372375 } ) ;
You can’t perform that action at this time.
0 commit comments