import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
import { Select } from '@/components/ui/select';
import { Spinner } from '@/components/ui/Spinner';
import { Share2 } from 'lucide-react';

interface ShareLinkManagerCreateFormProps {
  expiresIn: number;
  setExpiresIn: (v: number) => void;
  isPublic: boolean;
  setIsPublic: (v: boolean) => void;
  isPending: boolean;
  onCreate: () => void;
  onCancel: () => void;
  expiryOptions: readonly { value: string; label: string }[];
}

export function ShareLinkManagerCreateForm({
  expiresIn,
  setExpiresIn,
  isPublic,
  setIsPublic,
  isPending,
  onCreate,
  onCancel,
  expiryOptions,
}: ShareLinkManagerCreateFormProps) {
  return (
    <div className="p-4 border rounded-lg space-y-4 bg-muted/50">
      <div className="space-y-2">
        <Label>Expiration (jours)</Label>
        <Select
          value={expiresIn.toString()}
          onChange={(value) => setExpiresIn(Number(value))}
          options={[...expiryOptions]}
        />
      </div>
      <div className="flex items-center gap-2">
        <input
          type="checkbox"
          id="isPublic"
          checked={isPublic}
          onChange={(e) => setIsPublic(e.target.checked)}
          className="rounded"
        />
        <Label htmlFor="isPublic" className="cursor-pointer">
          Lien public (accessible sans authentification)
        </Label>
      </div>
      <div className="flex gap-2">
        <Button
          onClick={onCreate}
          disabled={isPending}
          className="flex-1"
        >
          {isPending ? (
            <>
              <Spinner size="sm" className="mr-2" />
              Création...
            </>
          ) : (
            <>
              <Share2 className="h-4 w-4 mr-2" />
              Créer le lien
            </>
          )}
        </Button>
        <Button
          variant="outline"
          onClick={onCancel}
          disabled={isPending}
        >
          Annuler
        </Button>
      </div>
    </div>
  );
}
