Files
supabase/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx
T
Ivan Vasilov 436bdb10ae chore: Move the studio app to apps/studio (#18915)
* Move all studio files from /studio to /apps/studio.

* Move studio specific prettier ignores.

* Fix the ui references from studio.

* Fix the css imports.

* Fix all package.json issues.

* Fix the prettier setup for the studio app.

* Add .turbo folder to prettierignore.

* Fix the github workflows.
2023-11-15 12:38:55 +01:00

48 lines
1.3 KiB
TypeScript

import { useParams } from 'common'
import { observer } from 'mobx-react-lite'
import { IconAlertCircle, IconLoader } from 'ui'
import { NewProjectPanel } from 'components/interfaces/Home'
import InformationBox from 'components/ui/InformationBox'
import ProjectUsage from './ProjectUsage'
import { useProjectLogRequestsCountQuery } from 'data/analytics/project-log-requests-count-query'
const ProjectUsageSection = observer(() => {
const { ref: projectRef } = useParams()
const {
data: usage,
error: usageError,
isLoading,
} = useProjectLogRequestsCountQuery({ projectRef })
if (usageError) {
return (
<InformationBox
hideCollapse
defaultVisibility
icon={<IconAlertCircle strokeWidth={2} />}
title="There was an issue loading the usage details of your project"
/>
)
}
const hasProjectData =
usage?.result && usage.result.length > 0 ? usage.result[0].count > 0 : false
return (
<>
{isLoading ? (
<div className="flex w-full items-center justify-center space-x-2">
<IconLoader className="animate-spin" size={14} />
<p className="text-sm">Retrieving project usage statistics</p>
</div>
) : hasProjectData ? (
<ProjectUsage />
) : (
<NewProjectPanel />
)}
</>
)
})
export default ProjectUsageSection