new interactive
This commit is contained in:
@@ -13,17 +13,19 @@ interface ProcessDocumentResponse {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
// Props du hook
|
||||
interface AnonymizationLogicProps {
|
||||
// Props du hook - Renommer pour correspondre à l'utilisation
|
||||
interface UseAnonymizationProps {
|
||||
setOutputText: (text: string) => void;
|
||||
setError: (error: string | null) => void;
|
||||
setEntityMappings: (mappings: EntityMapping[]) => void;
|
||||
setAnonymizedText?: (text: string) => void; // Nouveau paramètre optionnel
|
||||
}
|
||||
|
||||
// NOUVEAU: Définir les types pour le paramètre de anonymizeData
|
||||
interface AnonymizeDataParams {
|
||||
file?: File | null;
|
||||
text?: string;
|
||||
category?: string; // Ajouter le paramètre catégorie
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,10 +36,11 @@ export const useAnonymization = ({
|
||||
setOutputText,
|
||||
setError,
|
||||
setEntityMappings,
|
||||
}: AnonymizationLogicProps) => {
|
||||
setAnonymizedText,
|
||||
}: UseAnonymizationProps) => {
|
||||
const [isProcessing, setIsProcessing] = useState(false);
|
||||
|
||||
const anonymizeData = async ({ file, text }: AnonymizeDataParams) => {
|
||||
const anonymizeData = async ({ file, text, category = 'pii' }: AnonymizeDataParams) => {
|
||||
setIsProcessing(true);
|
||||
setError(null);
|
||||
setEntityMappings([]);
|
||||
@@ -46,6 +49,10 @@ export const useAnonymization = ({
|
||||
try {
|
||||
// ÉTAPE 1: Construire le FormData ici pour garantir le bon format
|
||||
const formData = new FormData();
|
||||
|
||||
// Ajouter la catégorie au FormData
|
||||
formData.append('category', category);
|
||||
|
||||
if (file) {
|
||||
formData.append("file", file);
|
||||
} else if (text) {
|
||||
@@ -74,7 +81,7 @@ export const useAnonymization = ({
|
||||
const replacementValues = data.replacementValues || {}; // Récupérer les valeurs de remplacement
|
||||
|
||||
// 🔍 AJOUT DES CONSOLE.LOG POUR DÉBOGUER
|
||||
console.log("📊 Données reçues de Presidio:", {
|
||||
console.log("📊 Réponse de l'API:", {
|
||||
originalTextLength: originalText.length,
|
||||
presidioResultsCount: presidioResults.length,
|
||||
presidioResults: presidioResults,
|
||||
@@ -83,8 +90,13 @@ export const useAnonymization = ({
|
||||
replacementValuesEntries: Object.entries(replacementValues),
|
||||
});
|
||||
|
||||
// ÉTAPE 2 : Passer le texte ORIGINAL à l'état de sortie.
|
||||
setOutputText(originalText);
|
||||
// ÉTAPE 2 : Utiliser le texte ANONYMISÉ de Presidio au lieu du texte original
|
||||
setOutputText(data.anonymizedText || originalText);
|
||||
|
||||
// NOUVEAU : Stocker le texte anonymisé de Presidio séparément
|
||||
if (setAnonymizedText && data.anonymizedText) {
|
||||
setAnonymizedText(data.anonymizedText);
|
||||
}
|
||||
|
||||
// ÉTAPE 3 : Créer le tableau de mapping avec la nouvelle structure
|
||||
const sortedResults = [...presidioResults].sort(
|
||||
@@ -111,7 +123,9 @@ export const useAnonymization = ({
|
||||
end: end,
|
||||
text: detectedText,
|
||||
replacementValue: replacementValues[detectedText],
|
||||
displayName: replacementValues[detectedText],
|
||||
displayName: replacementValues[detectedText]
|
||||
? replacementValues[detectedText].replace(/[\[\]]/g, "")
|
||||
: entity_type,
|
||||
customColor: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user