import { useState, useEffect } from 'react'
import type { Camera } from '../types'

const MOCK_CAMERAS: Camera[] = [
  { id: 'cam-1', name: 'Front View', status: 'online', position: 'North', fps: 30, resolution: '1920x1080', streamUrl: '/api/cameras/cam-1/stream', recording: true },
  { id: 'cam-2', name: 'Side View', status: 'online', position: 'East', fps: 30, resolution: '1920x1080', streamUrl: '/api/cameras/cam-2/stream', recording: false },
  { id: 'cam-3', name: 'Top View', status: 'connecting', position: 'Center', fps: 15, streamUrl: '/api/cameras/cam-3/stream', recording: false },
]

export function useCameraStatus() {
  const [cameras, setCameras] = useState<Camera[]>(MOCK_CAMERAS)

  useEffect(() => {
    const interval = setInterval(() => {
      setCameras((prev) =>
        prev.map((c) => ({ ...c })),
      )
    }, 5000)
    return () => clearInterval(interval)
  }, [])

  return { cameras }
}
