From 02d393f865d94e505402e2fe336e0a6f1d9177b6 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Sat, 10 Aug 2024 15:51:56 +0700 Subject: [PATCH] Create Dashboard.js --- .../PiFusion/containers/Dashboard.js | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 blockchain_integration/pi_network/PiFusion/containers/Dashboard.js diff --git a/blockchain_integration/pi_network/PiFusion/containers/Dashboard.js b/blockchain_integration/pi_network/PiFusion/containers/Dashboard.js new file mode 100644 index 000000000..f9547ef53 --- /dev/null +++ b/blockchain_integration/pi_network/PiFusion/containers/Dashboard.js @@ -0,0 +1,73 @@ +import React, { useState, useEffect, useMemo } from 'react'; +import { useAuth } from '../hooks/useAuth'; +import { useNodeData } from '../hooks/useNodeData'; +import { useNodeSelection } from '../hooks/useNodeSelection'; +import { useNodeIncentivization } from '../hooks/useNodeIncentivization'; +import { useNodeReputation } from '../hooks/useNodeReputation'; +import { NodeList } from '../components/NodeList'; +import { NodeCard } from '../components/NodeCard'; +import { NodeFilters } from '../components/NodeFilters'; +import { NodeSort } from '../components/NodeSort'; +import { NodePagination } from '../components/NodePagination'; +import { NodeActions } from '../components/NodeActions'; +import { NodeReputationChart } from '../components/NodeReputationChart'; +import { NodeIncentivizationChart } from '../components/NodeIncentivizationChart'; +import { DashboardHeader } from '../components/DashboardHeader'; +import { DashboardSidebar } from '../components/DashboardSidebar'; + +const Dashboard = () => { + const { user, logout } = useAuth(); + const [nodes, setNodes] = useState([]); + const [selectedNodes, setSelectedNodes] = useState([]); + const [incentivizationData, setIncentivizationData] = useState({}); + const [reputationData, setReputationData] = useState({}); + + const { data, error, isLoading } = useNodeData(); + const { nodeSelection, setNodeSelection } = useNodeSelection(); + const { nodeIncentivization, setNodeIncentivization } = useNodeIncentivization(); + const { nodeReputation, setNodeReputation } = useNodeReputation(); + + useEffect(() => { + if (data) { + setNodes(data.nodes); + setIncentivizationData(data.incentivization); + setReputationData(data.reputation); + } + }, [data]); + + const handleNodeSelect = (nodeId) => { + setSelectedNodes((prev) => [...prev, nodeId]); + }; + + const handleNodeDeselect = (nodeId) => { + setSelectedNodes((prev) => prev.filter((id) => id !== nodeId)); + }; + + const handleLogout = () => { + logout(); + }; + + return ( +
+ + +
+ + + + + + + + +
+
+ ); +}; + +export default Dashboard;