import { Link as RouterLink } from "react-router-dom"; import Box from "@mui/material/Box"; import Typography from "@mui/material/Typography"; import { Card, Button, EmptyState } from "../../ui"; import { iconBadgeSx, type IconBadgeColor } from "../../theme"; import { ENTITY_TYPE_LABELS, getActivityIconClass, formatActivityTime, } from "../../utils/dashboardHelpers"; interface Activity { id: number | string; action: string; description: string; username?: string; entity_type: string; created_at: string; } interface DashActivityFeedProps { activities: Activity[] | null; } // Maps the legacy activity-icon class to the MUI palette key used to tint the // circular icon badge (danger → error, accent → primary, muted → default). const ACTIVITY_BADGE_COLOR: Record = { success: "success", info: "info", danger: "error", accent: "primary", muted: "default", }; function getActivityIcon(action: string) { switch (action) { case "create": return ( ); case "update": return ( ); case "delete": return ( ); case "login": return ( ); default: return ( ); } } export default function DashActivityFeed({ activities, }: DashActivityFeedProps) { if (!activities) { return null; } return ( Audit log {activities.length === 0 ? ( ) : ( {activities.map((act) => { const badgeColor = ACTIVITY_BADGE_COLOR[getActivityIconClass(act.action)] ?? "default"; const isDefault = badgeColor === "default"; return ( {getActivityIcon(act.action)} {act.description} {act.username || "Systém"} ·{" "} {ENTITY_TYPE_LABELS[act.entity_type] || act.entity_type} {formatActivityTime(act.created_at)} ); })} )} ); }