diff --git a/src/components/SearchBar.tsx b/src/components/SearchBar.tsx index cd1018e..94fb92a 100644 --- a/src/components/SearchBar.tsx +++ b/src/components/SearchBar.tsx @@ -1,7 +1,16 @@ -export const SearchBar = () => { +interface SearchBarProps { + value: string; + onChange: (value: string) => void; +} + +export const SearchBar = ({ value, onChange }: SearchBarProps) => { + const handleChange = (event: React.ChangeEvent) => { + onChange(event.target.value); + }; + return (
- +
); }; diff --git a/src/components/Table.tsx b/src/components/Table.tsx index 377796c..348c80f 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -1,7 +1,10 @@ -import { useData } from '~/hooks'; +import { EcosystemChainData } from '~/types'; -export const Table = () => { - const { ecosystemData } = useData(); +interface TableProps { + chains: EcosystemChainData[]; +} + +export const Table = ({ chains }: TableProps) => { return ( @@ -12,7 +15,7 @@ export const Table = () => { - {ecosystemData?.chains.map((data, index) => { + {chains?.map((data, index) => { return ( diff --git a/src/components/index.ts b/src/components/index.ts index c99907e..35ed63f 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -4,3 +4,4 @@ export * from './CustomHead'; export * from './Table'; export * from './SearchBar'; export * from './TotalValueLocked'; +export * from './Title'; diff --git a/src/containers/Dashboard/index.tsx b/src/containers/Dashboard/index.tsx index 113a271..e8abe4b 100644 --- a/src/containers/Dashboard/index.tsx +++ b/src/containers/Dashboard/index.tsx @@ -1,14 +1,28 @@ -import { SearchBar, Table } from '~/components'; -import { Title } from '~/components/Title'; +import { useState } from 'react'; +import { SearchBar, Table, Title } from '~/components'; +import { useData } from '~/hooks'; const Dashboard = () => { + const { ecosystemData } = useData(); + const [searchTerm, setSearchTerm] = useState(''); + + const handleChange = (value: string) => { + setSearchTerm(value); + }; + + // Filter chains based on search term + const filteredChains = ecosystemData?.chains.filter((chain) => + chain.name.toLowerCase().includes(searchTerm.toLowerCase()), + ); + return (
- <SearchBar /> + <SearchBar value={searchTerm} onChange={handleChange} /> </header> - <Table /> + + <Table chains={filteredChains} /> </section> ); };
Type
{data.name}