Fixed null check warnings
This commit is contained in:
@@ -79,16 +79,16 @@
|
|||||||
|
|
||||||
const focusedTrainingReport = ref<CourseEventDetails | null>(null);
|
const focusedTrainingReport = ref<CourseEventDetails | null>(null);
|
||||||
const focusedTrainingTrainees = computed<CourseAttendee[] | null>(() => {
|
const focusedTrainingTrainees = computed<CourseAttendee[] | null>(() => {
|
||||||
if (focusedTrainingReport.value == null) return null;
|
if (focusedTrainingReport.value == null) return null; //if no training report is focused
|
||||||
return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name == 'Trainee');
|
return focusedTrainingReport.value.attendees?.filter((attendee) => attendee.role?.name == 'Trainee') ?? null;
|
||||||
})
|
})
|
||||||
const focusedNoShows = computed<CourseAttendee[] | null>(() => {
|
const focusedNoShows = computed<CourseAttendee[] | null>(() => {
|
||||||
if (focusedTrainingReport.value == null) return null;
|
if (focusedTrainingReport.value == null) return null; //if no training report is focused
|
||||||
return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name == 'No-Show');
|
return focusedTrainingReport.value.attendees?.filter((attendee) => attendee.role?.name == 'No-Show') ?? null;
|
||||||
})
|
})
|
||||||
const focusedTrainingTrainers = computed<CourseAttendee[] | null>(() => {
|
const focusedTrainingTrainers = computed<CourseAttendee[] | null>(() => {
|
||||||
if (focusedTrainingReport.value == null) return null;
|
if (focusedTrainingReport.value == null) return null; //if no training report is focused
|
||||||
return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name != 'Trainee' && attendee.role.name != 'No-Show');
|
return focusedTrainingReport.value.attendees?.filter((attendee) => attendee.role?.name != 'Trainee' && attendee.role?.name != 'No-Show') ?? null;
|
||||||
})
|
})
|
||||||
async function viewTrainingReport(id: number) {
|
async function viewTrainingReport(id: number) {
|
||||||
focusedTrainingReport.value = await getTrainingReport(id);
|
focusedTrainingReport.value = await getTrainingReport(id);
|
||||||
@@ -223,7 +223,7 @@
|
|||||||
loadTrainingReports();
|
loadTrainingReports();
|
||||||
}
|
}
|
||||||
|
|
||||||
const expanded = ref<number>(null);
|
const expanded = ref<number | null>(null);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -410,7 +410,7 @@
|
|||||||
<div class="mt-3 grid grid-cols-1 gap-2 text-xs">
|
<div class="mt-3 grid grid-cols-1 gap-2 text-xs">
|
||||||
<div class="rounded-lg bg-muted px-3 py-2">
|
<div class="rounded-lg bg-muted px-3 py-2">
|
||||||
<p class="text-muted-foreground">Role</p>
|
<p class="text-muted-foreground">Role</p>
|
||||||
<p class="font-medium text-foreground">{{ person.role.name }}</p>
|
<p class="font-medium text-foreground">{{ person.role?.name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="rounded-lg bg-muted px-3 py-2">
|
<div class="rounded-lg bg-muted px-3 py-2">
|
||||||
<p class="text-muted-foreground">Remarks</p>
|
<p class="text-muted-foreground">Remarks</p>
|
||||||
@@ -451,7 +451,7 @@
|
|||||||
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{
|
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{
|
||||||
person.attendee_name }}</p>
|
person.attendee_name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="truncate">{{ person.role.name }}</p>
|
<p class="truncate">{{ person.role?.name }}</p>
|
||||||
<p class="text-right px-2 truncate"
|
<p class="text-right px-2 truncate"
|
||||||
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
||||||
{{ person.remarks == "" ?
|
{{ person.remarks == "" ?
|
||||||
@@ -514,14 +514,14 @@
|
|||||||
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
||||||
<p class="text-muted-foreground">Bookwork</p>
|
<p class="text-muted-foreground">Bookwork</p>
|
||||||
<p class="font-semibold text-foreground">{{
|
<p class="font-semibold text-foreground">{{
|
||||||
!focusedTrainingReport.course.hasBookwork ? 'N/A' :
|
!focusedTrainingReport.course?.hasBookwork ? 'N/A' :
|
||||||
(person.passed_bookwork ?
|
(person.passed_bookwork ?
|
||||||
'Pass' : 'Fail') }}</p>
|
'Pass' : 'Fail') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
||||||
<p class="text-muted-foreground">Qual</p>
|
<p class="text-muted-foreground">Qual</p>
|
||||||
<p class="font-semibold text-foreground">{{
|
<p class="font-semibold text-foreground">{{
|
||||||
!focusedTrainingReport.course.hasQual ?
|
!focusedTrainingReport.course?.hasQual ?
|
||||||
'N/A' : (person.passed_qual ? 'Pass' : 'Fail') }}</p>
|
'N/A' : (person.passed_qual ? 'Pass' : 'Fail') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-span-2 rounded-lg bg-muted px-3 py-2">
|
<div class="col-span-2 rounded-lg bg-muted px-3 py-2">
|
||||||
@@ -565,17 +565,17 @@
|
|||||||
person.attendee_name }}</p>
|
person.attendee_name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<Tooltip :open="!focusedTrainingReport.course.hasBookwork"
|
<Tooltip :open="!focusedTrainingReport.course?.hasBookwork"
|
||||||
message="This course does not have bookwork">
|
message="This course does not have bookwork">
|
||||||
<Checkbox :disabled="!focusedTrainingReport.course.hasBookwork"
|
<Checkbox :disabled="!focusedTrainingReport.course?.hasBookwork"
|
||||||
:model-value="person.passed_bookwork" class="pointer-events-none">
|
:model-value="person.passed_bookwork" class="pointer-events-none">
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<Tooltip :open="!focusedTrainingReport.course.hasQual"
|
<Tooltip :open="!focusedTrainingReport.course?.hasQual"
|
||||||
message="This course does not have a qualification">
|
message="This course does not have a qualification">
|
||||||
<Checkbox :disabled="!focusedTrainingReport.course.hasQual"
|
<Checkbox :disabled="!focusedTrainingReport.course?.hasQual"
|
||||||
:model-value="person.passed_qual" class="pointer-events-none">
|
:model-value="person.passed_qual" class="pointer-events-none">
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -615,7 +615,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- No Shows -->
|
<!-- No Shows -->
|
||||||
<div v-if="focusedNoShows.length != 0">
|
<div v-if="focusedNoShows?.length != 0">
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<label class="scroll-m-20 text-xl font-semibold tracking-tight">
|
<label class="scroll-m-20 text-xl font-semibold tracking-tight">
|
||||||
No Shows
|
No Shows
|
||||||
|
|||||||
Reference in New Issue
Block a user