Fix formatting issues and improve code readability

This commit is contained in:
Simon Larsen 2023-12-05 13:56:14 +00:00
parent 606c0cb69d
commit 3dcdb5f0c2
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
4 changed files with 23 additions and 16 deletions

View File

@ -98,7 +98,7 @@ export class Service extends DatabaseService<Model> {
if (
UserNotificationEventType.IncidentCreated ===
options.userNotificationEventType &&
options.userNotificationEventType &&
!options.triggeredByIncidentId
) {
throw new BadDataException(
@ -277,20 +277,20 @@ export class Service extends DatabaseService<Model> {
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<ObjectID>) ||
[],
[],
(onCreate.createBy.miscDataProps['teams'] as Array<ObjectID>) ||
[],
(onCreate.createBy.miscDataProps['onCallSchedules'] as Array<ObjectID>) ||
[],
[],
(onCreate.createBy.miscDataProps[
'onCallSchedules'
] as Array<ObjectID>) || [],
onCreate.createBy.props
);
}
@ -358,7 +358,6 @@ export class Service extends DatabaseService<Model> {
});
}
public async addOnCallSchedules(
projectId: ObjectID,
escalationRuleId: ObjectID,

View File

@ -13,7 +13,8 @@ const OnCallDutyScheduleElement: FunctionComponent<ComponentProps> = (
): 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()

View File

@ -23,7 +23,9 @@ const OnCallDutySchedulesElement: FunctionComponent<ComponentProps> = (
schedule={schedule}
onNavigateComplete={props.onNavigateComplete}
/>
{i !== props.schedules.length - 1 && <span>,&nbsp;</span>}
{i !== props.schedules.length - 1 && (
<span>,&nbsp;</span>
)}
</span>
);
})}

View File

@ -17,7 +17,9 @@ export interface ComponentProps {
const OnCallDutyScheduleView: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {
const [schedules, setSchedules] = useState<Array<OnCallDutyPolicySchedule>>([]);
const [schedules, setSchedules] = useState<Array<OnCallDutyPolicySchedule>>(
[]
);
const [isLoading, setIsLoading] = useState<boolean>(false);
@ -44,11 +46,14 @@ const OnCallDutyScheduleView: FunctionComponent<ComponentProps> = (
{}
);
const schedules: Array<OnCallDutyPolicySchedule> = onCallSchedules.data.map(
(onCallUser: OnCallDutyPolicyEscalationRuleOnCallSchedule) => {
return onCallUser.onCallDutyPolicySchedule!;
}
);
const schedules: Array<OnCallDutyPolicySchedule> =
onCallSchedules.data.map(
(
onCallUser: OnCallDutyPolicyEscalationRuleOnCallSchedule
) => {
return onCallUser.onCallDutyPolicySchedule!;
}
);
setSchedules(schedules);
} catch (err) {