/
kreyndelHam
/
Konstructorium
Обзор
Документация
Войти
/
kreyndelHam
/
Konstructorium
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
Безопасность
dev
frontend/src/components/UserErrorBanner.jsx
41 строка
1 KB
MihahamYT
Frontend rebuilded with dark mode
24 май 2026, 15:47
24 май 2026, 15:47
dbcde1d
Код
Авторство
О чём код?
import { useEffect, useRef } from 'react' import { useTranslation } from '../hooks/useTranslation' import { getUserErrorDisplay, reportUserError } from '../utils/showUserError' /** * Inline error panel with support incident reference. * * @param {{error: unknown, className?: string}} props * @returns {JSX.Element|null} */ const UserErrorBanner = ({ error, className = '' }) => { const { t } = useTranslation() const reportedRef = useRef(false) const display = getUserErrorDisplay(error) useEffect(() => { if (!error || reportedRef.current) { return } reportedRef.current = true reportUserError(error) }, [error]) if (!display) { return null } return ( <div className={`rounded-lg border border-red-200 bg-red-50 p-4 text-red-800 dark:border-red-800 dark:bg-red-950/40 dark:text-red-200 ${className}`}> <p className="font-medium">{display.message}</p> <p className="mt-2 text-sm text-red-700 dark:text-red-300"> {t('errors.support.codeLine', { code: display.errorCode })} </p> <p className="text-sm text-red-700 dark:text-red-300"> {t('errors.inline.incident', { incidentId: display.incidentId })} </p> </div> ) } export default UserErrorBanner