chore: rendering real data for Providers and relocate action folder

This commit is contained in:
Pablo Lara
2024-08-02 10:24:47 +02:00
parent 6a7b6f3e6b
commit b95d48e2ad
6 changed files with 29 additions and 33 deletions
+1
View File
@@ -0,0 +1 @@
export * from "./providers";
+20
View File
@@ -0,0 +1,20 @@
import "server-only";
import { parseStringify } from "@/lib";
export const getProvider = async () => {
const keyServer = process.env.LOCAL_SERVER_URL;
try {
const providers = await fetch(`${keyServer}/providers`, {
headers: {
"X-Tenant-ID": "12646005-9067-4d2a-a098-8bb378604362",
},
});
const data = await providers.json();
return parseStringify(data);
} catch (error) {
return undefined;
}
};
+2 -7
View File
@@ -1,6 +1,7 @@
import { Spacer } from "@nextui-org/react";
import React, { Suspense } from "react";
import { getProvider } from "@/actions";
import {
ColumnsProviders,
DataTable,
@@ -8,7 +9,6 @@ import {
ModalWrap,
SkeletonTableProvider,
} from "@/components";
import { getProvider } from "@/lib/actions";
export default async function Providers() {
const onSave = async () => {
@@ -44,10 +44,5 @@ export default async function Providers() {
const SSRDataTable = async () => {
const providersData = await getProvider();
const [providers] = await Promise.all([providersData]);
return (
<DataTable
columns={ColumnsProviders}
data={providers?.providers?.data ?? []}
/>
);
return <DataTable columns={ColumnsProviders} data={providers?.data ?? []} />;
};
@@ -45,9 +45,9 @@ export const ColumnsProviders: ColumnDef<ProviderProps>[] = [
{
accessorKey: "status",
header: "Scan Status",
cell: ({ row }) => {
const { status } = getProviderAttributes(row);
return <StatusBadge status={status} />;
cell: () => {
// Temporarily overwriting the value until the API is functional.
return <StatusBadge status={"completed"} />;
},
},
{
@@ -72,9 +72,9 @@ export const ColumnsProviders: ColumnDef<ProviderProps>[] = [
{
accessorKey: "resources",
header: "Resources",
cell: ({ row }) => {
const { resources } = getProviderAttributes(row);
return <p className="font-medium">{resources}</p>;
cell: () => {
// Temporarily overwriting the value until the API is functional.
return <p className="font-medium">{288}</p>;
},
},
{
-1
View File
@@ -1 +0,0 @@
export * from "./provider.actions";
-19
View File
@@ -1,19 +0,0 @@
import "server-only";
import { parseStringify } from "../utils";
export const getProvider = async () => {
const key = process.env.LOCAL_SITE_URL;
if (!key) return undefined;
try {
const providers = await fetch(`${key}/api/providers`);
const data = await providers.json();
return parseStringify(data);
} catch (error) {
return undefined;
}
};