From 1bf24704a397545996b672f0ebb28e68e9032b9f Mon Sep 17 00:00:00 2001 From: Sander Nilsen Rysjedal Date: Tue, 7 Jan 2025 15:06:09 +0100 Subject: [PATCH] better components view --- app/routes/kontrakter._index.tsx | 4 ++-- app/types/AdapterContract.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/routes/kontrakter._index.tsx b/app/routes/kontrakter._index.tsx index 61a4f7d..99dd5f8 100644 --- a/app/routes/kontrakter._index.tsx +++ b/app/routes/kontrakter._index.tsx @@ -11,7 +11,7 @@ import { import { useEffect, useRef, useState } from "react"; import { json, LoaderFunction } from "@remix-run/node"; import { StatusApi } from "~/api/StatusApi"; -import {AdapterContract, ContractModal, convertLastActivity} from "~/types/AdapterContract"; +import {AdapterContract, ContractModal, convertLastActivity, formatComponents} from "~/types/AdapterContract"; import { useLoaderData } from "@remix-run/react"; import { MagnifyingGlassIcon } from "@navikt/aksel-icons"; import {envCookie} from "~/components/cookie"; @@ -154,7 +154,7 @@ export default function Kontrakter() { {contract.orgId} - {contract.components} + {formatComponents(contract.components)} {String(contract.hasContact)} diff --git a/app/types/AdapterContract.ts b/app/types/AdapterContract.ts index 422a6cb..ae296c0 100644 --- a/app/types/AdapterContract.ts +++ b/app/types/AdapterContract.ts @@ -37,4 +37,18 @@ export function convertLastActivity(timestamp: number): string { return `${hours}:${minutes}:${seconds} ${day}/${month}/${year}`; +} + +export function formatComponents(compontents: string[]): Array { + const resources = new Array; + compontents.forEach((component: string) => { + const parts = component.split('.'); + if (parts.length > 1) { + if (!resources.find(resource => resource === parts[0])) { + resources.push(parts[0]); + } + } + }) + + return resources; } \ No newline at end of file