This commit is contained in:
nBiqoz
2025-06-24 00:30:05 +02:00
parent bdbc126b11
commit 65fa45d8f3
2 changed files with 74 additions and 206 deletions

View File

@@ -18,18 +18,8 @@ import {
Lock,
Shield,
Clock,
User,
AtSign,
MapPin,
Cake,
Home as HomeIcon,
Venus,
Phone,
Building,
Fingerprint,
CreditCard,
Check,
Eye,
TestTube,
} from "lucide-react";
import PresidioModal from "./components/PresidioModal";
@@ -51,23 +41,6 @@ interface ProcessedFile {
anonymizedText?: string;
}
interface AnonymizationOptions {
[key: string]: boolean;
}
const piiOptions = [
{ id: "name", label: "Nom & Prénom", icon: User },
{ id: "email", label: "Email", icon: AtSign },
{ id: "location", label: "Lieu", icon: MapPin },
{ id: "birthdate", label: "Date de naissance", icon: Cake },
{ id: "address", label: "Adresse", icon: HomeIcon },
{ id: "gender", label: "Genre / Sexe", icon: Venus },
{ id: "phone", label: "Téléphone", icon: Phone },
{ id: "organization", label: "Entreprise", icon: Building },
{ id: "idNumber", label: "N° Identification", icon: Fingerprint },
{ id: "financial", label: "Données financières", icon: CreditCard },
];
export default function Home() {
const [file, setFile] = useState<File | null>(null);
const [isProcessing, setIsProcessing] = useState(false);
@@ -75,19 +48,12 @@ export default function Home() {
const [isDragOver, setIsDragOver] = useState(false);
const [history, setHistory] = useState<ProcessedFile[]>([]);
const [error, setError] = useState<string | null>(null);
const [anonymizationOptions, setAnonymizationOptions] =
useState<AnonymizationOptions>(
piiOptions.reduce((acc, option) => ({ ...acc, [option.id]: true }), {})
);
const [showPresidioModal, setShowPresidioModal] = useState(false);
const [anonymizedResult, setAnonymizedResult] = useState<{
text: string;
piiCount: number;
} | null>(null);
const handleOptionChange = (id: string) =>
setAnonymizationOptions((prev) => ({ ...prev, [id]: !prev[id] }));
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.target.files?.length) {
setFile(e.target.files[0]);
@@ -180,6 +146,29 @@ export default function Home() {
}
};
const loadTestDocument = () => {
try {
// Créer un document de test avec des données PII fictives
const testContent = `Rapport pour la société belge "Solution Globale SPRL" (BCE : BE 0987.654.321).
Contact principal : M. Luc Dubois, né le 15/03/1975.
Son numéro de registre national est le 75.03.15-123.45.
Adresse : Avenue des Arts 56, 1000 Bruxelles.
Téléphone : +32 2 555 12 34. Email : luc.dubois@solutionglobale.be.
Le paiement de la facture a été effectué par carte VISA 4979 1234 5678 9012.
Le remboursement sera versé sur le compte IBAN BE12 3456 7890 1234, code SWIFT : GEBABEBB.`;
const testBlob = new Blob([testContent], { type: "text/plain" });
const testFile = new File([testBlob], "document-test.txt", {
type: "text/plain",
});
setFile(testFile);
setError(null);
} catch {
setError("Erreur lors du chargement du document de test");
}
};
const processFile = async () => {
if (!file) return;
@@ -198,6 +187,7 @@ export default function Home() {
},
...prev,
]);
setFile(null);
try {
@@ -444,36 +434,19 @@ export default function Home() {
)}
</div>
</div>
<div className="flex-grow">
<h3 className="text-base font-black text-white uppercase tracking-wide mb-3">
Options d&apos;Anonymisation
</h3>
<div className="grid grid-cols-2 lg:grid-cols-2 gap-x-4 gap-y-2">
{piiOptions.map((option) => (
<label
key={option.id}
htmlFor={option.id}
className="flex items-center gap-2 cursor-pointer group"
>
<input
type="checkbox"
id={option.id}
className="sr-only peer"
checked={anonymizationOptions[option.id]}
onChange={() => handleOptionChange(option.id)}
/>
<div className="w-5 h-5 border-2 border-white shadow-[2px_2px_0_0_black] flex items-center justify-center transition-all peer-checked:bg-[#F7AB6E] peer-checked:border-[#F7AB6E]">
{anonymizationOptions[option.id] && (
<Check className="h-4 w-4 text-white" />
)}
</div>
<span className="font-bold text-xs text-white uppercase">
{option.label}
</span>
</label>
))}
</div>
{/* Bouton pour charger un document de test */}
<div className="flex-grow flex items-center justify-center">
<Button
onClick={loadTestDocument}
disabled={isProcessing}
className="bg-[#061717] text-white border-4 border-white shadow-[6px_6px_0_0_black] hover:shadow-[3px_3px_0_0_black] active:shadow-none active:translate-x-1 active:translate-y-1 h-12 px-6 text-base font-black uppercase tracking-wide disabled:opacity-50"
>
<TestTube className="h-5 w-5 mr-2" />
Charger Document de Test
</Button>
</div>
{isProcessing && (
<div className="space-y-2">
<div className="flex justify-between items-center">