import { slug } from 'github-slugger'
import { HeadingLink } from '@/frame/components/article/HeadingLink'
import { useTranslation } from '@/languages/components/useTranslation'
import type { AuditLogEventT } from '../types'
import styles from './GroupedEvents.module.scss'
type Props = {
auditLogEvents: AuditLogEventT[]
category: string
categoryNote?: string
}
export default function GroupedEvents({ auditLogEvents, category, categoryNote }: Props) {
const { t } = useTranslation('audit_logs')
const eventSlug = slug(category)
const renderReferenceLinks = (event: AuditLogEventT) => {
if (!event.docs_reference_links || event.docs_reference_links === 'N/A') {
return null
}
const links = event.docs_reference_links
.split(/[,\s]+/)
.map((link) => link.trim())
.filter((link) => link && link !== 'N/A')
.map((link) => (link.startsWith('/') ? link : `/${link}`))
const titles = event.docs_reference_titles ? event.docs_reference_titles.split(', ') : links
return links.map((link, index) => (
{titles[index] || link}
{index < links.length - 1 && ', '}
))
}
return (
<>
{categoryNote}
{event.action}
{field}
{index < event.fields!.length - 1 && ', '}
))
: 'No fields available'}