import { useQuery } from '@tanstack/react-query' import { AlertTriangle, CircleAlert } from 'lucide-react' import { useTranslation } from 'react-i18next' import { qk } from '@/shared/api/query-keys' import type { SlotDto, TemplateIssueDto } from '@/shared/api/types' import { cn } from '@/shared/lib/cn' import { getTemplateIssues } from '../api' /** * Проверки по правилам (см. 5.1). Считаются на сервере по шаблону, без прогона генератора, поэтому * показываются прямо в редакторе и обновляются вместе с сеткой. */ export function TemplateIssues({ channelId, slotsById, onGoToSlot, }: { channelId: string slotsById: Map onGoToSlot: (slot: SlotDto) => void }) { const { t } = useTranslation() const { data: issues } = useQuery({ queryKey: qk.channels.issues(channelId), queryFn: () => getTemplateIssues(channelId), }) if (!issues || issues.length === 0) return null const errors = issues.filter((i) => i.severity === 'Error') const warnings = issues.filter((i) => i.severity === 'Warning') return (
{t('admin.channels.issues', { errors: errors.length, warnings: warnings.length })}
) } function IssueRow({ issue, slot, onGoToSlot, }: { issue: TemplateIssueDto slot: SlotDto | undefined onGoToSlot: (slot: SlotDto) => void }) { const { t } = useTranslation() const Icon = issue.severity === 'Error' ? CircleAlert : AlertTriangle return (
  • {t(`admin.channels.issueKinds.${issue.kind}`)}:{' '} {issue.details} {slot && ( )}
  • ) }