Project Usage: fix types and component (#35934)

* fix types and component

* fix types
This commit is contained in:
Jordi Enric authored and GitHub committed 2025-05-26 16:38:26 +02:00
1 parent 318280f2fe
commit 2fa17afca3
5 files changed
+28 -30

No files matched your search

@@ -27,9 +27,11 @@ import {
Loading,
} from 'ui'
type ChartIntervalKey = ProjectLogStatsVariables['interval']
const CHART_INTERVALS: ChartIntervals[] = [
{
key: 'minutely',
key: '1hr',
label: 'Last 60 minutes',
startValue: 1,
startUnit: 'hour',
@@ -37,21 +39,21 @@ const CHART_INTERVALS: ChartIntervals[] = [
availableIn: ['free', 'pro', 'enterprise', 'team'],
},
{
key: 'hourly',
key: '1day',
label: 'Last 24 hours',
startValue: 24,
startUnit: 'hour',
format: 'MMM D, ha',
availableIn: ['free', 'pro', 'enterprise', 'team'],
},
{
key: 'daily',
label: 'Last 7 days',
startValue: 7,
startUnit: 'day',
format: 'MMM D',
availableIn: ['pro', 'enterprise', 'team'],
},
// {
// key: '',
// label: 'Last 7 days',
// startValue: 7,
// startUnit: 'day',
// format: 'MMM D',
// availableIn: ['pro', 'enterprise', 'team'],
// },
]
const ProjectUsage = () => {
@@ -65,9 +67,9 @@ const ProjectUsage = () => {
const { plan } = useCurrentOrgPlan()
const DEFAULT_INTERVAL = plan?.id === 'free' ? 'hourly' : 'daily'
const DEFAULT_INTERVAL: ChartIntervalKey = plan?.id === 'free' ? '1hr' : '1day'
const [interval, setInterval] = useState<ProjectLogStatsVariables['interval']>(DEFAULT_INTERVAL)
const [interval, setInterval] = useState<ChartIntervalKey>(DEFAULT_INTERVAL)
const { data, isLoading } = useProjectLogStatsQuery({ projectRef, interval })
@@ -14,7 +14,7 @@ export const ProjectUsageSection = () => {
// wait for the stats to load before showing the usage section to eliminate multiple spinners
const { isLoading: isLogsStatsLoading } = useProjectLogStatsQuery({
projectRef: project?.ref,
interval: 'minutely',
interval: '1hr',
})
if (isLoading || isLogsStatsLoading) {
@@ -33,19 +33,12 @@ import {
} from 'ui'
const CHART_INTERVALS: ChartIntervals[] = [
{
key: '5min',
label: '5 min',
startValue: 5,
startUnit: 'minute',
format: 'MMM D, h:mm:ssa',
},
{
key: '15min',
label: '15 min',
startValue: 15,
startUnit: 'minute',
format: 'MMM D, h:mma',
format: 'MMM D, h:mm:ssa',
},
{
key: '1hr',
@@ -61,13 +54,13 @@ const CHART_INTERVALS: ChartIntervals[] = [
startUnit: 'hour',
format: 'MMM D, h:mma',
},
{
key: '7day',
label: '7 days',
startValue: 7,
startUnit: 'day',
format: 'MMM D',
},
// {
// key: '7day',
// label: '7 days',
// startValue: 7,
// startUnit: 'day',
// format: 'MMM D',
// },
]
const PageLayout: NextPageWithLayout = () => {
+2 -1
View File
@@ -1,4 +1,5 @@
import type { PostgresColumn } from '@supabase/postgres-meta'
import { ProjectLogStatsVariables } from 'data/analytics/project-log-stats-query'
import { PlanId } from 'data/subscriptions/types'
export interface Notification {
@@ -17,7 +18,7 @@ interface NotificationMetadata {
}
export interface ChartIntervals {
key: 'minutely' | 'hourly' | 'daily' | '5min' | '15min' | '1hr' | '1day' | '7day'
key: Exclude<ProjectLogStatsVariables['interval'], undefined>
label: string
startValue: number
startUnit: 'minute' | 'hour' | 'day'
+3 -1
View File
@@ -5639,6 +5639,7 @@ export interface components {
MAILER_TEMPLATES_MAGIC_LINK_CONTENT: string
MAILER_TEMPLATES_REAUTHENTICATION_CONTENT: string
MAILER_TEMPLATES_RECOVERY_CONTENT: string
MFA_ALLOW_LOW_AAL: boolean
MFA_MAX_ENROLLED_FACTORS: number
MFA_PHONE_ENROLL_ENABLED: boolean
MFA_PHONE_MAX_FREQUENCY: number
@@ -7832,6 +7833,7 @@ export interface components {
MAILER_TEMPLATES_MAGIC_LINK_CONTENT?: string | null
MAILER_TEMPLATES_REAUTHENTICATION_CONTENT?: string | null
MAILER_TEMPLATES_RECOVERY_CONTENT?: string | null
MFA_ALLOW_LOW_AAL?: boolean | null
MFA_MAX_ENROLLED_FACTORS?: number | null
MFA_PHONE_ENROLL_ENABLED?: boolean | null
MFA_PHONE_MAX_FREQUENCY?: number | null
@@ -14303,7 +14305,7 @@ export interface operations {
UsageApiController_getApiCounts: {
parameters: {
query?: {
interval?: 'minutely' | 'hourly' | 'daily' | '15min' | '30min' | '1hr' | '3hr' | '1day'
interval?: '15min' | '30min' | '1hr' | '3hr' | '1day'
}
header?: never
path: {