Updated the LookupWizard component to enhance readability and maintainability by replacing Alert components with a new LookupStatusBanner component. This change simplifies the status display logic for matched and unmatched results, improving the user experience during the lookup process.
75 lines
2.3 KiB
TypeScript
75 lines
2.3 KiB
TypeScript
import { CircleAlert, CircleCheck, ShieldAlert } from 'lucide-react'
|
|
|
|
import { Badge } from '@/components/reui/badge'
|
|
import {
|
|
Alert,
|
|
AlertDescription,
|
|
AlertTitle,
|
|
} from '@/components/reui/alert'
|
|
|
|
/**
|
|
* Lookup result status plaque — ReUI Alert + Badge.
|
|
* @see https://reui.io/docs/components/base/alert
|
|
* @see https://reui.io/preview/base/components/c-alert-6
|
|
* @see https://reui.io/docs/components/base/badge
|
|
*/
|
|
export function LookupStatusBanner({
|
|
status,
|
|
normalized,
|
|
matchCount = 0,
|
|
}: {
|
|
status: 'found' | 'missing' | 'missing_denied'
|
|
normalized: string
|
|
matchCount?: number
|
|
}) {
|
|
if (status === 'found') {
|
|
return (
|
|
<Alert variant="success" className="items-start py-3">
|
|
<CircleCheck aria-hidden />
|
|
<AlertTitle className="line-clamp-none flex flex-wrap items-center gap-2">
|
|
Найдено
|
|
<Badge variant="success-light" size="sm" radius="full">
|
|
в списках
|
|
</Badge>
|
|
</AlertTitle>
|
|
<AlertDescription>
|
|
«{normalized}» — {matchCount} совп. в entries / snapshots.
|
|
</AlertDescription>
|
|
</Alert>
|
|
)
|
|
}
|
|
|
|
if (status === 'missing_denied') {
|
|
return (
|
|
<Alert variant="warning" className="items-start py-3">
|
|
<ShieldAlert aria-hidden />
|
|
<AlertTitle className="line-clamp-none flex flex-wrap items-center gap-2">
|
|
Не найдено
|
|
<Badge variant="warning-light" size="sm" radius="full">
|
|
нет прав
|
|
</Badge>
|
|
</AlertTitle>
|
|
<AlertDescription>
|
|
«{normalized}» отсутствует в списках. Для добавления нужно право{' '}
|
|
<span className="font-medium text-foreground">bgp:modules:write</span>.
|
|
</AlertDescription>
|
|
</Alert>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Alert variant="warning" className="items-start py-3">
|
|
<CircleAlert aria-hidden />
|
|
<AlertTitle className="line-clamp-none flex flex-wrap items-center gap-2">
|
|
Не найдено
|
|
<Badge variant="warning-light" size="sm" radius="full">
|
|
можно добавить
|
|
</Badge>
|
|
</AlertTitle>
|
|
<AlertDescription>
|
|
«{normalized}» отсутствует в entries и snapshots. Добавить запись в модуль?
|
|
</AlertDescription>
|
|
</Alert>
|
|
)
|
|
}
|