Files
supabase/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx
Saxon Fletcher 9d36654fbe add advisor and stats to home (#35580)
* add advisor and stats to home

* public tables

* table count

* small fixes

* loading state

* Clean up + Add links to each advisor

* Last few fixes

* Tinnnnnnyy fix

* Nits to make the layout shift less

* Update LoadingState to minimize layout shift

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-05-13 21:14:07 +08:00

37 lines
1.2 KiB
TypeScript

import { AlertCircle } from 'lucide-react'
import { ProjectUsageLoadingState } from 'components/layouts/ProjectLayout/LoadingState'
import InformationBox from 'components/ui/InformationBox'
import { useProjectLogRequestsCountQuery } from 'data/analytics/project-log-requests-count-query'
import { useProjectLogStatsQuery } from 'data/analytics/project-log-stats-query'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import ProjectUsage from './ProjectUsage'
export const ProjectUsageSection = () => {
const project = useSelectedProject()
const { error, isLoading } = useProjectLogRequestsCountQuery({ projectRef: project?.ref })
// wait for the stats to load before showing the usage section to eliminate multiple spinners
const { isLoading: isLogsStatsLoading } = useProjectLogStatsQuery({
projectRef: project?.ref,
interval: 'minutely',
})
if (isLoading || isLogsStatsLoading) {
return <ProjectUsageLoadingState />
}
if (error) {
return (
<InformationBox
hideCollapse
defaultVisibility
icon={<AlertCircle size={18} strokeWidth={2} />}
title="There was an issue loading the usage details of your project"
/>
)
}
return <ProjectUsage />
}