Skip to content

Commit

Permalink
Create Dashboard.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 10, 2024
1 parent 0295565 commit 02d393f
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions blockchain_integration/pi_network/PiFusion/containers/Dashboard.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className="dashboard">
<DashboardHeader user={user} onLogout={handleLogout} />
<DashboardSidebar />
<div className="dashboard-content">
<NodeFilters />
<NodeSort />
<NodeList
nodes={nodes}
selectedNodes={selectedNodes}
onSelect={handleNodeSelect}
onDeselect={handleNodeDeselect}
/>
<NodePagination />
<NodeCard nodes={selectedNodes} />
<NodeActions nodes={selectedNodes} />
<NodeReputationChart data={reputationData} />
<NodeIncentivizationChart data={incentivizationData} />
</div>
</div>
);
};

export default Dashboard;

0 comments on commit 02d393f

Please sign in to comment.