1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Add a suggestive message if no network selected (#884)

* add suggestive message

* message display refactor

* chainIds readded to the dependency list

* visual fix
This commit is contained in:
claudiaHash 2021-09-30 16:05:18 +03:00 committed by GitHub
parent 4b34e2f347
commit b9583edaf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -3,6 +3,7 @@ import DataTable, { IDataTableProps } from 'react-data-table-component'
import Loader from './Loader' import Loader from './Loader'
import Pagination from '../molecules/Pagination' import Pagination from '../molecules/Pagination'
import styles from './Table.module.css' import styles from './Table.module.css'
import { useUserPreferences } from '../../providers/UserPreferences'
interface TableProps extends IDataTableProps { interface TableProps extends IDataTableProps {
isLoading?: boolean isLoading?: boolean
@ -13,7 +14,14 @@ interface TableProps extends IDataTableProps {
} }
function Empty({ message }: { message?: string }): ReactElement { function Empty({ message }: { message?: string }): ReactElement {
return <div className={styles.empty}>{message || 'No results found'}</div> const { chainIds } = useUserPreferences()
return (
<div className={styles.empty}>
{chainIds.length === 0
? 'No network selected'
: message || 'No results found'}
</div>
)
} }
export default function Table({ export default function Table({

View File

@ -68,7 +68,11 @@ const AssetList: React.FC<AssetListProps> = ({
[className]: className [className]: className
}) })
return assetsWithPrices && return chainIds.length === 0 ? (
<div className={styleClasses}>
<div className={styles.empty}>No network selected</div>
</div>
) : assetsWithPrices &&
!loading && !loading &&
(isLoading === undefined || isLoading === false) ? ( (isLoading === undefined || isLoading === false) ? (
<> <>
@ -82,10 +86,8 @@ const AssetList: React.FC<AssetListProps> = ({
noPublisher={noPublisher} noPublisher={noPublisher}
/> />
)) ))
) : chainIds.length === 0 ? (
<div className={styles.empty}>No network selected.</div>
) : ( ) : (
<div className={styles.empty}>No results found.</div> <div className={styles.empty}>No results found</div>
)} )}
</div> </div>

View File

@ -165,6 +165,7 @@ export default function PoolShares({
const [loading, setLoading] = useState<boolean>(false) const [loading, setLoading] = useState<boolean>(false)
const [dataFetchInterval, setDataFetchInterval] = useState<NodeJS.Timeout>() const [dataFetchInterval, setDataFetchInterval] = useState<NodeJS.Timeout>()
const newCancelToken = useCancelToken() const newCancelToken = useCancelToken()
const fetchPoolSharesAssets = useCallback( const fetchPoolSharesAssets = useCallback(
async (cancelToken: CancelToken) => { async (cancelToken: CancelToken) => {
if (!poolShares || isPoolSharesLoading) return if (!poolShares || isPoolSharesLoading) return