import { useEffect } from "react"; import Link from "next/link"; import { observer } from "mobx-react-lite"; import { History } from "lucide-react"; // hooks import { useDashboard, useUser } from "hooks/store"; // components import { ActivityIcon, ActivityMessage } from "components/core"; import { RecentActivityEmptyState, WidgetLoader, WidgetProps } from "components/dashboard/widgets"; // ui import { Avatar } from "@plane/ui"; // helpers import { calculateTimeAgo } from "helpers/date-time.helper"; // types import { TRecentActivityWidgetResponse } from "@plane/types"; const WIDGET_KEY = "recent_activity"; export const RecentActivityWidget: React.FC = observer((props) => { const { dashboardId, workspaceSlug } = props; // store hooks const { currentUser } = useUser(); // derived values const { fetchWidgetStats, getWidgetStats } = useDashboard(); const widgetStats = getWidgetStats(workspaceSlug, dashboardId, WIDGET_KEY); useEffect(() => { if (!widgetStats) fetchWidgetStats(workspaceSlug, dashboardId, { widget_key: WIDGET_KEY, }); }, [dashboardId, fetchWidgetStats, widgetStats, workspaceSlug]); if (!widgetStats) return ; return (
My activity {widgetStats.length > 0 ? (
{widgetStats.map((activity) => (
{activity.field ? ( activity.new_value === "restore" ? ( ) : (
) ) : activity.actor_detail.avatar && activity.actor_detail.avatar !== "" ? ( ) : (
{activity.actor_detail.is_bot ? activity.actor_detail.first_name.charAt(0) : activity.actor_detail.display_name.charAt(0)}
)}

{currentUser?.id === activity.actor_detail.id ? "You" : activity.actor_detail.display_name}{" "} {activity.field ? ( ) : ( created this{" "} Issue. )}

{calculateTimeAgo(activity.created_at)}

))}
) : (
)}
); });