'use client';

import { useReloadConfig } from '@/lib/hooks/useSupervisor';
import { Button } from '@/components/ui/button';
import { RefreshCw } from 'lucide-react';
import { cn } from '@/lib/utils/cn';

export function ReloadConfigButton() {
  const reloadMutation = useReloadConfig();

  const handleReload = () => {
    if (confirm('Are you sure you want to reload the configuration? This will apply any changes made to supervisord.conf.')) {
      reloadMutation.mutate();
    }
  };

  return (
    <Button
      onClick={handleReload}
      disabled={reloadMutation.isPending}
      variant="outline"
      className="gap-2"
    >
      <RefreshCw className={cn('h-4 w-4', reloadMutation.isPending && 'animate-spin')} />
      Reload Configuration
    </Button>
  );
}
