Files
Kevin Grüneberg c26231a755 fix: usage page project filtering via URL param (#39919)
When opening the usage page with a projectRef param (filter by project), it lead to some odd behaviour where the project is not preselected and then after picking a project, it would end up showing the initially filtered project from the URL.

PR removes the odd all-projects logic and uses nuqs for URL state mgmt
2025-10-28 13:37:35 +08:00

55 lines
1.5 KiB
TypeScript

import { DataPoint } from 'data/analytics/constants'
import { PricingMetric, type OrgDailyUsageResponse } from 'data/analytics/org-daily-stats-query'
import type { OrgSubscription } from 'data/subscriptions/types'
import UsageSection from './UsageSection/UsageSection'
import { dailyUsageToDataPoints } from './Usage.utils'
export interface EgressProps {
orgSlug: string
projectRef: string | null
subscription: OrgSubscription | undefined
currentBillingCycleSelected: boolean
orgDailyStats: OrgDailyUsageResponse | undefined
isLoadingOrgDailyStats: boolean
}
const Egress = ({
orgSlug,
projectRef,
subscription,
currentBillingCycleSelected,
orgDailyStats,
isLoadingOrgDailyStats,
}: EgressProps) => {
const chartMeta: {
[key: string]: { data: DataPoint[]; margin: number; isLoading: boolean }
} = {
[PricingMetric.EGRESS]: {
data: dailyUsageToDataPoints(orgDailyStats, (metric) => metric === PricingMetric.EGRESS),
margin: 16,
isLoading: isLoadingOrgDailyStats,
},
[PricingMetric.CACHED_EGRESS]: {
data: dailyUsageToDataPoints(
orgDailyStats,
(metric) => metric === PricingMetric.CACHED_EGRESS
),
margin: 16,
isLoading: isLoadingOrgDailyStats,
},
}
return (
<UsageSection
orgSlug={orgSlug}
projectRef={projectRef}
categoryKey="egress"
chartMeta={chartMeta}
subscription={subscription}
currentBillingCycleSelected={currentBillingCycleSelected}
/>
)
}
export default Egress