"use client";

import { Button } from "@/components/ui/button";
import { Loader2, Scan } from "lucide-react";

interface ScanFormProps {
  projectPath: string;
  onScan: () => Promise<void>;
  isScanning: boolean;
}

export function ScanForm({ projectPath, onScan, isScanning }: ScanFormProps) {
  const handleSubmit = async (e: React.FormEvent) => {
    e.preventDefault();
    if (!projectPath.trim() || isScanning) return;
    await onScan();
  };

  return (
    <form onSubmit={handleSubmit} className="space-y-4">
      <div>
        <label className="block text-sm font-medium text-foreground mb-2">
          Project Path
        </label>
        <p className="text-sm font-mono p-3 bg-muted rounded-md text-muted-foreground">
          {projectPath || "Not set (configure in sidebar)"}
        </p>
      </div>
      <Button type="submit" disabled={isScanning || !projectPath.trim()}>
        {isScanning ? (
          <>
            <Loader2 className="h-4 w-4 mr-2 animate-spin" />
            Scanning...
          </>
        ) : (
          <>
            <Scan className="h-4 w-4 mr-2" />
            Run Scan
          </>
        )}
      </Button>
    </form>
  );
}
