"use client"; import { Transaction } from "@/lib/types"; import { formatDistanceToNow } from "date-fns"; import EmptyState from "@/components/ui/EmptyState"; interface Props { transactions: Transaction[]; branchNames: Record; connected: boolean; scope: "global" | "branch"; } const statusStyles: Record = { SUCCESS: "bg-confirm-500/15 text-confirm-600", PENDING: "bg-cash-500/15 text-cash-600", FAILED: "bg-alert-500/15 text-alert-600", }; export default function ActivityFeedMatrix({ transactions, branchNames, connected, scope }: Props) { return (

Live activity feed

{connected ? "Live" : "Reconnecting…"}
    {transactions.length === 0 && (
  • )} {transactions.map((t) => { const branchId = typeof t.branchId === "string" ? t.branchId : t.branchId._id; const branchLabel = typeof t.branchId === "object" ? t.branchId.branchName : branchNames[branchId] ?? "—"; return (
  • {t.customerName || t.customerPhone || "Walk-in customer"}

    {scope === "global" && ( {branchLabel} )}

    {t.quantity} × {t.sizeLiters}L · {t.paymentMethod === "CASH" ? "Cash" : "M-Pesa"} ·{" "} {formatDistanceToNow(new Date(t.createdAt), { addSuffix: true })}

    KES {t.amountTotal.toLocaleString()} {t.paymentStatus}
  • ); })}
); }