Commit 516dbb45 authored by tom's avatar tom

empty state

parent 92030c31
...@@ -3,6 +3,7 @@ import React from 'react'; ...@@ -3,6 +3,7 @@ import React from 'react';
import type { AppItemOverview } from 'types/client/apps'; import type { AppItemOverview } from 'types/client/apps';
import { apos } from 'lib/html-entities';
import AppCard from 'ui/apps/AppCard'; import AppCard from 'ui/apps/AppCard';
import EmptySearchResult from 'ui/apps/EmptySearchResult'; import EmptySearchResult from 'ui/apps/EmptySearchResult';
...@@ -42,7 +43,7 @@ const AppList = ({ apps }: Props) => { ...@@ -42,7 +43,7 @@ const AppList = ({ apps }: Props) => {
)) } )) }
</Grid> </Grid>
) : ( ) : (
<EmptySearchResult/> <EmptySearchResult text={ `Couldn${ apos }t find an app that matches your filter query.` }/>
) } ) }
</> </>
); );
......
...@@ -2,9 +2,12 @@ import { Box, Heading, Icon, Text } from '@chakra-ui/react'; ...@@ -2,9 +2,12 @@ import { Box, Heading, Icon, Text } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import emptyIcon from 'icons/empty_search_result.svg'; import emptyIcon from 'icons/empty_search_result.svg';
import { apos } from 'lib/html-entities';
const EmptySearchResult = () => { interface Props {
text: string;
}
const EmptySearchResult = ({ text }: Props) => {
return ( return (
<Box <Box
display="flex" display="flex"
...@@ -31,7 +34,7 @@ const EmptySearchResult = () => { ...@@ -31,7 +34,7 @@ const EmptySearchResult = () => {
variant="secondary" variant="secondary"
align="center" align="center"
> >
Couldn{ apos }t find an app that matches your filter query. { text }
</Text> </Text>
</Box> </Box>
); );
......
// DEPRECATED
// migrate to separate components
// ui/shared/FilterButton.tsx + custom filter
// ui/shared/FilterInput.tsx
import { SearchIcon } from '@chakra-ui/icons'; import { SearchIcon } from '@chakra-ui/icons';
import { Flex, Icon, Button, Circle, InputGroup, InputLeftElement, Input, useColorModeValue } from '@chakra-ui/react'; import { Flex, Icon, Button, Circle, InputGroup, InputLeftElement, Input, useColorModeValue } from '@chakra-ui/react';
import type { ChangeEvent } from 'react'; import type { ChangeEvent } from 'react';
......
...@@ -5,6 +5,8 @@ import type { TxInternalsType } from 'types/api/tx'; ...@@ -5,6 +5,8 @@ import type { TxInternalsType } from 'types/api/tx';
import type ArrayElement from 'types/utils/ArrayElement'; import type ArrayElement from 'types/utils/ArrayElement';
import { data } from 'data/txInternal'; import { data } from 'data/txInternal';
import { apos } from 'lib/html-entities';
import EmptySearchResult from 'ui/apps/EmptySearchResult';
import FilterInput from 'ui/shared/FilterInput'; 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';
...@@ -26,13 +28,17 @@ const TxInternals = () => { ...@@ -26,13 +28,17 @@ const TxInternals = () => {
setFilters(nextValue); setFilters(nextValue);
}, []); }, []);
return ( const content = (() => {
<Box> const filteredData = data
<Flex> .filter(({ type }) => filters.includes(type))
<TxInternalsFilter onFilterChange={ handleFilterChange } defaultFilters={ filters } appliedFiltersNum={ filters.length }/> .filter(searchFn(searchTerm));
<FilterInput onChange={ setSearchTerm } maxW="360px" ml={ 3 } size="xs" placeholder="Search by addresses, hash, method..."/>
</Flex> if (filteredData.length === 0) {
<TableContainer width="100%" mt={ 6 }> return <EmptySearchResult text={ `Couldn${ apos }t find any transaction that matches your query.` }/>;
}
return (
<TableContainer width="100%">
<Table variant="simple" minWidth="950px" size="sm"> <Table variant="simple" minWidth="950px" size="sm">
<Thead> <Thead>
<Tr> <Tr>
...@@ -51,6 +57,16 @@ const TxInternals = () => { ...@@ -51,6 +57,16 @@ const TxInternals = () => {
</Tbody> </Tbody>
</Table> </Table>
</TableContainer> </TableContainer>
);
})();
return (
<Box>
<Flex mb={ 6 }>
<TxInternalsFilter onFilterChange={ handleFilterChange } defaultFilters={ filters } appliedFiltersNum={ filters.length }/>
<FilterInput onChange={ setSearchTerm } maxW="360px" ml={ 3 } size="xs" placeholder="Search by addresses, hash, method..."/>
</Flex>
{ content }
</Box> </Box>
); );
}; };
......
...@@ -38,4 +38,4 @@ const TxInternalsFilter = ({ onFilterChange, defaultFilters, appliedFiltersNum } ...@@ -38,4 +38,4 @@ const TxInternalsFilter = ({ onFilterChange, defaultFilters, appliedFiltersNum }
); );
}; };
export default TxInternalsFilter; export default React.memo(TxInternalsFilter);
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