Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mentee route and status validation, unit test were previously in … #135

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
dsmabulage marked this conversation as resolved.
Show resolved Hide resolved
menteeRouter.get('/:menteeId', requireAuth, getMenteeDetails)
menteeRouter.put('/:menteeId/state', requireAuth, updateMenteeStatus)

Expand Down
Loading