Skip to content

Commit

Permalink
Styling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jennymar committed Oct 6, 2024
1 parent 2a6599c commit afdb442
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 337 deletions.
30 changes: 12 additions & 18 deletions api/controllers/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,17 @@ export class AdminController {
async getAllNamesAndEmails(
@AuthenticatedUser() user: UserModel,
): Promise<GetAllNamesAndEmailsResponse> {
if (!PermissionsService.canSeeAllUserEmails(user))
throw new ForbiddenError();
if (!PermissionsService.canSeeAllUserEmails(user)) throw new ForbiddenError();
const namesAndEmails = await this.userAccountService.getAllNamesAndEmails();
return { error: null, namesAndEmails };
}

@Post('/milestone')
async createMilestone(
@Body() createMilestoneRequest: CreateMilestoneRequest,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<CreateMilestoneResponse> {
if (!PermissionsService.canCreateMilestones(user))
throw new ForbiddenError();
if (!PermissionsService.canCreateMilestones(user)) throw new ForbiddenError();
await this.userAccountService.createMilestone(
createMilestoneRequest.milestone,
);
Expand All @@ -78,10 +76,9 @@ export class AdminController {
@Post('/bonus')
async addBonus(
@Body() createBonusRequest: CreateBonusRequest,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<CreateBonusResponse> {
if (!PermissionsService.canGrantPointBonuses(user))
throw new ForbiddenError();
if (!PermissionsService.canGrantPointBonuses(user)) throw new ForbiddenError();
const { bonus } = createBonusRequest;
const emails = bonus.users.map((e) => e.toLowerCase());
await this.userAccountService.grantBonusPoints(
Expand All @@ -97,7 +94,7 @@ export class AdminController {
@UploadedFile('image', {
options: StorageService.getFileOptions(MediaType.BANNER),
})
file: File,
file: File,
): Promise<UploadBannerResponse> {
const banner = await this.storageService.upload(
file,
Expand All @@ -110,10 +107,9 @@ export class AdminController {
@Post('/attendance')
async submitAttendanceForUsers(
@Body() submitAttendanceForUsersRequest: SubmitAttendanceForUsersRequest,
@AuthenticatedUser() currentUser: UserModel,
@AuthenticatedUser() currentUser: UserModel,
): Promise<SubmitAttendanceForUsersResponse> {
if (!PermissionsService.canSubmitAttendanceForUsers(currentUser))
throw new ForbiddenError();
if (!PermissionsService.canSubmitAttendanceForUsers(currentUser)) throw new ForbiddenError();
const { users, event, asStaff } = submitAttendanceForUsersRequest;
const emails = users.map((e) => e.toLowerCase());
const attendances = await this.attendanceService.submitAttendanceForUsers(
Expand All @@ -128,10 +124,9 @@ export class AdminController {
@Patch('/access')
async updateUserAccessLevel(
@Body() modifyUserAccessLevelRequest: ModifyUserAccessLevelRequest,
@AuthenticatedUser() currentUser: UserModel,
@AuthenticatedUser() currentUser: UserModel,
): Promise<ModifyUserAccessLevelResponse> {
if (!PermissionsService.canModifyUserAccessLevel(currentUser))
throw new ForbiddenError();
if (!PermissionsService.canModifyUserAccessLevel(currentUser)) throw new ForbiddenError();
const { accessUpdates } = modifyUserAccessLevelRequest;
const emails = accessUpdates.map((e) => e.user.toLowerCase());
const updatedUsers = await this.userAccountService.updateUserAccessLevels(
Expand All @@ -146,12 +141,11 @@ export class AdminController {
async getAllUsersWithAccessLevels(
@AuthenticatedUser() user: UserModel,
): Promise<GetAllUserAccessLevelsResponse> {
if (!PermissionsService.canSeeAllUserAccessLevels(user))
throw new ForbiddenError();
if (!PermissionsService.canSeeAllUserAccessLevels(user)) throw new ForbiddenError();
const users = await this.userAccountService.getAllFullUserProfiles();
return {
error: null,
users: users.map((user) => user.getFullUserProfile()),
users: users.map((u) => u.getFullUserProfile()),
};
}
}
24 changes: 8 additions & 16 deletions api/controllers/AttendanceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ export class AttendanceController {
@Get('/:uuid')
async getAttendancesForEvent(
@Params() params: UuidParam,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<GetAttendancesForEventResponse> {
if (!PermissionsService.canSeeEventAttendances(user))
throw new ForbiddenError();
if (!PermissionsService.canSeeEventAttendances(user)) throw new ForbiddenError();
const attendances = await this.attendanceService.getAttendancesForEvent(
params.uuid,
);
return {
error: null,
attendances: attendances.map((attendance) =>
attendance.getPublicAttendance(),
),
attendances: attendances.map((attendance) => attendance.getPublicAttendance()),
};
}

Expand All @@ -62,21 +59,18 @@ export class AttendanceController {
async getAttendancesForCurrentUser(
@AuthenticatedUser() user: UserModel,
): Promise<GetAttendancesForUserResponse> {
const attendances =
await this.attendanceService.getAttendancesForCurrentUser(user);
const attendances = await this.attendanceService.getAttendancesForCurrentUser(user);
return {
error: null,
attendances: attendances.map((attendance) =>
attendance.getPublicAttendance(),
),
attendances: attendances.map((attendance) => attendance.getPublicAttendance()),
};
}

@UseBefore(UserAuthentication)
@Get('/user/:uuid')
async getAttendancesForUser(
@Params() params: UuidParam,
@AuthenticatedUser() currentUser: UserModel,
@AuthenticatedUser() currentUser: UserModel,
): Promise<GetAttendancesForEventResponse> {
if (params.uuid === currentUser.uuid) {
return this.getAttendancesForCurrentUser(currentUser);
Expand All @@ -86,17 +80,15 @@ export class AttendanceController {
);
return {
error: null,
attendances: attendances.map((attendance) =>
attendance.getPublicAttendance(),
),
attendances: attendances.map((attendance) => attendance.getPublicAttendance()),
};
}

@UseBefore(UserAuthentication)
@Post()
async attendEvent(
@Body() body: AttendEventRequest,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<AttendEventResponse> {
const attendance = await this.attendanceService.attendEvent(
user,
Expand Down
36 changes: 16 additions & 20 deletions api/controllers/EventController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ export class EventController {
@Get('/past')
async getPastEvents(
@QueryParams() options: EventSearchOptions,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<GetPastEventsResponse> {
const canSeeAttendanceCode =
!!user && PermissionsService.canEditEvents(user);
const canSeeAttendanceCode = !!user && PermissionsService.canEditEvents(user);
const events = await this.eventService.getPastEvents(options);
return {
error: null,
Expand All @@ -78,10 +77,9 @@ export class EventController {
@Get('/future')
async getFutureEvents(
@QueryParams() options: EventSearchOptions,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<GetFutureEventsResponse> {
const canSeeAttendanceCode =
!!user && PermissionsService.canEditEvents(user);
const canSeeAttendanceCode = !!user && PermissionsService.canEditEvents(user);
const events = await this.eventService.getFutureEvents(options);
return {
error: null,
Expand All @@ -95,9 +93,9 @@ export class EventController {
@UploadedFile('image', {
options: StorageService.getFileOptions(MediaType.EVENT_COVER),
})
file: File,
@Params() params: UuidParam,
@AuthenticatedUser() user: UserModel,
file: File,
@Params() params: UuidParam,
@AuthenticatedUser() user: UserModel,
): Promise<UpdateEventCoverResponse> {
if (!PermissionsService.canEditEvents(user)) throw new ForbiddenError();
const cover = await this.storageService.upload(
Expand All @@ -112,7 +110,7 @@ export class EventController {
@UseBefore(UserAuthentication)
@Post('/:uuid/feedback')
async submitEventFeedback(
@Params() params: UuidParam,
@Params() params: UuidParam,
@Body() submitEventFeedbackRequest: SubmitEventFeedbackRequest,
@AuthenticatedUser() user: UserModel,
) {
Expand All @@ -129,10 +127,9 @@ export class EventController {
@Get('/:uuid')
async getOneEvent(
@Params() params: UuidParam,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<GetOneEventResponse> {
const canSeeAttendanceCode =
!!user && PermissionsService.canEditEvents(user);
const canSeeAttendanceCode = !!user && PermissionsService.canEditEvents(user);
const event = await this.eventService.findByUuid(params.uuid);
return { error: null, event: event.getPublicEvent(canSeeAttendanceCode) };
}
Expand All @@ -141,8 +138,8 @@ export class EventController {
@Patch('/:uuid')
async updateEvent(
@Params() params: UuidParam,
@Body() patchEventRequest: PatchEventRequest,
@AuthenticatedUser() user: UserModel,
@Body() patchEventRequest: PatchEventRequest,
@AuthenticatedUser() user: UserModel,
): Promise<PatchEventResponse> {
if (!PermissionsService.canEditEvents(user)) throw new ForbiddenError();
const event = await this.eventService.updateByUuid(
Expand All @@ -156,7 +153,7 @@ export class EventController {
@Delete('/:uuid')
async deleteEvent(
@Params() params: UuidParam,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<DeleteEventResponse> {
if (!PermissionsService.canEditEvents(user)) throw new ForbiddenError();
await this.eventService.deleteByUuid(params.uuid);
Expand All @@ -167,10 +164,9 @@ export class EventController {
@Get()
async getAllEvents(
@QueryParams() options: EventSearchOptions,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<GetAllEventsResponse> {
const canSeeAttendanceCode =
!!user && PermissionsService.canEditEvents(user);
const canSeeAttendanceCode = !!user && PermissionsService.canEditEvents(user);
const events = await this.eventService.getAllEvents(options);
return {
error: null,
Expand All @@ -182,7 +178,7 @@ export class EventController {
@Post()
async createEvent(
@Body() createEventRequest: CreateEventRequest,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<CreateEventResponse> {
if (!PermissionsService.canEditEvents(user)) throw new ForbiddenError();
const event = await this.eventService.create(createEventRequest.event);
Expand Down
8 changes: 4 additions & 4 deletions api/controllers/FeedbackController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class FeedbackController {
@Get()
async getFeedback(
@QueryParams() options: FeedbackSearchOptions,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<GetFeedbackResponse> {
const canSeeAllFeedback = PermissionsService.canSeeAllFeedback(user);
const feedback = await this.feedbackService.getFeedback(
Expand All @@ -55,7 +55,7 @@ export class FeedbackController {
@Post()
async submitFeedback(
@Body() submitFeedbackRequest: SubmitFeedbackRequest,
@AuthenticatedUser() user: UserModel,
@AuthenticatedUser() user: UserModel,
): Promise<SubmitFeedbackResponse> {
if (!PermissionsService.canSubmitFeedback(user)) throw new ForbiddenError();
const feedback = await this.feedbackService.submitFeedback(
Expand All @@ -68,8 +68,8 @@ export class FeedbackController {
@Patch('/:uuid')
async updateFeedbackStatus(
@Params() params: UuidParam,
@Body() updateFeedbackStatusRequest: UpdateFeedbackStatusRequest,
@AuthenticatedUser() user: UserModel,
@Body() updateFeedbackStatusRequest: UpdateFeedbackStatusRequest,
@AuthenticatedUser() user: UserModel,
): Promise<UpdateFeedbackStatusResponse> {
if (!PermissionsService.canSeeAllFeedback(user)) throw new ForbiddenError();
const feedback = await this.feedbackService.updateFeedbackStatus(
Expand Down
Loading

0 comments on commit afdb442

Please sign in to comment.