srn Fix lint

This commit is contained in:
sumit_chaturvedi
2025-04-28 10:25:04 +05:30
parent a2f9f54edd
commit 9639082e20
4 changed files with 34 additions and 39 deletions
+20 -28
View File
@@ -1,12 +1,12 @@
import { Spacer } from "@nextui-org/react";
import { format, parseISO, subDays } from "date-fns";
import { format, parseISO } from "date-fns";
import { Suspense } from "react";
import { getResourceFields, getResources } from "@/actions/resources";
import { getScansByFields } from "@/actions/scans";
import { FilterControls } from "@/components/filters";
import { ColumnResources } from "@/components/resources/table/column-resources";
import { SkeletonTableResources } from "@/components/resources/skeleton/skeleton-table-resources";
import { ColumnResources } from "@/components/resources/table/column-resources";
import { ContentLayout } from "@/components/ui";
import { DataTable, DataTableFilterCustom } from "@/components/ui/table";
import { createDict } from "@/lib";
@@ -18,7 +18,6 @@ export default async function Resources({
searchParams: SearchParamsProps;
}) {
const searchParamsKey = JSON.stringify(searchParams || {});
const twoDaysAgo = format(subDays(new Date(), 2), "yyyy-MM-dd");
// Check if the searchParams contain any date or filter
const hasDateOrScanFilter = Object.keys(searchParams).some((key) =>
@@ -28,7 +27,7 @@ export default async function Resources({
// Default filters for getFindings
const defaultFilters: Record<string, string> = hasDateOrScanFilter
? {} // Do not apply default filters if there are date or filters
: { "filter[inserted_at]": twoDaysAgo, "page[size]": "100" }; // TODO: Remove page[size] 100 when metadata endpoint implemented
: { "page[size]": "100" }; // TODO: Remove page[size] 100 when metadata endpoint implemented
const filters: Record<string, string> = {
...defaultFilters,
@@ -55,6 +54,7 @@ export default async function Resources({
}
}
// Resource call for filters
const resourcesData = await getResourceFields(
"name,type,region,service",
filters,
@@ -69,14 +69,14 @@ export default async function Resources({
resourceNameList = Array.from(
new Set(
resourcesData.data.map((item: ResourceProps) => item.attributes.name) ||
[],
[],
),
);
typeList = Array.from(
new Set(
resourcesData.data.map((item: ResourceProps) => item.attributes.type) ||
[],
[],
),
);
@@ -144,20 +144,12 @@ const SSRDataTable = async ({
const defaultSort = "name";
const sort = searchParams.sort?.toString() || defaultSort;
const twoDaysAgo = format(subDays(new Date(), 2), "yyyy-MM-dd");
// Check if the searchParams contain any date or filter
const hasDateOrScanFilter = Object.keys(searchParams).some((key) =>
key.includes("inserted_at"),
);
// Default filters for getFindings
const defaultFilters: Record<string, string> = hasDateOrScanFilter
? {} // Do not apply default filters if there are date or filters
: { "filter[inserted_at]": twoDaysAgo };
const filters: Record<string, string> = {
...defaultFilters,
...Object.fromEntries(
Object.entries(searchParams)
.filter(([key]) => key.startsWith("filter["))
@@ -196,22 +188,22 @@ const SSRDataTable = async ({
// Expand each resources with its corresponding findings and provider
const expandedResources = resourcesData?.data
? resourcesData.data.map((resource: ResourceProps) => {
const findings = {
meta: resource.relationships.findings.meta,
data: resource.relationships.findings.data?.map(
(finding) => findingsDict[finding.id],
),
};
const findings = {
meta: resource.relationships.findings.meta,
data: resource.relationships.findings.data?.map(
(finding) => findingsDict[finding.id],
),
};
const provider = {
data: providerDict[resource.relationships.provider.data.id],
};
const provider = {
data: providerDict[resource.relationships.provider.data.id],
};
return {
...resource,
relationships: { findings, provider },
};
})
return {
...resource,
relationships: { findings, provider },
};
})
: [];
const expandedResponse = {
@@ -1,14 +1,16 @@
import React from "react";
export const SkeletonFindingSummary = () => {
return (<div className="flex animate-pulse flex-col gap-4 rounded-lg p-4 shadow dark:bg-prowler-blue-400">
<div className="flex items-center justify-between gap-4">
<div className="h-5 w-1/3 rounded bg-default-200" />
<div className="flex items-center gap-2">
<div className="h-5 w-16 rounded bg-default-200" />
<div className="h-5 w-16 rounded bg-default-200" />
<div className="h-5 w-5 rounded-full bg-default-200" />
</div>
return (
<div className="flex animate-pulse flex-col gap-4 rounded-lg p-4 shadow dark:bg-prowler-blue-400">
<div className="flex items-center justify-between gap-4">
<div className="h-5 w-1/3 rounded bg-default-200" />
<div className="flex items-center gap-2">
<div className="h-5 w-16 rounded bg-default-200" />
<div className="h-5 w-16 rounded bg-default-200" />
<div className="h-5 w-5 rounded-full bg-default-200" />
</div>
</div>);
}
</div>
</div>
);
};
+1 -1
View File
@@ -1,4 +1,4 @@
export * from "../skeleton/skeleton-table-resources";
export * from "./column-resources";
export * from "./data-table-row-details";
export * from "./resource-detail";
export * from "../skeleton/skeleton-table-resources";
@@ -11,6 +11,7 @@ import {
} from "@/components/ui/entities";
import { SeverityBadge, StatusFindingBadge } from "@/components/ui/table";
import { ResourceApiResponse, ResourceProps } from "@/types";
import { SkeletonFindingSummary } from "../skeleton/skeleton-finding-summary";
const renderValue = (value: string | null | undefined) => {