Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt committed Jul 9, 2024
1 parent c6fb719 commit 6b4e791
Showing 1 changed file with 8 additions and 34 deletions.
42 changes: 8 additions & 34 deletions packages/frontend/utils/enrichment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function renderLanguageEnrichment(languageDetections: LanguageDetectionResult) {
</Group>
)
}

function renderPIIEnrichment(data: Record<string, any[]>) {
const [opened, { close, open }] = useDisclosure(false)

Expand Down Expand Up @@ -84,39 +83,14 @@ function renderPIIEnrichment(data: Record<string, any[]>) {
{piiCount} PII
</Badge>
</Popover.Target>
<Popover.Dropdown style={{ pointerEvents: "none" }} w="300">
<Stack>
{Object.entries(data)
.filter(([_, items]) => items.some(Boolean))
.map(([key, items]) => {
const uniqueItemEntities = new Set()
items
.filter(Boolean)
.forEach((item) =>
item.forEach((subItem: { entity: string }) =>
uniqueItemEntities.add(subItem.entity),
),
)
return (
<div key={key}>
<strong style={{ textTransform: "capitalize" }}>
{key}:
</strong>
<Group>
{Array.from(uniqueItemEntities).map((entity) => (
<Badge
key={entity as string}
variant="filled"
color="blue"
>
{entity as string}
</Badge>
))}
</Group>
</div>
)
})}
</Stack>
<Popover.Dropdown style={{ pointerEvents: "none" }} w={300}>
<Group justify="space-between">
{Array.from(uniqueEntities).map((entity) => (
<Badge key={entity as string} variant="light">
{entity as string}
</Badge>
))}
</Group>
</Popover.Dropdown>
</Popover>
)
Expand Down

0 comments on commit 6b4e791

Please sign in to comment.