import { Link, useParams } from "react-router"; import { Fragment, useState } from "react"; import { useTranslation } from "react-i18next"; import { PaginationDto } from "~/application/dtos/data/PaginationDto"; import { Colors } from "~/application/enums/shared/Colors"; import SimpleBadge from "~/components/ui/badges/SimpleBadge"; import ExternalLinkEmptyIcon from "~/components/ui/icons/ExternalLinkEmptyIcon"; import OpenModal from "~/components/ui/modals/OpenModal"; import TableSimple from "~/components/ui/tables/TableSimple"; import { EventWithAttempts } from "../db/events.db.server"; import MonacoEditor from "~/components/editors/MonacoEditor"; import { Badge } from "~/components/ui/badge"; import { useLocaleFormatters } from "~/locale/format"; import { appPath } from "~/utils/app/CanonicalUrlUtils"; import { redactDiagnosticJsonString } from "~/utils/redaction"; import EventUtils from "../utils/EventUtils"; interface Props { items: EventWithAttempts[]; pagination: PaginationDto; } export default function EventsTable({ items, pagination }: Props) { const { t } = useTranslation(); const formatters = useLocaleFormatters(); const params = useParams(); const [selectedData, setSelectedData] = useState(undefined); const formattedData = (item: EventWithAttempts) => { return redactDiagnosticJsonString(item.data); }; return ( <> i.id, }, ]} pagination={pagination} headers={[ { name: "event", title: t("models.event.object"), value: (i) => EventUtils.parseName(i.name, t), formattedValue: (i) => (
{EventUtils.parseName(i.name, t)}
), }, { name: "data", title: t("models.event.data"), value: (i) => ( ), className: "w-full", }, // { // name: "attempts", // title: t("models.event.attempts"), // value: (i) => i.attempts.length, // formattedValue: (i) => ( //
// {i.attempts.map((f, idx) => ( // (
{!i.tenant ? ( {t("shared.notSet")} ) : (
{i.tenant?.name}
/{i.tenant.slug}
)}
), hidden: !!params.tenant, }, { name: "createdAt", title: t("shared.createdAt"), value: (i) => (
{i.user?.email ?? {t("shared.notSet")}}
{formatters.relativeDate(i.createdAt)}
), }, ]} /> {selectedData && ( setSelectedData(undefined)}>

{formatters.dateTime(selectedData.createdAt)}

{t("models.event.data")}

{}} theme="vs-dark" language="json" />
)} ); }