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