import { CheckCircle2, ChevronRight, Loader2 } from 'lucide-react' import Link from 'next/link' import { Fragment, useState } from 'react' import { useParams } from 'common' import { useProjectLintsQuery } from 'data/lint/lint-query' import { Button, PopoverContent_Shadcn_, PopoverSeparator_Shadcn_, PopoverTrigger_Shadcn_, Popover_Shadcn_, cn, } from 'ui' import { LINTER_LEVELS, LINT_TABS } from '../Linter/Linter.constants' export const SecurityStatus = () => { const { ref } = useParams() const [open, setOpen] = useState(false) const { data, isLoading } = useProjectLintsQuery({ projectRef: ref }) const securityLints = (data ?? []).filter((lint) => lint.categories.includes('SECURITY')) const errorLints = securityLints.filter((lint) => lint.level === 'ERROR') const warnLints = securityLints.filter((lint) => lint.level === 'WARN') const infoLints = securityLints.filter((lint) => lint.level === 'INFO') const totalLints = errorLints.length + warnLints.length + infoLints.length const noIssuesFound = totalLints === 0 return (
{noIssuesFound ? (

No security issues found

Keep monitoring Security Advisor for updates as your project grows.

) : (

{totalLints} issue{totalLints > 1 ? 's' : ''} have been identified

{[ { lints: errorLints, level: LINTER_LEVELS.ERROR }, { lints: warnLints, level: LINTER_LEVELS.WARN }, { lints: infoLints, level: LINTER_LEVELS.INFO }, ].map(({ lints, level }) => { const { label, descriptionShort } = LINT_TABS.find((tab) => tab.id === level) ?? {} return ( lints.length > 0 && (

{lints.length}{' '} {label === 'Info' ? 'suggestion' : label?.slice(0, label.length - 1).toLowerCase()} {lints.length > 1 ? 's' : ''}

{descriptionShort}

) ) })}
)}
) } const StatusDot = ({ level }: { level: LINTER_LEVELS }) => { const variants = { [LINTER_LEVELS.ERROR]: 'bg-destructive-600', [LINTER_LEVELS.WARN]: 'bg-warning-600', [LINTER_LEVELS.INFO]: 'bg-foreground-lighter dark:bg-foreground-light', } return
}