From e81272aae0672065ec403d0371d078b435aa3fd4 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Tue, 24 May 2022 18:36:59 +0800 Subject: [PATCH] fix: add type interfaces for dayjs --- .../interfaces/Home/ProjectUsage.tsx | 21 ++++++++++--------- .../Settings/Logs/Logs.constants.ts | 7 ++++--- .../project/[ref]/functions/[id]/index.tsx | 10 ++++----- studio/types/ui.ts | 8 +++++++ 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/studio/components/interfaces/Home/ProjectUsage.tsx b/studio/components/interfaces/Home/ProjectUsage.tsx index 7b3c9deb159..62a1c0a9dc8 100644 --- a/studio/components/interfaces/Home/ProjectUsage.tsx +++ b/studio/components/interfaces/Home/ProjectUsage.tsx @@ -25,8 +25,9 @@ import Table from 'components/to-be-cleaned/Table' import StackedAreaChart from 'components/ui/Charts/StackedAreaChart' import { USAGE_COLORS } from 'components/ui/Charts/Charts.constants' import { EndpointResponse, PathsDatum, StatusCodesDatum } from './ChartData.types' +import { ChartIntervals } from 'types' -const CHART_INTERVALS = [ +const CHART_INTERVALS: ChartIntervals[] = [ { key: 'minutely', label: '60 minutes', @@ -112,12 +113,12 @@ const ProjectUsage: FC = ({ project }) => {
{startDate && endDate && ( <> -
+
+
} @@ -148,7 +149,7 @@ const ProjectUsage: FC = ({ project }) => { +
} @@ -179,7 +180,7 @@ const ProjectUsage: FC = ({ project }) => { +
} @@ -210,7 +211,7 @@ const ProjectUsage: FC = ({ project }) => { +
} @@ -240,7 +241,7 @@ const ProjectUsage: FC = ({ project }) => {
@@ -267,7 +268,7 @@ const ProjectUsage: FC = ({ project }) => { @@ -286,7 +287,7 @@ const ProjectUsage: FC = ({ project }) => { {(pathsData?.result ?? []).map((row: PathsDatum) => ( -

{row.method}

+

{row.method}

{row.path}

{row.count} @@ -313,7 +314,7 @@ const PanelHeader = (props: any) => {
{props.icon} diff --git a/studio/components/interfaces/Settings/Logs/Logs.constants.ts b/studio/components/interfaces/Settings/Logs/Logs.constants.ts index 0d6ff67e859..ddd889a38b8 100644 --- a/studio/components/interfaces/Settings/Logs/Logs.constants.ts +++ b/studio/components/interfaces/Settings/Logs/Logs.constants.ts @@ -234,7 +234,6 @@ export const SQL_FILTER_TEMPLATES: any = { }, } - export enum LogsTableName { EDGE = 'edge_logs', POSTGRES = 'postgres_logs', @@ -248,7 +247,7 @@ export const LOGS_TABLES = { database: LogsTableName.POSTGRES, functions: LogsTableName.FUNCTIONS, fn_edge: LogsTableName.FN_EDGE, - auth: LogsTableName.AUTH + auth: LogsTableName.AUTH, } export const LOGS_SOURCE_DESCRIPTION = { @@ -469,7 +468,9 @@ export const EXPLORER_DATEPICKER_HELPERS: DatetimeHelper[] = [ export const getDefaultHelper = (helpers: DatetimeHelper[]) => helpers.find((helper) => helper.default) || helpers[0] -export const TIER_QUERY_LIMITS = { +export const TIER_QUERY_LIMITS: { + [x: string]: { text: string; value: 1 | 7 | 3; unit: 'day' | 'month' } +} = { FREE: { text: '1 day', value: 1, unit: 'day' }, PRO: { text: '7 days', value: 7, unit: 'day' }, PAYG: { text: '3 months', value: 3, unit: 'month' }, diff --git a/studio/pages/project/[ref]/functions/[id]/index.tsx b/studio/pages/project/[ref]/functions/[id]/index.tsx index 29166c46b2f..1f5a1bc8172 100644 --- a/studio/pages/project/[ref]/functions/[id]/index.tsx +++ b/studio/pages/project/[ref]/functions/[id]/index.tsx @@ -14,9 +14,9 @@ import { get } from 'lib/common/fetch' import { API_URL, DATE_FORMAT } from 'lib/constants' import FunctionsLayout from 'components/interfaces/Functions/FunctionsLayout' -import { NextPageWithLayout } from 'types' +import { ChartIntervals, NextPageWithLayout } from 'types' -const CHART_INTERVALS = [ +const CHART_INTERVALS: ChartIntervals[] = [ { key: '5min', label: '5 min', @@ -91,7 +91,7 @@ const PageLayout: NextPageWithLayout = () => { } return ( -
+
{CHART_INTERVALS.map((item, i) => { @@ -118,14 +118,14 @@ const PageLayout: NextPageWithLayout = () => { })}
- + Statistics for past {selectedInterval.label}
{startDate && endDate && ( <> -
+
{/* diff --git a/studio/types/ui.ts b/studio/types/ui.ts index 4d58fa0b698..2095094d2ed 100644 --- a/studio/types/ui.ts +++ b/studio/types/ui.ts @@ -6,3 +6,11 @@ export interface Notification { progress?: number // Optional: For loading messages to show a progress bar (Out of 100) duration?: number // Optional: How long to show the message for (ms) } + +export interface ChartIntervals { + key: 'minutely' | 'hourly' | 'daily' | '5min' | '15min' | '1hr' | '1day' | '7day' + label: string + startValue: 1 | 24 | 7 + startUnit: 'hour' | 'day' + format: 'MMM D, h:mma' | 'MMM D, ha' | 'MMM D' +}