sef-global / scholarx-backend

This is the backend of the ScholarX
MIT License
10 stars 37 forks source link

Implement Set mentor availability endpoint (Admin) #28 #72

Closed sathudeva7 closed 11 months ago

sathudeva7 commented 11 months ago

Purpose

The purpose of this PR is to fix #28

Goals

This issue involves implementing an API to get all mentors. The endpoint should allow Admin to make a PUT request to /api/admin/mentor/{{mentorId}}/availability.

Approach

const existingMentor = await mentorRepository.findOne({
      where: { uuid: mentorId },
      select: [
        'application',
        'state',
        'availability',
        'uuid',
        'category',
        'profile',
        'created_at'
      ],
      relations: ['category', 'profile']
    })

    if (!existingMentor) {
      return {
        statusCode: 404,
        message: 'Mentor not found'
      }
    }

    existingMentor.availability = availability
    const mentor = await mentorRepository.save(existingMentor)

Screenshots

Checklist

Related PRs

## Test environment ## Learning