Skip to content

Commit

Permalink
better components view
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander14121 committed Jan 7, 2025
1 parent fb0279d commit 1bf2470
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/routes/kontrakter._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -154,7 +154,7 @@ export default function Kontrakter() {
{contract.orgId}
</Table.HeaderCell>
<Table.HeaderCell scope="row">
{contract.components}
{formatComponents(contract.components)}
</Table.HeaderCell>
<Table.HeaderCell scope="row">
{String(contract.hasContact)}
Expand Down
14 changes: 14 additions & 0 deletions app/types/AdapterContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,18 @@ export function convertLastActivity(timestamp: number): string {

return `${hours}:${minutes}:${seconds} ${day}/${month}/${year}`;

}

export function formatComponents(compontents: string[]): Array<string> {
const resources = new Array<string>;
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;
}

0 comments on commit 1bf2470

Please sign in to comment.