diff --git a/frontend/src/lib/components/Forms/Score.svelte b/frontend/src/lib/components/Forms/Score.svelte index 58aebb5c3..85b0b432e 100644 --- a/frontend/src/lib/components/Forms/Score.svelte +++ b/frontend/src/lib/components/Forms/Score.svelte @@ -4,6 +4,7 @@ import { RangeSlider } from '@skeletonlabs/skeleton'; import * as m from '$paraglide/messages'; import type { AnyZodObject } from 'zod'; + import { displayScoreColor } from '$lib/utils/helpers'; export let label: string | undefined = undefined; export let field: string; @@ -67,7 +68,7 @@
{#if scoringEnabled} - {displayNoValue($value)} + {displayNoValue($value)} {:else} -- {/if} diff --git a/frontend/src/lib/utils/helpers.ts b/frontend/src/lib/utils/helpers.ts index 50f259b3e..567f02896 100644 --- a/frontend/src/lib/utils/helpers.ts +++ b/frontend/src/lib/utils/helpers.ts @@ -1,4 +1,4 @@ -export function formatStringToDate(inputString: string,locale: string="en") { +export function formatStringToDate(inputString: string, locale: string="en") { const date = new Date(inputString); return date.toLocaleDateString(locale, { year: 'numeric', @@ -23,4 +23,18 @@ export function getRequirementTitle(ref_id: string, name: string) { pattern == 2 ? ref_id : pattern == 1 ? name : ''; return title; +} + +export function displayScoreColor(value: number, max_score: number){ + value = value * 100 / max_score + if(value < 25){ + return 'stroke-red-500' + } + if(value < 50){ + return 'stroke-orange-500' + } + if(value < 75){ + return 'stroke-yellow-500' + } + return 'stroke-green-500' } \ No newline at end of file diff --git a/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/+page.svelte index f38b7a304..0a0fb9e90 100644 --- a/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/+page.svelte @@ -90,6 +90,7 @@ import { ProgressRadial, localStorageStore } from '@skeletonlabs/skeleton'; import type { Writable } from 'svelte/store'; + import { displayScoreColor } from '$lib/utils/helpers'; const expandedNodesState: Writable = localStorageStore('expandedNodes', expandedNodes, { storage: 'session' @@ -161,7 +162,7 @@
{#if data.global_score.score >= 0}
- {data.global_score.score} + {data.global_score.score}
{/if}
diff --git a/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/TreeViewItemLead.svelte b/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/TreeViewItemLead.svelte index 976683f10..695673d4a 100644 --- a/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/TreeViewItemLead.svelte +++ b/frontend/src/routes/(app)/compliance-assessments/[id=uuid]/TreeViewItemLead.svelte @@ -1,4 +1,5 @@