From f44800c01392305cf23d4da30a05c3cec48e1b67 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Thu, 15 Jan 2026 11:54:53 +0300 Subject: [PATCH] Add explorer sub-routes for accounts and assets views - Add /explorer/* wildcard route in App.tsx - Add view navigation tabs (Overview, Accounts, Assets) - Parse URL to determine current view - Add accounts and assets view components - Add account detail view with address display --- web/src/App.tsx | 1 + web/src/pages/Explorer.tsx | 163 ++++++++++++++++++++++++++++++++++++- 2 files changed, 161 insertions(+), 3 deletions(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index e8af99cf..dbfa9670 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -117,6 +117,7 @@ function App() { } /> } /> } /> + } /> } /> } /> } /> diff --git a/web/src/pages/Explorer.tsx b/web/src/pages/Explorer.tsx index 3f69ca00..308b4489 100644 --- a/web/src/pages/Explorer.tsx +++ b/web/src/pages/Explorer.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useCallback } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useNavigate, useLocation, useParams } from 'react-router-dom'; import Layout from '@/components/Layout'; import { usePezkuwi } from '@/contexts/PezkuwiContext'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; @@ -62,10 +62,40 @@ interface NetworkStats { era: number; } +type ExplorerView = 'overview' | 'accounts' | 'assets' | 'account' | 'block' | 'tx'; + const Explorer: React.FC = () => { const navigate = useNavigate(); + const location = useLocation(); const { api, isApiReady } = usePezkuwi(); + // Parse URL to determine view + const getViewFromPath = (): { view: ExplorerView; param?: string } => { + const path = location.pathname.replace('/explorer', '').replace(/^\//, ''); + if (!path) return { view: 'overview' }; + + const parts = path.split('/'); + const viewType = parts[0]; + const param = parts[1]; + + switch (viewType) { + case 'accounts': + return param ? { view: 'account', param } : { view: 'accounts' }; + case 'account': + return { view: 'account', param }; + case 'assets': + return { view: 'assets' }; + case 'block': + return { view: 'block', param }; + case 'tx': + return { view: 'tx', param }; + default: + return { view: 'overview' }; + } + }; + + const { view: currentView, param: viewParam } = getViewFromPath(); + const [stats, setStats] = useState({ bestBlock: 0, finalizedBlock: 0, @@ -381,6 +411,37 @@ const Explorer: React.FC = () => { + {/* View Navigation */} +
+ + + +
+ {/* Search Bar */} @@ -423,8 +484,102 @@ const Explorer: React.FC = () => { - {/* Stats Grid */} - {isLoading ? ( + {/* View-specific content */} + {currentView === 'accounts' && ( + + + + + Accounts + + + +

+ Search for an account address to view details, balances, and transaction history. +

+
+ +

Use the search bar above to find an account by address

+
+
+
+ )} + + {currentView === 'assets' && ( + + + + + Assets + + + +
+
+
+ HEZ + Native +
+

Native token of PezkuwiChain

+
+
+
+ PEZ + Asset ID: 1 +
+

Pezkuwi governance token

+
+
+
+ wHEZ + Asset ID: 0 +
+

Wrapped HEZ token

+
+
+
+ wUSDT + Asset ID: 2 +
+

Wrapped USDT stablecoin (6 decimals)

+
+
+
+
+ )} + + {currentView === 'account' && viewParam && ( + + + + + Account Details + + + +
+
Address
+
+ {viewParam} + +
+
+

+ Account balance and transaction history loading... +

+
+
+ )} + + {/* Stats Grid - Only show for overview */} + {currentView === 'overview' && ( + <> + {isLoading ? (
{[...Array(8)].map((_, i) => ( @@ -712,6 +867,8 @@ const Explorer: React.FC = () => {
+ + )}