import { useFlag, useParams } from 'common' import { ChevronRightIcon } from 'lucide-react' import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' import { CATEGORY_ICONS, CATEGORY_LABELS, ISSUE_CATEGORIES, ISSUE_SEVERITIES, SEVERITY_LABELS, } from './Issues.constants' import { IssuesLegacyRedirect } from './IssuesLegacyRedirect' import { SeverityIndicator } from './SeverityIndicator' import { AlertError } from '@/components/ui/AlertError' import { DocsButton } from '@/components/ui/DocsButton' import { DynamicLink } from '@/components/ui/DynamicLink' import type { IssueSeverity } from '@/data/issues/issue.types' import { useProjectIssues } from '@/data/issues/useProjectIssues' import { DOCS_URL } from '@/lib/constants' const countBy = (values: T[]) => values.reduce>((counts, value) => { counts[value] = (counts[value] ?? 0) + 1 return counts }, {}) export const IssuesOverview = () => { const { ref } = useParams() const isHealthAdvisorEnabled = useFlag('healthAdvisor') const { issues, error, isLoading, isError, isSuccess } = useProjectIssues({ projectRef: ref }) const severityCounts = countBy(issues.map((issue) => issue.severity)) const categoryCounts = countBy(issues.map((issue) => issue.category)) const categories = ISSUE_CATEGORIES.filter( (category) => category !== 'health' || isHealthAdvisorEnabled ) return (

Issues

Problems found in this project by Supabase checks

{isLoading && } {isError && } {isSuccess && ( <>
{ISSUE_SEVERITIES.map((severity) => ( ))}

Open by category

    {categories.map((category) => { const Icon = CATEGORY_ICONS[category] const firstIssue = issues.find((issue) => issue.category === category) const href = firstIssue ? `/project/${ref}/issues/${firstIssue.id}?category=${category}` : `/project/${ref}/issues?category=${category}` return (
  • {CATEGORY_LABELS[category]} {categoryCounts[category] ?? 0}
  • ) })}
)}
) } const StatCard = ({ label, value, href, severity, }: { label: string value: number href: string severity?: IssueSeverity }) => ( {severity && } {label} {value} )