1+ 'use client'
12import React , { useState , useEffect } from 'react' ;
2- import { useRouter } from "next/navigation"
3+ import { useRouter } from "next/navigation" ;
4+ import { LoadingScreen } from "@/components/loading-screen" ;
35
46const CryptoPathExplorer = ( { language = 'en' as 'en' | 'vi' } ) => {
57 const [ searchValue , setSearchValue ] = useState ( '' ) ;
@@ -10,7 +12,7 @@ const CryptoPathExplorer = ({ language = 'en' as 'en' | 'vi' }) => {
1012 const [ isFilterOpen , setIsFilterOpen ] = useState ( false ) ;
1113 const [ selectedFilter , setSelectedFilter ] = useState ( 'All Filters' ) ;
1214 const router = useRouter ( )
13-
15+ const [ isLoading , setIsLoading ] = useState ( false ) ;
1416 const filters = [ 'All Filters' , 'On-Chain' , 'Off-Chain' , 'Tokens' , 'NFTs' , 'Addresses' ] ;
1517
1618 const translations = {
@@ -67,9 +69,23 @@ const CryptoPathExplorer = ({ language = 'en' as 'en' | 'vi' }) => {
6769 fetchData ( ) ;
6870 } , [ ] ) ;
6971
70- const handleSearch = ( e : React . FormEvent < HTMLFormElement > ) => {
72+ const handleSearch = async ( e : React . FormEvent < HTMLFormElement > ) => {
7173 e . preventDefault ( ) ;
72- // Nho minh duy phan nay
74+ if ( ! searchValue . trim ( ) ) return ;
75+
76+ setIsLoading ( true ) ;
77+ try {
78+ await new Promise ( ( resolve ) => setTimeout ( resolve , 2500 ) ) ; // Simulated delay
79+ if ( selectedFilter === "On-Chain" ) {
80+ router . push ( `/search/?address=${ encodeURIComponent ( searchValue ) } &network=mainnet` ) ;
81+ } else if ( selectedFilter === "Off-Chain" ) {
82+ router . push ( `/search-offchain/?address=${ encodeURIComponent ( searchValue ) } ` ) ;
83+ }
84+ } catch ( error ) {
85+ console . error ( "Search error:" , error ) ;
86+ } finally {
87+ setIsLoading ( false ) ;
88+ }
7389 } ;
7490
7591 const toggleFilterDropdown = ( ) => {
@@ -82,6 +98,7 @@ const CryptoPathExplorer = ({ language = 'en' as 'en' | 'vi' }) => {
8298 } ;
8399
84100 return (
101+ < >
85102 < div className = "w-full mb-16 mt-16" >
86103 { /* Explorer Title */ }
87104 < div className = "mb-6 text-center" >
@@ -241,6 +258,8 @@ const CryptoPathExplorer = ({ language = 'en' as 'en' | 'vi' }) => {
241258 </ div >
242259 </ div >
243260 </ div >
261+ < LoadingScreen isLoading = { isLoading } />
262+ </ >
244263 ) ;
245264} ;
246265
0 commit comments