"use client";
import { useState, useEffect } from "react";

export function RefreshIndicator({ interval = 60 }: { interval?: number }) {
  const [countdown, setCountdown] = useState(interval);

  useEffect(() => {
    const timer = setInterval(() => {
      setCountdown(prev => prev <= 1 ? interval : prev - 1);
    }, 1000);
    return () => clearInterval(timer);
  }, [interval]);

  return (
    <span className="text-[9px] text-muted-foreground tabular-nums">
      {countdown}s
    </span>
  );
}
