import MoneyValues from "@/components/money-values"; import type { TopEstablishmentsData } from "@/lib/dashboard/top-establishments"; import { RiStore2Line } from "@remixicon/react"; import Image from "next/image"; import { WidgetEmptyState } from "../widget-empty-state"; type TopEstablishmentsWidgetProps = { data: TopEstablishmentsData; }; const resolveLogoPath = (logo: string | null) => { if (!logo) { return null; } if (/^(https?:\/\/|data:)/.test(logo)) { return logo; } return logo.startsWith("/") ? logo : `/logos/${logo}`; }; const buildInitials = (value: string) => { const parts = value.trim().split(/\s+/).filter(Boolean); if (parts.length === 0) { return "LC"; } if (parts.length === 1) { const firstPart = parts[0]; return firstPart ? firstPart.slice(0, 2).toUpperCase() : "LC"; } const firstChar = parts[0]?.[0] ?? ""; const secondChar = parts[1]?.[0] ?? ""; return `${firstChar}${secondChar}`.toUpperCase() || "LC"; }; const formatOccurrencesLabel = (occurrences: number) => { if (occurrences === 1) { return "1 lançamento"; } return `${occurrences} lançamentos`; }; export function TopEstablishmentsWidget({ data, }: TopEstablishmentsWidgetProps) { return (
{data.establishments.length === 0 ? ( } title="Nenhum estabelecimento encontrado" description="Quando houver despesas registradas, elas aparecerão aqui." /> ) : ( )}
); }