From a694b422cf10f859757eef6024938fa3ee406917 Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Wed, 16 Oct 2024 18:03:29 +0200 Subject: [PATCH] WIP --- actions/findings/findings.ts | 9 ++- components/findings/table/column-findings.tsx | 70 ++++++++++++------- 2 files changed, 48 insertions(+), 31 deletions(-) diff --git a/actions/findings/findings.ts b/actions/findings/findings.ts index 228f7dba30..86f0bf5605 100644 --- a/actions/findings/findings.ts +++ b/actions/findings/findings.ts @@ -17,9 +17,7 @@ export const getFindings = async ({ if (isNaN(Number(page)) || page < 1) redirect("/findings"); const keyServer = process.env.API_BASE_URL; - const url = new URL( - `${keyServer}/findings?filter[inserted_at__gte]=2024-01-01`, - ); + const url = new URL(`${keyServer}/findings`); if (page) url.searchParams.append("page[number]", page.toString()); if (query) url.searchParams.append("filter[search]", query); @@ -33,14 +31,15 @@ export const getFindings = async ({ }); try { - const providers = await fetch(url.toString(), { + const findings = await fetch(url.toString(), { headers: { Accept: "application/vnd.api+json", Authorization: `Bearer ${session?.accessToken}`, }, }); - const data = await providers.json(); + const data = await findings.json(); const parsedData = parseStringify(data); + console.log(parsedData.data); revalidatePath("/findings"); return parsedData; } catch (error) { diff --git a/components/findings/table/column-findings.tsx b/components/findings/table/column-findings.tsx index 096e9ab7ee..20d7d6198b 100644 --- a/components/findings/table/column-findings.tsx +++ b/components/findings/table/column-findings.tsx @@ -2,45 +2,65 @@ import { ColumnDef } from "@tanstack/react-table"; -import { DateWithTime, SnippetId } from "@/components/ui/entities"; +import { DateWithTime } from "@/components/ui/entities"; import { DataTableColumnHeader, StatusBadge } from "@/components/ui/table"; import { FindingsProps } from "@/types"; import { DataTableRowActions } from "./data-table-row-actions"; const getFindingsData = (row: { original: FindingsProps }) => { + console.log(row.original); + return row.original; }; +const getFindingsMetadata = (row: { original: FindingsProps }) => { + return row.original.attributes.check_metadata.metadata; +}; + export const ColumnFindings: ColumnDef[] = [ // { // header: " ", // cell: ({ row }) =>

{row.index + 1}

, // }, { - accessorKey: "account", + accessorKey: "check", header: ({ column }) => ( - + ), cell: ({ row }) => { - const { - attributes: { status }, - } = getFindingsData(row); - return

{status}

; - }, - }, - { - accessorKey: "uid", - header: ({ column }) => ( - - ), - cell: ({ row }) => { - const { - attributes: { uid }, - } = getFindingsData(row); - return ; + const { CheckTitle } = getFindingsMetadata(row); + return

{CheckTitle}

; }, }, + // { + // accessorKey: "uid", + // header: ({ column }) => ( + // + // ), + // cell: ({ row }) => { + // const { + // attributes: { uid }, + // } = getFindingsData(row); + // return ; + // }, + // }, + // { + // accessorKey: "severity", + // header: ({ column }) => ( + // + // ), + // cell: ({ row }) => { + // const { + // attributes: { severity }, + // } = getFindingsData(row); + // return ; + // }, + // }, { accessorKey: "status", header: "Scan Status", @@ -50,19 +70,17 @@ export const ColumnFindings: ColumnDef[] = [ }, }, { - accessorKey: "lastScan", + accessorKey: "service", header: ({ column }) => ( ), cell: ({ row }) => { - const { - attributes: { updated_at }, - } = getFindingsData(row); - return ; + const { ServiceName } = getFindingsMetadata(row); + return

{ServiceName}

; }, }, {