# All files / src/components/layout BackendIndicator.tsx

0% Statements 0/46
0% Branches 0/1
0% Functions 0/1
0% Lines 0/46

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47

     import { Database, CloudCheck } from '@phosphor-icons/react'
    import { getStorageConfig } from '@/lib/storage'
    import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'

    export function BackendIndicator() {
      const { backend } = getStorageConfig()
      const isEnvConfigured = Boolean(process.env.NEXT_PUBLIC_FLASK_BACKEND_URL)

      if (backend === 'indexeddb') {
        return (
          <TooltipProvider>
            <Tooltip>
              <TooltipTrigger asChild>
                <div data-testid="backend-indicator" className="backend-indicator disconnected flex items-center gap-2 px-3 py-1.5 rounded-full bg-muted/50 border border-border">
                  <Database size={16} className="text-muted-foreground" />
                  <span className="text-xs font-medium text-muted-foreground">Local</span>
                </div>
              </TooltipTrigger>
              <TooltipContent>
                <p>Disconnected from backend - Using local storage</p>
              </TooltipContent>
            </Tooltip>
          </TooltipProvider>
        )
      }

      return (
        <TooltipProvider>
          <Tooltip>
            <TooltipTrigger asChild>
              <div data-testid="backend-indicator" className="backend-indicator connected flex items-center gap-2 px-3 py-1.5 rounded-full bg-accent/10 border border-accent/30">
                <CloudCheck size={16} className="text-accent" weight="fill" />
                <span className="text-xs font-medium text-accent">Connected</span>
                {isEnvConfigured && (
                  <span className="w-1.5 h-1.5 rounded-full bg-accent" />
                )}
              </div>
            </TooltipTrigger>
            <TooltipContent>
              <p>Connected to Flask Backend</p>
              {isEnvConfigured && <p className="text-xs text-muted-foreground">Auto-configured</p>}
            </TooltipContent>
          </Tooltip>
        </TooltipProvider>
      )
    }