diff --git a/app/next-client-app/app/(protected)/scanreports/[id]/columns.tsx b/app/next-client-app/app/(protected)/scanreports/[id]/columns.tsx index 38278ae7a..0d4f38c7a 100644 --- a/app/next-client-app/app/(protected)/scanreports/[id]/columns.tsx +++ b/app/next-client-app/app/(protected)/scanreports/[id]/columns.tsx @@ -60,7 +60,8 @@ export const columns: ColumnDef[] = [ // Divide jobs into jobs groups const jobGroups = DivideJobs(jobsData); // Get the general status of the table for the lastest run - const generalStatus = FindGeneralStatus(jobGroups[0]); + const generalStatus = + jobGroups.length > 0 ? FindGeneralStatus(jobGroups[0]) : "NOT_STARTED"; return (
@@ -83,7 +84,8 @@ export const columns: ColumnDef[] = [ // Divide jobs into jobs groups const jobGroups = DivideJobs(jobsData); // Get the general status of the table for the lastest run - const generalStatus = FindGeneralStatus(jobGroups[0]); + const generalStatus = + jobGroups.length > 0 ? FindGeneralStatus(jobGroups[0]) : "NOT_STARTED"; return ( { - let generalStatus = "NOT_STARTED"; - if (jobsData.length > 0) { - if ( - jobsData?.some((job) => job.status && job.status.value === "IN_PROGRESS") - ) { - generalStatus = "IN_PROGRESS"; - } else if ( - jobsData?.some((job) => job.status && job.status.value === "FAILED") - ) { - generalStatus = "FAILED"; - } else if ( - jobsData?.every((job) => job.status && job.status.value === "COMPLETE") - ) { - generalStatus = "COMPLETE"; - } + if ( + jobsData.some((job) => job.status && job.status.value === "IN_PROGRESS") + ) { + return "IN_PROGRESS"; + } + + if (jobsData.some((job) => job.status && job.status.value === "FAILED")) { + return "FAILED"; } - return generalStatus; + + if (jobsData.every((job) => job.status && job.status.value === "COMPLETE")) { + return "COMPLETE"; + } + + return "NOT_STARTED"; }; export const DivideJobs = (jobsData: Job[]) => {