import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Description as DialogDescription, Title as DialogTitle } from "@radix-ui/react-dialog"; import { FeatherArchive, FeatherEye, FeatherLock, FeatherShield } from "@subframe/core"; import type { ChatAuditOverviewVM } from "@hivegrid/view-models"; import { useLocaleFormatters } from "~/locale/format"; import { Alert } from "~/ui/components/Alert"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { Dialog } from "~/ui/components/Dialog"; import { EmptyState } from "~/ui/components/EmptyState"; import { Table } from "~/ui/components/Table"; import { TextArea } from "~/ui/components/TextArea"; import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageIntro, PageShell } from "../shared/PageShell"; export type ChatAuditOverviewActions = Readonly<{ onStartSession: (reason: string) => void | Promise; onEndSession: () => void | Promise; onOpenChannel: (href: string) => void | Promise; onArchiveChannel: (chatId: string) => void | Promise; }>; export function ChatAuditOverviewPage({ vm, actions, busy = false, actionErrorKey = null, embedded = false, }: { readonly vm: ChatAuditOverviewVM; readonly actions: ChatAuditOverviewActions; readonly busy?: boolean; readonly actionErrorKey?: string | null; /** Inside the Compliance hub (AK-SET-01) the hub owns the header. */ readonly embedded?: boolean; }): React.JSX.Element { const { t } = useTranslation(); const formatters = useLocaleFormatters(); const [reason, setReason] = useState(""); const [archiveCandidate, setArchiveCandidate] = useState<{ id: string; title: string } | null>(null); const data = vm.status === "ready" ? vm.data : null; return ( {embedded ? null : ( } title={t("chat.audit.title")} subtitle={t("chat.audit.description")} actions={ data?.session ? ( ) : null } /> )} {embedded ? (
{t("chat.audit.description")} {data?.session ? ( ) : null}
) : null} {actionErrorKey ? : null} {!data?.session ? (
) : ( <> {data.channels.length === 0 ? ( ) : (
{t("chat.audit.columns.channel")}{t("chat.audit.columns.kind")}{t("chat.audit.columns.members")}{t("chat.audit.columns.visibility")}{t("chat.audit.columns.lastActivity")}{t("chat.audit.columns.action")} } > {data.channels.map((channel) => (
{channel.title} {channel.participantLabels.length > 0 ? ( {channel.participantLabels.join(", ")} ) : null}
{t(channel.kindLabelKey)} {t("chat.audit.memberCount", { count: channel.memberCount })} {t(channel.isPrivate ? "chat.audit.visibility.private" : "chat.audit.visibility.public")} {channel.lastMessageAtIso ? formatters.date(channel.lastMessageAtIso, { dateStyle: "medium", timeStyle: "short" }) : t("chat.audit.noActivity")}
{channel.canArchive ? (
))}
)} )} (open ? undefined : setArchiveCandidate(null))}>
{t("chat.audit.confirm.archive.title")} {t("chat.audit.confirm.archive.bodyNamed", { channel: archiveCandidate?.title ?? "" })}
); }