@@ -4,19 +4,19 @@ import { addRating } from "@backend/types/schemaHelpers";
44import { bulkKeys , DEPARTMENT_LIST } from "@backend/utils/const" ;
55
66const changeDepartmentParser = z . object ( {
7- professorId : z . uuid ( ) ,
7+ professorId : z . string ( ) . uuid ( ) ,
88 department : z . enum ( DEPARTMENT_LIST ) ,
99} ) ;
1010
1111const changeNameParser = z . object ( {
12- professorId : z . uuid ( ) ,
12+ professorId : z . string ( ) . uuid ( ) ,
1313 firstName : z . string ( ) . trim ( ) ,
1414 lastName : z . string ( ) . trim ( ) ,
1515} ) ;
1616
1717const fixEscapedCharsParser = z . object ( {
1818 professors : z
19- . array ( z . uuid ( ) )
19+ . array ( z . string ( ) . uuid ( ) )
2020 . min ( 1 )
2121 . max ( 250 , "Separate your request into batches of 250 professors." ) ,
2222} ) ;
@@ -30,22 +30,28 @@ export const adminRouter = t.router({
3030 getPendingProfessors : protectedProcedure . query ( ( { ctx } ) =>
3131 ctx . env . kvDao . getAllPendingProfessors ( ) ,
3232 ) ,
33- approvePendingProfessor : protectedProcedure . input ( z . uuid ( ) ) . mutation ( async ( { ctx, input } ) => {
34- const pendingProfessor = await ctx . env . kvDao . getPendingProfessor ( input ) ;
33+ approvePendingProfessor : protectedProcedure
34+ . input ( z . string ( ) . uuid ( ) )
35+ . mutation ( async ( { ctx, input } ) => {
36+ const pendingProfessor = await ctx . env . kvDao . getPendingProfessor ( input ) ;
3537
36- await ctx . env . kvDao . putProfessor ( pendingProfessor ) ;
37- await ctx . env . kvDao . removePendingProfessor ( input ) ;
38- } ) ,
39- rejectPendingProfessor : protectedProcedure . input ( z . uuid ( ) ) . mutation ( async ( { input, ctx } ) => {
40- await ctx . env . kvDao . removePendingProfessor ( input ) ;
41- } ) ,
42- removeProfessor : protectedProcedure . input ( z . uuid ( ) ) . mutation ( async ( { input, ctx } ) => {
43- await ctx . env . kvDao . removeProfessor ( input ) ;
44- } ) ,
38+ await ctx . env . kvDao . putProfessor ( pendingProfessor ) ;
39+ await ctx . env . kvDao . removePendingProfessor ( input ) ;
40+ } ) ,
41+ rejectPendingProfessor : protectedProcedure
42+ . input ( z . string ( ) . uuid ( ) )
43+ . mutation ( async ( { input, ctx } ) => {
44+ await ctx . env . kvDao . removePendingProfessor ( input ) ;
45+ } ) ,
46+ removeProfessor : protectedProcedure
47+ . input ( z . string ( ) . uuid ( ) )
48+ . mutation ( async ( { input, ctx } ) => {
49+ await ctx . env . kvDao . removeProfessor ( input ) ;
50+ } ) ,
4551
4652 // Takes reviews of target professor and applies them to dest and then removes the target professor
4753 mergeProfessor : protectedProcedure
48- . input ( z . object ( { destId : z . uuid ( ) , sourceId : z . uuid ( ) } ) )
54+ . input ( z . object ( { destId : z . string ( ) . uuid ( ) , sourceId : z . string ( ) . uuid ( ) } ) )
4955 . mutation ( async ( { ctx, input : { destId, sourceId } } ) => {
5056 const destProfessor = await ctx . env . kvDao . getProfessor ( destId ) ;
5157 const sourceProfessor = await ctx . env . kvDao . getProfessor ( sourceId ) ;
@@ -96,10 +102,10 @@ export const adminRouter = t.router({
96102 . mutation ( async ( { ctx, input : { bulkKey, keys } } ) =>
97103 ctx . env . kvDao . getBulkValues ( bulkKey , keys ) ,
98104 ) ,
99- removeReport : protectedProcedure . input ( z . uuid ( ) ) . mutation ( async ( { ctx, input } ) => {
105+ removeReport : protectedProcedure . input ( z . string ( ) . uuid ( ) ) . mutation ( async ( { ctx, input } ) => {
100106 await ctx . env . kvDao . removeReport ( input ) ;
101107 } ) ,
102- actOnReport : protectedProcedure . input ( z . uuid ( ) ) . mutation ( async ( { ctx, input } ) => {
108+ actOnReport : protectedProcedure . input ( z . string ( ) . uuid ( ) ) . mutation ( async ( { ctx, input } ) => {
103109 const report = await ctx . env . kvDao . getReport ( input ) ;
104110 await ctx . env . kvDao . removeRating ( report . professorId , report . ratingId ) ;
105111 await ctx . env . kvDao . removeReport ( input ) ;
0 commit comments