'use client' import { useState } from 'react' import { Card } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from '@/components/ui/collapsible' import { Database, Server, ChevronDown, ExternalLink } from 'lucide-react' import { ConnectionError } from '@/lib/types/config' import { useTranslation } from '@/lib/hooks/use-translation' interface ConnectionErrorOverlayProps { error: ConnectionError onRetry: () => void } export function ConnectionErrorOverlay({ error, onRetry, }: ConnectionErrorOverlayProps) { const { t } = useTranslation() const [showDetails, setShowDetails] = useState(false) const isApiError = error.type === 'api-unreachable' return (
{/* Error icon and title */}
{isApiError ? (
{/* Troubleshooting instructions */}

{t('connectionErrors.troubleshooting')}

    {isApiError ? ( <>
  • {t('connectionErrors.apiUnreachable1')}
  • {t('connectionErrors.apiUnreachable2')}
  • {t('connectionErrors.apiUnreachable3')}
  • ) : ( <>
  • {t('connectionErrors.dbFailed1')}
  • {t('connectionErrors.dbFailed2')}
  • {t('connectionErrors.dbFailed3')}
  • )}

{t('connectionErrors.quickFixes')}

{isApiError ? (

{t('connectionErrors.setApiUrl')}

# {t('connectionErrors.dockerLabel')}:
docker run -e API_URL=http://your-host:5055 ...

# {t('connectionErrors.localDevLabel')}:
API_URL=http://localhost:5055
) : (

{t('connectionErrors.checkSurreal')}

# {t('connectionErrors.dockerLabel')}:
docker compose ps | grep surrealdb
docker compose logs surrealdb
)}
{/* Documentation link */}

{t('connectionErrors.seeDocumentation')}

{t('connectionErrors.docLink')}
{/* Collapsible technical details */} {error.details && (
{error.details.attemptedUrl && (
{t('connectionErrors.attemptedUrl')}: {error.details.attemptedUrl}
)} {error.details.message && (
{t('connectionErrors.message')}: {error.details.message}
)} {error.details.technicalMessage && (
{t('connectionErrors.technicalDetails')}:{' '} {error.details.technicalMessage}
)} {error.details.stack && (
{t('connectionErrors.stackTrace')}:
                      {error.details.stack}
                    
)}
)} {/* Retry button */}

{t('connectionErrors.retryHint')}

) }