From 3dcdb5f0c24ff692db96003dc4d22dcfccc6afb7 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Tue, 5 Dec 2023 13:56:14 +0000 Subject: [PATCH] Fix formatting issues and improve code readability --- .../OnCallDutyPolicyEscalationRuleService.ts | 15 +++++++-------- .../OnCallDutySchedule/ScheduleElement.tsx | 3 ++- .../OnCallDutySchedule/SchedulesElement.tsx | 4 +++- .../EscalationRule/OnCallScheduleView.tsx | 17 +++++++++++------ 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/CommonServer/Services/OnCallDutyPolicyEscalationRuleService.ts b/CommonServer/Services/OnCallDutyPolicyEscalationRuleService.ts index 53a88a671b..f5338ff9be 100644 --- a/CommonServer/Services/OnCallDutyPolicyEscalationRuleService.ts +++ b/CommonServer/Services/OnCallDutyPolicyEscalationRuleService.ts @@ -98,7 +98,7 @@ export class Service extends DatabaseService { if ( UserNotificationEventType.IncidentCreated === - options.userNotificationEventType && + options.userNotificationEventType && !options.triggeredByIncidentId ) { throw new BadDataException( @@ -277,20 +277,20 @@ export class Service extends DatabaseService { if ( onCreate.createBy.miscDataProps && (onCreate.createBy.miscDataProps['teams'] || - onCreate.createBy.miscDataProps['users'] || + onCreate.createBy.miscDataProps['users'] || onCreate.createBy.miscDataProps['onCallSchedules']) - ) { await this.addUsersTeamsAndSchedules( createdItem.projectId, createdItem.id, createdItem.onCallDutyPolicyId!, (onCreate.createBy.miscDataProps['users'] as Array) || - [], + [], (onCreate.createBy.miscDataProps['teams'] as Array) || - [], - (onCreate.createBy.miscDataProps['onCallSchedules'] as Array) || - [], + [], + (onCreate.createBy.miscDataProps[ + 'onCallSchedules' + ] as Array) || [], onCreate.createBy.props ); } @@ -358,7 +358,6 @@ export class Service extends DatabaseService { }); } - public async addOnCallSchedules( projectId: ObjectID, escalationRuleId: ObjectID, diff --git a/Dashboard/src/Components/OnCallDutySchedule/ScheduleElement.tsx b/Dashboard/src/Components/OnCallDutySchedule/ScheduleElement.tsx index c96a906716..e94e2e9675 100644 --- a/Dashboard/src/Components/OnCallDutySchedule/ScheduleElement.tsx +++ b/Dashboard/src/Components/OnCallDutySchedule/ScheduleElement.tsx @@ -13,7 +13,8 @@ const OnCallDutyScheduleElement: FunctionComponent = ( ): ReactElement => { if ( props.schedule._id && - (props.schedule.projectId || (props.schedule.project && props.schedule.project._id)) + (props.schedule.projectId || + (props.schedule.project && props.schedule.project._id)) ) { const projectId: string | undefined = props.schedule.projectId ? props.schedule.projectId.toString() diff --git a/Dashboard/src/Components/OnCallDutySchedule/SchedulesElement.tsx b/Dashboard/src/Components/OnCallDutySchedule/SchedulesElement.tsx index cf7c40cae5..f4bc9fc65b 100644 --- a/Dashboard/src/Components/OnCallDutySchedule/SchedulesElement.tsx +++ b/Dashboard/src/Components/OnCallDutySchedule/SchedulesElement.tsx @@ -23,7 +23,9 @@ const OnCallDutySchedulesElement: FunctionComponent = ( schedule={schedule} onNavigateComplete={props.onNavigateComplete} /> - {i !== props.schedules.length - 1 && } + {i !== props.schedules.length - 1 && ( + + )} ); })} diff --git a/Dashboard/src/Components/OnCallPolicy/EscalationRule/OnCallScheduleView.tsx b/Dashboard/src/Components/OnCallPolicy/EscalationRule/OnCallScheduleView.tsx index 892f15b887..ffa3918ad1 100644 --- a/Dashboard/src/Components/OnCallPolicy/EscalationRule/OnCallScheduleView.tsx +++ b/Dashboard/src/Components/OnCallPolicy/EscalationRule/OnCallScheduleView.tsx @@ -17,7 +17,9 @@ export interface ComponentProps { const OnCallDutyScheduleView: FunctionComponent = ( props: ComponentProps ): ReactElement => { - const [schedules, setSchedules] = useState>([]); + const [schedules, setSchedules] = useState>( + [] + ); const [isLoading, setIsLoading] = useState(false); @@ -44,11 +46,14 @@ const OnCallDutyScheduleView: FunctionComponent = ( {} ); - const schedules: Array = onCallSchedules.data.map( - (onCallUser: OnCallDutyPolicyEscalationRuleOnCallSchedule) => { - return onCallUser.onCallDutyPolicySchedule!; - } - ); + const schedules: Array = + onCallSchedules.data.map( + ( + onCallUser: OnCallDutyPolicyEscalationRuleOnCallSchedule + ) => { + return onCallUser.onCallDutyPolicySchedule!; + } + ); setSchedules(schedules); } catch (err) {