mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
- Rename all @blockscout/* npm packages to @luxfi/* aliases (150+ files) - Override blue accent colors to gray for monochrome theme - Fix dropdown/menu/popover fonts to use Geist Sans - Change Latest Blocks to horizontal scrolling layout - Show dashes instead of zeros for validator stats on error - Fix GHA deploy step to use correct deployment name
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import React, { useEffect } from 'react';
|
|
|
|
import { Resolution } from '@luxfi/stats-types';
|
|
import type { StatsIntervalIds } from 'types/client/stats';
|
|
|
|
import { route, type Route } from 'nextjs-routes';
|
|
|
|
import config from 'configs/app';
|
|
import { ChartWidget } from 'toolkit/components/charts/ChartWidget';
|
|
import { useChartsConfig } from 'ui/shared/chart/config';
|
|
import useChartQuery from 'ui/shared/chart/useChartQuery';
|
|
|
|
type Props = {
|
|
id: string;
|
|
title: string;
|
|
description: string;
|
|
interval: StatsIntervalIds;
|
|
onLoadingError: () => void;
|
|
isPlaceholderData: boolean;
|
|
className?: string;
|
|
href?: Route;
|
|
};
|
|
|
|
const ChartWidgetContainer = ({
|
|
id,
|
|
title,
|
|
description,
|
|
interval,
|
|
onLoadingError,
|
|
isPlaceholderData,
|
|
className,
|
|
href,
|
|
}: Props) => {
|
|
const { items, lineQuery } = useChartQuery(id, Resolution.DAY, interval, !isPlaceholderData);
|
|
const chartsConfig = useChartsConfig();
|
|
|
|
useEffect(() => {
|
|
if (lineQuery.isError) {
|
|
onLoadingError();
|
|
}
|
|
}, [ lineQuery.isError, onLoadingError ]);
|
|
|
|
const charts = React.useMemo(() => {
|
|
if (!lineQuery.data?.info || !items) {
|
|
return [];
|
|
}
|
|
|
|
return [
|
|
{
|
|
id: lineQuery.data?.info?.id,
|
|
name: 'Value',
|
|
items,
|
|
charts: chartsConfig,
|
|
units: lineQuery.data.info.units,
|
|
},
|
|
];
|
|
}, [ lineQuery.data?.info, items, chartsConfig ]);
|
|
|
|
return (
|
|
<ChartWidget
|
|
isError={ lineQuery.isError }
|
|
charts={ charts }
|
|
title={ title }
|
|
description={ description }
|
|
isLoading={ lineQuery.isPlaceholderData }
|
|
className={ className }
|
|
href={ href ? route(href) : undefined }
|
|
chartUrl={ href ? `${ config.app.baseUrl }${ route(href) }` : undefined }
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default React.memo(ChartWidgetContainer);
|