Skip to content

Commit

Permalink
add mentee route and status validation, unit test were previously in …
Browse files Browse the repository at this point in the history
…the code
  • Loading branch information
dileepainivossl committed Jul 14, 2024
1 parent 0df9fb3 commit c6cdc90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/controllers/admin/mentee.controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Request, Response } from 'express'
import { ApplicationStatus, ProfileTypes, StatusUpdatedBy } from '../../enums'
import type Profile from '../../entities/profile.entity'
import type Mentee from '../../entities/mentee.entity'
import type { ApiResponse } from '../../types'
import type Profile from '../../entities/profile.entity'
import { ApplicationStatus, ProfileTypes, StatusUpdatedBy } from '../../enums'
import {
getAllMenteeEmailsService,
getAllMentees,
getMentee,
updateStatus
} from '../../services/admin/mentee.service'
import type { ApiResponse } from '../../types'

export const getMentees = async (
req: Request,
Expand All @@ -24,7 +24,7 @@ export const getMentees = async (
return res.status(403).json({ message: 'Only Admins are allowed' })
}

if (status && !(status.toUpperCase() in ApplicationStatus)) {
if (status && !Object.values(ApplicationStatus).includes(status)) {
return res.status(400).json({ message: 'Please provide a valid status' })
}

Expand Down
6 changes: 4 additions & 2 deletions src/routes/admin/mentee/mentee.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {

const menteeRouter = express.Router()

menteeRouter.get('/emails/', requireAuth, getAllMenteeEmails)
menteeRouter.get('/applications', requireAuth, getMentees)
menteeRouter.get('/', requireAuth, getMentees)
menteeRouter.get('/emails', requireAuth, getAllMenteeEmails)
// TODO: Remove this route
// menteeRouter.get('/applications', requireAuth, getMentees)
menteeRouter.get('/:menteeId', requireAuth, getMenteeDetails)
menteeRouter.put('/:menteeId/state', requireAuth, updateMenteeStatus)

Expand Down

0 comments on commit c6cdc90

Please sign in to comment.