Skip to content

Commit

Permalink
Get all consultant booking for admin and general staff
Browse files Browse the repository at this point in the history
  • Loading branch information
nghiavohuynhdai committed Mar 12, 2024
1 parent 54aca1c commit a9f753f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/consultant-booking/controllers/provider.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ export class ConsultantBookingProviderController {
@ApiQuery({ type: PaginationQuery })
@ApiOkResponse({ type: ConsultantBookingPaginateResponseDto })
async paginate(@Req() req, @Pagination() paginationParams: PaginationParams) {
const staffId = _.get(req, 'user._id')
const { _id, role } = _.get(req, 'user')
if ([UserRole.ADMIN, UserRole.STAFF].includes(role)) {
return await this.consultantBookingService.paginate({}, paginationParams)
}

const staffId = _id
return await this.consultantBookingService.paginate(
{ 'consultant._id': new Types.ObjectId(staffId) },
paginationParams
Expand All @@ -45,7 +50,12 @@ export class ConsultantBookingProviderController {
@ApiOkResponse({ type: ConsultantBookingResponseDto })
@ApiBadRequestResponse({ type: ErrorResponse })
async getOne(@Req() req, @Param('bookingId', ParseObjectIdPipe) bookingId: string) {
const staffId = _.get(req, 'user._id')
const { _id, role } = _.get(req, 'user')
if ([UserRole.ADMIN, UserRole.STAFF].includes(role)) {
return await this.consultantBookingService.getOne({ _id: bookingId })
}

const staffId = _id
return await this.consultantBookingService.getOne({ 'consultant._id': new Types.ObjectId(staffId), _id: bookingId })
}
}

0 comments on commit a9f753f

Please sign in to comment.