interface DownloadActionsProps {
  outputText: string;
}

export const useDownloadActions = ({ outputText }: DownloadActionsProps) => {
  const copyToClipboard = () => {
    navigator.clipboard.writeText(outputText);
  };

  const downloadText = () => {
    const blob = new Blob([outputText], { type: "text/plain" });
    const url = URL.createObjectURL(blob);
    const a = document.createElement("a");
    a.href = url;
    a.download = "texte-anonymise.txt";
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
  };

  return { copyToClipboard, downloadText };
};