"use client" import { useState } from "react" import { formatDistanceToNow } from "date-fns" import { DollarSign, UserPlus, Wrench, FileText, AlertTriangle, Building2, ClipboardCheck, Users, Receipt, Zap, Activity, } from "lucide-react" const typeConfig: Record = { rent_paid: { icon: DollarSign, color: "text-emerald-400", bg: "bg-emerald-500/10" }, rent_overdue: { icon: AlertTriangle, color: "text-red-400", bg: "bg-red-500/10" }, tenant_added: { icon: UserPlus, color: "text-blue-400", bg: "bg-blue-500/10" }, tenant_removed: { icon: Users, color: "text-orange-400", bg: "bg-orange-500/10" }, maintenance_opened: { icon: Wrench, color: "text-yellow-400", bg: "bg-yellow-500/10" }, maintenance_resolved: { icon: ClipboardCheck, color: "text-emerald-400", bg: "bg-emerald-500/10" }, lease_created: { icon: FileText, color: "text-indigo-400", bg: "bg-indigo-500/10" }, lease_expiring: { icon: AlertTriangle, color: "text-amber-400", bg: "bg-amber-500/10" }, expense_added: { icon: Receipt, color: "text-purple-400", bg: "bg-purple-500/10" }, property_added: { icon: Building2, color: "text-cyan-400", bg: "bg-cyan-500/10" }, inspection_completed: { icon: ClipboardCheck, color: "text-teal-400", bg: "bg-teal-500/10" }, vendor_added: { icon: Users, color: "text-pink-400", bg: "bg-pink-500/10" }, ai_action: { icon: Zap, color: "text-violet-400", bg: "bg-violet-500/10" }, } const FILTER_OPTIONS = [ { label: "All", value: "" }, { label: "Rent", value: "rent" }, { label: "Tenants", value: "tenant" }, { label: "Maintenance", value: "maintenance" }, { label: "Leases", value: "lease" }, { label: "AI", value: "ai" }, ] export function ActivityFeed({ activities }: { activities: any[] }) { const [filter, setFilter] = useState("") const filtered = filter ? activities.filter((a) => a.type.startsWith(filter)) : activities return (
{/* Header */}

Activity Feed

{filtered.length} events

{/* Filters */}
{FILTER_OPTIONS.map((f) => ( ))}
{/* Feed */} {filtered.length === 0 ? (

No activity yet

Actions like adding tenants, recording payments, and maintenance requests will appear here

) : (
{filtered.map((activity) => { const cfg = typeConfig[activity.type] ?? { icon: Activity, color: "text-white/40", bg: "bg-white/5" } const Icon = cfg.icon return (

{activity.title}

{activity.description && (

{activity.description}

)}

{formatDistanceToNow(new Date(activity.created_at), { addSuffix: true })}

) })}
)}
) }