Skip to content

Commit

Permalink
feat: add network column to list view
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzkirstein committed Mar 7, 2024
1 parent 7809ce8 commit 162e957
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/components/@shared/AssetList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AssetTeaser from '@shared/AssetTeaser'
import { ReactElement, useState } from 'react'
import { ReactElement, useEffect, useState } from 'react'
import Pagination from '@shared/Pagination'
import styles from './index.module.css'
import AssetTitle from '@shared/AssetListTitle'
Expand All @@ -10,8 +10,20 @@ import { getServiceByName } from '@utils/ddo'
import AssetViewSelector, { AssetViewOptions } from './AssetViewSelector'
import Time from '../atoms/Time'
import Loader from '../atoms/Loader'
import NetworkName from '../NetworkName'
import { useUserPreferences } from '../../../@context/UserPreferences'
import { ChainDoesNotSupportMulticallError } from 'wagmi'

const columns: TableOceanColumn<AssetExtended>[] = [
const networkColumn: TableOceanColumn<AssetExtended> = {
name: 'Network',
selector: (row) => {
const { chainId } = row
return <NetworkName networkId={chainId} />
},
maxWidth: '10rem'
}

const tableColumns: TableOceanColumn<AssetExtended>[] = [
{
name: 'Dataset',
selector: (row) => {
Expand Down Expand Up @@ -96,6 +108,17 @@ export default function AssetList({
showAssetViewSelector,
defaultAssetView
}: AssetListProps): ReactElement {
const { chainIds } = useUserPreferences()

const [columns, setColumns] = useState(tableColumns)

useEffect(() => {
if (chainIds.length > 1) {
const [datasetColumn, ...otherColumns] = tableColumns
setColumns([datasetColumn, networkColumn, ...otherColumns])
} else setColumns(tableColumns)
}, [chainIds])

const [activeAssetView, setActiveAssetView] = useState<AssetViewOptions>(
defaultAssetView || AssetViewOptions.Grid
)
Expand Down

0 comments on commit 162e957

Please sign in to comment.