Skip to content

Commit

Permalink
chore: use RoleName-type
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeppner-dataport committed Oct 23, 2024
1 parent c188f55 commit d568064
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { PaginationResponse } from '@shared/controller';
import { RoleName } from '@shared/domain/interface';

export class RoomParticipantResponse {
@ApiProperty()
Expand All @@ -12,7 +13,7 @@ export class RoomParticipantResponse {
fullName!: string;

@ApiProperty()
roleName!: string;
roleName!: RoleName;

@ApiProperty()
schoolName!: string;
Expand Down
17 changes: 10 additions & 7 deletions apps/server/src/modules/room/api/room.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiValidationError } from '@shared/common';
import { IFindOptions } from '@shared/domain/interface';
import { IFindOptions, RoleName } from '@shared/domain/interface';
import { ErrorResponse } from '@src/core/error/dto';
import { Room } from '../domain';
import { CreateRoomBodyParams } from './dto/request/create-room.body.params';
Expand Down Expand Up @@ -142,12 +142,15 @@ export class RoomController {
@CurrentUser() currentUser: ICurrentUser,
@Query() pagination: RoomPaginationParams
): Promise<RoomParticipantListResponse> {
const response = new RoomParticipantListResponse(
mockusers.map((user) => new RoomParticipantResponse(user)),
0,
pagination.skip,
pagination.limit
);
const participants = mockusers.map((user) => {
const mapRole = <Record<string, RoleName>>{
teacher: RoleName.TEACHER,
student: RoleName.STUDENT,
};
const data = { ...user, roleName: mapRole[user.roleName] };
return new RoomParticipantResponse(data);
});
const response = new RoomParticipantListResponse(participants, 0, pagination.skip, pagination.limit);

return Promise.resolve(response);
}
Expand Down

0 comments on commit d568064

Please sign in to comment.