diff --git a/packages/page-broker/src/Overview/Summary/RegionLength.tsx b/packages/page-broker/src/Overview/Summary/RegionLength.tsx index 130010659b..369ca149f3 100644 --- a/packages/page-broker/src/Overview/Summary/RegionLength.tsx +++ b/packages/page-broker/src/Overview/Summary/RegionLength.tsx @@ -15,11 +15,11 @@ interface Props { function RegionLength ({ children, className }: Props): React.ReactElement | null { const { api } = useApi(); const config = useCall(api.query.broker?.configuration); - const length = config?.toJSON().regionLength; + const length = config?.toJSON()?.regionLength; return (
- {length?.toString()} + {length?.toString() || '-'} {children}
); diff --git a/packages/page-broker/src/Overview/Summary/RenewalPrice.tsx b/packages/page-broker/src/Overview/Summary/RenewalPrice.tsx index df34e3d1bc..1d1a21481c 100644 --- a/packages/page-broker/src/Overview/Summary/RenewalPrice.tsx +++ b/packages/page-broker/src/Overview/Summary/RenewalPrice.tsx @@ -21,7 +21,7 @@ function RenewalPrice ({ currentPrice, renewalBump }: Props): React.ReactElement return (
- {formatBalance(renewalPrice)} + {formatBalance(renewalPrice) || '-'}
); diff --git a/packages/page-broker/src/Overview/index.tsx b/packages/page-broker/src/Overview/index.tsx index cd46df2dd3..97edf881a2 100644 --- a/packages/page-broker/src/Overview/index.tsx +++ b/packages/page-broker/src/Overview/index.tsx @@ -59,9 +59,13 @@ function Overview ({ api, apiEndpoint, className, isReady }: Props): React.React const reservationMap = useMemo(() => reservations ? createTaskMap(reservations) : [], [reservations]); const timesliceAsString = useMemo(() => { - const timeslice = status?.toHuman().lastCommittedTimeslice?.toString(); + if (!!status && !!status?.toHuman()) { + const timeslice = status?.toHuman().lastCommittedTimeslice?.toString(); - return timeslice === undefined ? '' : timeslice.toString().split(',').join(''); + return timeslice === undefined ? '' : timeslice.toString().split(',').join(''); + } + + return '0'; }, [status]); useEffect(() => @@ -78,16 +82,21 @@ function Overview ({ api, apiEndpoint, className, isReady }: Props): React.React apiEndpoint={apiEndpoint} workloadInfos={workLoad} > - - + {!!workPlan?.length && + (<> + + + ) + } + {!workPlan?.length &&

No data currently available

} ); } diff --git a/packages/react-hooks/src/useBrokerStatus.ts b/packages/react-hooks/src/useBrokerStatus.ts index 87a39a229f..708dece93f 100644 --- a/packages/react-hooks/src/useBrokerStatus.ts +++ b/packages/react-hooks/src/useBrokerStatus.ts @@ -19,7 +19,7 @@ function useBrokerStatusImpl (query: string): string | undefined { ); }, [status]); - return state?.toJSON()[query]?.toString(); + return state?.toJSON()?.[query]?.toString(); } export const useBrokerStatus = createNamedHook('useBrokerStatus', useBrokerStatusImpl); diff --git a/packages/react-hooks/src/useCurrentPrice.tsx b/packages/react-hooks/src/useCurrentPrice.tsx index 6fc7c02872..951fe30de8 100644 --- a/packages/react-hooks/src/useCurrentPrice.tsx +++ b/packages/react-hooks/src/useCurrentPrice.tsx @@ -8,7 +8,7 @@ import { useEffect, useState } from 'react'; import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks'; function extractCurrentPrice (saleInfo: PalletBrokerSaleInfoRecord) { - return saleInfo.toJSON().price?.toString(); + return saleInfo.toJSON()?.price?.toString(); } function useCurrentPriceImpl () { diff --git a/packages/react-hooks/src/useRenewalBump.ts b/packages/react-hooks/src/useRenewalBump.ts index 9ae0fc1374..20af19d22f 100644 --- a/packages/react-hooks/src/useRenewalBump.ts +++ b/packages/react-hooks/src/useRenewalBump.ts @@ -8,7 +8,7 @@ import { useEffect, useState } from 'react'; import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks'; function extractRenewalBump (config: PalletBrokerConfigRecord) { - return config.toJSON().renewalBump?.toString(); + return config.toJSON()?.renewalBump?.toString(); } function useRenewalBumpImpl () { diff --git a/packages/react-query/src/BrokerStatus.tsx b/packages/react-query/src/BrokerStatus.tsx index d0f5a712b1..a85ed52d94 100644 --- a/packages/react-query/src/BrokerStatus.tsx +++ b/packages/react-query/src/BrokerStatus.tsx @@ -12,7 +12,7 @@ interface Props { } function BrokerStatus ({ children, className = '', query }: Props): React.ReactElement { - const info = useBrokerStatus(query); + const info = useBrokerStatus(query) || '-'; return (