interface interactive
This commit is contained in:
@@ -1,14 +1,23 @@
|
||||
import { generateAnonymizedText } from "@/app/utils/generateAnonymizedText";
|
||||
import { EntityMapping } from "@/app/config/entityLabels";
|
||||
|
||||
interface DownloadActionsProps {
|
||||
outputText: string;
|
||||
entityMappings?: EntityMapping[];
|
||||
}
|
||||
|
||||
export const useDownloadActions = ({ outputText }: DownloadActionsProps) => {
|
||||
export const useDownloadActions = ({
|
||||
outputText,
|
||||
entityMappings = [],
|
||||
}: DownloadActionsProps) => {
|
||||
const copyToClipboard = () => {
|
||||
navigator.clipboard.writeText(outputText);
|
||||
const anonymizedText = generateAnonymizedText(outputText, entityMappings);
|
||||
navigator.clipboard.writeText(anonymizedText);
|
||||
};
|
||||
|
||||
const downloadText = () => {
|
||||
const blob = new Blob([outputText], { type: "text/plain" });
|
||||
const anonymizedText = generateAnonymizedText(outputText, entityMappings);
|
||||
const blob = new Blob([anonymizedText], { type: "text/plain" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
@@ -20,4 +29,4 @@ export const useDownloadActions = ({ outputText }: DownloadActionsProps) => {
|
||||
};
|
||||
|
||||
return { copyToClipboard, downloadText };
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user