errors.tsx 917 B

1234567891011121314151617181920212223242526272829303132333435
  1. import PdfLogsViewer from '@/features/pdf-preview/components/pdf-logs-viewer'
  2. import { PdfPreviewProvider } from '@/features/pdf-preview/components/pdf-preview-provider'
  3. import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
  4. import { RailIndicator } from './rail-indicator'
  5. export const ErrorIndicator = () => {
  6. const { logEntries } = useCompileContext()
  7. if (!logEntries) {
  8. return null
  9. }
  10. const errorCount = Number(logEntries.errors?.length)
  11. const warningCount = Number(logEntries.warnings?.length)
  12. const totalCount = errorCount + warningCount
  13. if (totalCount === 0) {
  14. return null
  15. }
  16. return (
  17. <RailIndicator
  18. count={totalCount}
  19. type={errorCount > 0 ? 'danger' : 'warning'}
  20. />
  21. )
  22. }
  23. export const ErrorPane = () => {
  24. return (
  25. <PdfPreviewProvider>
  26. <PdfLogsViewer alwaysVisible />
  27. </PdfPreviewProvider>
  28. )
  29. }