Commit 2d436427 authored by Yuri Mikhin's avatar Yuri Mikhin Committed by Yuri Mikhin

Remove precision from charts.

parent f672536f
......@@ -4,8 +4,8 @@ import appConfig from 'configs/app/config';
import handler from 'lib/api/handler';
const getUrl = (req: NextApiRequest) => {
const { precision, from, to } = req.query;
return `/v1/blocks/new?precision=${ precision }${ from ? `&from=${ from }&to=${ to }` : '' }`;
const { from, to } = req.query;
return `/v1/blocks/new?${ from ? `&from=${ from }&to=${ to }` : '' }`;
};
const requestHandler = handler(getUrl, [ 'GET' ], appConfig.statsApi.endpoint);
......
......@@ -29,10 +29,3 @@ export type Charts = {
value: string;
}>;
}
export enum ChartPrecision {
'DAY' = 'DAY',
'MONTH' = 'MONTH',
}
export type ChartPrecisionIds = keyof typeof ChartPrecision;
......@@ -39,10 +39,10 @@ const ChartWidget = ({ id, title, description, apiMethodURL, interval }: Props)
const menuButtonColor = useColorModeValue('black', 'white');
const borderColor = useColorModeValue('gray.200', 'gray.600');
const url = `${ apiMethodURL }?precision=${ selectedInterval.precision }${ startDate ? `&from=${ startDate }&to=${ endDate }` : '' }`;
const url = `${ apiMethodURL }${ startDate ? `?from=${ startDate }&to=${ endDate }` : '' }`;
const { data, isLoading } = useQuery<unknown, unknown, Charts>(
[ QueryKeys.charts, id, selectedInterval.precision, startDate ],
[ QueryKeys.charts, id, startDate ],
async() => await fetch(url),
);
......
......@@ -22,7 +22,6 @@ const sectionsList = Object.keys(STATS_SECTIONS)
const intervalList = Object.keys(STATS_INTERVALS).map((id: string) => ({
id: id,
title: STATS_INTERVALS[id as StatsIntervalIds].title,
precision: STATS_INTERVALS[id as StatsIntervalIds].precision,
})) as Array<StatsInterval>;
type Props = {
......
import { sub } from 'date-fns';
import type { ChartPrecisionIds } from 'types/api/stats';
import type { StatsSectionIds, StatsIntervalIds } from 'types/client/stats';
export const STATS_SECTIONS: { [key in StatsSectionIds]?: string } = {
......@@ -11,29 +10,24 @@ export const STATS_SECTIONS: { [key in StatsSectionIds]?: string } = {
gas: 'Gas',
};
export const STATS_INTERVALS: { [key in StatsIntervalIds]: { title: string; precision: ChartPrecisionIds; start?: Date } } = {
export const STATS_INTERVALS: { [key in StatsIntervalIds]: { title: string; start?: Date } } = {
all: {
title: 'All time',
precision: 'MONTH',
},
oneMonth: {
title: '1 month',
precision: 'DAY',
start: getStartDateInPast(1),
},
threeMonths: {
title: '3 months',
precision: 'DAY',
start: getStartDateInPast(3),
},
sixMonths: {
title: '6 months',
precision: 'MONTH',
start: getStartDateInPast(6),
},
oneYear: {
title: '1 year',
precision: 'MONTH',
start: getStartDateInPast(12),
},
};
......
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