import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { EntityMapping } from "../config/entityLabels"; interface EntityMappingTableProps { mappings: EntityMapping[]; selectedCategory?: string; } // Fonction pour filtrer les entités selon la catégorie const filterMappingsByCategory = ( mappings: EntityMapping[], category: string = "pii_business" ): EntityMapping[] => { if (category === "pii_business") { return mappings; // Tout afficher } // Définir les entités PII (Données personnelles) const piiEntities = new Set([ // Données personnelles de base "PERSONNE", "PERSON", "DATE", "DATE_TIME", "EMAIL_ADDRESS", "ADRESSE_EMAIL", "PHONE_NUMBER", "TELEPHONE", "CREDIT_CARD", "IBAN", "ADRESSE_IP", // Adresses personnelles "ADRESSE", "ADRESSE_FRANCAISE", "ADRESSE_BELGE", "LOCATION", // Téléphones personnels "TELEPHONE_FRANCAIS", "TELEPHONE_BELGE", // Documents d'identité personnels "NUMERO_SECURITE_SOCIALE_FRANCAIS", "REGISTRE_NATIONAL_BELGE", "CARTE_IDENTITE_FRANCAISE", "CARTE_IDENTITE_BELGE", "PASSEPORT_FRANCAIS", "PASSEPORT_BELGE", "PERMIS_CONDUIRE_FRANCAIS", // Données financières personnelles "COMPTE_BANCAIRE_FRANCAIS", // Données sensibles RGPD "HEALTH_DATA", "DONNEES_SANTE", "SEXUAL_ORIENTATION", "ORIENTATION_SEXUELLE", "POLITICAL_OPINIONS", "OPINIONS_POLITIQUES", "BIOMETRIC_DATA", "DONNEES_BIOMETRIQUES", "RGPD_FINANCIAL_DATA", "DONNEES_FINANCIERES_RGPD", // Identifiants personnels "IDENTIFIANT_PERSONNEL", ]); // Définir les entités Business (Données d'entreprise) const businessEntities = new Set([ // Organisations et sociétés "ORGANISATION", "ORGANIZATION", "SOCIETE_FRANCAISE", "SOCIETE_BELGE", // Identifiants fiscaux et d'entreprise "TVA_FRANCAISE", "TVA_BELGE", "NUMERO_FISCAL_FRANCAIS", "SIRET_SIREN_FRANCAIS", "NUMERO_ENTREPRISE_BELGE", // Identifiants professionnels "ID_PROFESSIONNEL_BELGE", // Données commerciales "MARKET_SHARE", "SECRET_COMMERCIAL", "REFERENCE_CONTRAT", "MONTANT_FINANCIER", // Données techniques d'entreprise "CLE_API_SECRETE", ]); // Définir les entités mixtes (PII + Business) const mixedEntities = new Set([ // Données pouvant être personnelles ou professionnelles "TITRE_CIVILITE", "DONNEES_PROFESSIONNELLES", "LOCALISATION_GPS", "URL_IDENTIFIANT", ]); if (category === "pii") { // Inclure PII + mixtes const allowedEntities = new Set([...piiEntities, ...mixedEntities]); return mappings.filter((mapping) => allowedEntities.has(mapping.entity_type) ); } if (category === "business") { // Inclure Business + mixtes const allowedEntities = new Set([...businessEntities, ...mixedEntities]); return mappings.filter((mapping) => allowedEntities.has(mapping.entity_type) ); } // Par défaut, retourner tous les mappings return mappings; }; export const EntityMappingTable = ({ mappings, selectedCategory = "pii_business", }: EntityMappingTableProps) => { // Filtrer les mappings selon la catégorie sélectionnée const filteredMappings = filterMappingsByCategory(mappings, selectedCategory); if (!mappings || mappings.length === 0) { return ( Entités détectées Aucune entité détectée dans le document. ); } if (filteredMappings.length === 0) { const categoryNames = { pii: "PII (Données Personnelles)", business: "Business (Données Métier)", pii_business: "PII + Business", }; return ( Entités détectées -{" "} {categoryNames[selectedCategory as keyof typeof categoryNames] || "Toutes"} Aucune entité de type " {categoryNames[selectedCategory as keyof typeof categoryNames] || "sélectionné"} " détectée dans le document. ); } // Créer un compteur pour chaque type d'entité (sur les mappings filtrés) const entityCounts: { [key: string]: number } = {}; const mappingsWithNumbers = filteredMappings.map((mapping) => { const entityType = mapping.entity_type; entityCounts[entityType] = (entityCounts[entityType] || 0) + 1; return { ...mapping, entityNumber: entityCounts[entityType], displayName: mapping.entity_type, }; }); const categoryNames = { pii: "PII (Données Personnelles)", business: "Business (Données Métier)", pii_business: "PII + Business", }; return ( Entités détectées -{" "} {categoryNames[selectedCategory as keyof typeof categoryNames] || "Toutes"}{" "} ({filteredMappings.length}/{mappings.length}) {/* Version mobile : Cards empilées */} {mappingsWithNumbers.map((mapping, index) => ( {mapping.displayName} Texte détecté {mapping.text} Identifiant {mapping.displayName} #{mapping.entityNumber} ))} {/* Version desktop : Table classique */} Type d'entité Texte détecté Identifiant {mappingsWithNumbers.map((mapping, index) => ( {mapping.displayName} {mapping.text} {mapping.displayName} #{mapping.entityNumber} ))} ); };
Aucune entité détectée dans le document.
Aucune entité de type " {categoryNames[selectedCategory as keyof typeof categoryNames] || "sélectionné"} " détectée dans le document.