generated from Luis/nextjs-python-web-template
[Functionality] Request Home Table
- request entities for home view table
This commit is contained in:
@@ -1,11 +1,29 @@
|
||||
"use client";
|
||||
|
||||
import { NoDataOverlay } from "@/components/noDataOverlay";
|
||||
import {NoDataOverlay} from "@/components/noDataOverlay";
|
||||
import SummaryDetails from "@/components/summary_card";
|
||||
import CustomTable from "@/components/table";
|
||||
import { HomeDummyData, HomeTableConfig } from "@/mock/home";
|
||||
import {HomeDummyData, HomeTableConfig} from "@/mock/home";
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
export default function Home() {
|
||||
const [homeData, setHomeData] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("http://localhost:2979/api/v1/get_entities", {
|
||||
method: "GET",
|
||||
// credentials: 'include',
|
||||
})
|
||||
.then((resp) =>
|
||||
resp.json().then((jsonData) => {
|
||||
console.log(jsonData);
|
||||
jsonData.length > 0 ? setHomeData(jsonData) : setHomeData(HomeDummyData);
|
||||
}),
|
||||
)
|
||||
.then()
|
||||
.catch();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="m-10">
|
||||
<SummaryDetails
|
||||
@@ -16,7 +34,7 @@ export default function Home() {
|
||||
|
||||
<div>
|
||||
<h4>Home View Table</h4>
|
||||
<CustomTable data={HomeDummyData} configuration={HomeTableConfig} />
|
||||
<CustomTable data={homeData} configuration={HomeTableConfig} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
@@ -21,27 +21,27 @@ export const HomeDummyData = [
|
||||
|
||||
export const HomeTableConfig = [
|
||||
{
|
||||
key: "entity_name",
|
||||
key: "name",
|
||||
label: "Entity name",
|
||||
},
|
||||
{
|
||||
key: "entity_DID",
|
||||
key: "did",
|
||||
label: "Entity DID",
|
||||
},
|
||||
// {
|
||||
// key: "network",
|
||||
// label: "Network",
|
||||
// },
|
||||
{
|
||||
key: "network",
|
||||
label: "Network",
|
||||
},
|
||||
{
|
||||
key: "ip_address",
|
||||
key: "ip",
|
||||
label: "IP address",
|
||||
},
|
||||
// {
|
||||
// key: "roles",
|
||||
// label: "Roles",
|
||||
// },
|
||||
{
|
||||
key: "roles",
|
||||
label: "Roles",
|
||||
},
|
||||
{
|
||||
key: "visible",
|
||||
label: "Visible",
|
||||
key: "attached",
|
||||
label: "Attached",
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user