import { ClockIcon } from "@repo/rdx-ui/lib/icons"; import { useQuery } from "@tanstack/react-query"; import { useTranslation } from "react-i18next"; import { CompanyIdentity } from "../../../companies/shared/ui/company-identity"; import { BlockState, DashboardNavigationButton, DashboardPanel } from "../../shared"; import { dashboardApi, dashboardKeys } from "../../shared/api"; import type { DashboardNavigation } from "../../shared/helpers"; import { KIND_ICONS, entryDestination } from "../../shared/helpers"; export function DashboardActivityPanel({ companyId, onDetails, onNavigate, }: { companyId: string | undefined; onDetails: () => void; onNavigate: (destination: DashboardNavigation) => void; }) { const { t, i18n } = useTranslation("companies"); const activity = useQuery({ queryKey: dashboardKeys.block("activity", companyId), queryFn: ({ signal }) => dashboardApi.activity(signal, companyId), staleTime: 0, }); const date = (value: string | null) => value ? new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium", timeStyle: "short" }).format( new Date(value) ) : "—"; return ( } title={t("dashboard.recentActivity")}> {activity.data?.items.slice(0, 4).map((item) => { const Icon = KIND_ICONS[item.kind]; return ( {date(item.recordedAt)} onNavigate(entryDestination(item))}> {t("dashboard.recordUpdated", { name: item.name })} {item.actorName ? ` · ${item.actorName}` : ""} ); })} ); }
{item.actorName ? ` · ${item.actorName}` : ""}