'use client'

import { useEffect, useState } from 'react'

/** Reloj en vivo del estado del servidor (equivale a startTime()/useClock de Django). */
export function ServerClock() {
  const [time, setTime] = useState('')
  useEffect(() => {
    const tick = () => setTime(new Date().toLocaleTimeString('es-ES'))
    tick()
    const id = setInterval(tick, 1000)
    return () => clearInterval(id)
  }, [])
  return (
    <span id="server-time" suppressHydrationWarning>
      {time}
    </span>
  )
}
