Commit 46ff91ae authored by tom's avatar tom

fixes

parent 9d468f85
...@@ -11,8 +11,6 @@ import FilterInput from 'ui/shared/FilterInput'; ...@@ -11,8 +11,6 @@ import FilterInput from 'ui/shared/FilterInput';
import TxInternalsFilter from 'ui/tx/internals/TxInternalsFilter'; import TxInternalsFilter from 'ui/tx/internals/TxInternalsFilter';
import TxInternalsTableItem from 'ui/tx/internals/TxInternalsTableItem'; import TxInternalsTableItem from 'ui/tx/internals/TxInternalsTableItem';
const DEFAULT_FILTERS: Array<TxInternalsType> = [ 'call', 'delegate_call', 'static_call', 'create', 'create2', 'self_destruct', 'reward' ];
const searchFn = (searchTerm: string) => (item: ArrayElement<typeof data>): boolean => { const searchFn = (searchTerm: string) => (item: ArrayElement<typeof data>): boolean => {
const formattedSearchTerm = searchTerm.toLowerCase(); const formattedSearchTerm = searchTerm.toLowerCase();
return item.type.toLowerCase().includes(formattedSearchTerm) || return item.type.toLowerCase().includes(formattedSearchTerm) ||
...@@ -21,7 +19,7 @@ const searchFn = (searchTerm: string) => (item: ArrayElement<typeof data>): bool ...@@ -21,7 +19,7 @@ const searchFn = (searchTerm: string) => (item: ArrayElement<typeof data>): bool
}; };
const TxInternals = () => { const TxInternals = () => {
const [ filters, setFilters ] = React.useState<Array<TxInternalsType>>(DEFAULT_FILTERS); const [ filters, setFilters ] = React.useState<Array<TxInternalsType>>([]);
const [ searchTerm, setSearchTerm ] = React.useState<string>(''); const [ searchTerm, setSearchTerm ] = React.useState<string>('');
const handleFilterChange = React.useCallback((nextValue: Array<TxInternalsType>) => { const handleFilterChange = React.useCallback((nextValue: Array<TxInternalsType>) => {
...@@ -30,7 +28,7 @@ const TxInternals = () => { ...@@ -30,7 +28,7 @@ const TxInternals = () => {
const content = (() => { const content = (() => {
const filteredData = data const filteredData = data
.filter(({ type }) => filters.includes(type)) .filter(({ type }) => filters.length > 0 ? filters.includes(type) : true)
.filter(searchFn(searchTerm)); .filter(searchFn(searchTerm));
if (filteredData.length === 0) { if (filteredData.length === 0) {
...@@ -50,10 +48,7 @@ const TxInternals = () => { ...@@ -50,10 +48,7 @@ const TxInternals = () => {
</Tr> </Tr>
</Thead> </Thead>
<Tbody> <Tbody>
{ data { filteredData.map((item) => <TxInternalsTableItem key={ item.id } { ...item }/>) }
.filter(({ type }) => filters.includes(type))
.filter(searchFn(searchTerm))
.map((item) => <TxInternalsTableItem key={ item.id } { ...item }/>) }
</Tbody> </Tbody>
</Table> </Table>
</TableContainer> </TableContainer>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment