import React from "react"; import { cn } from "@/lib/utils"; import { formatCurrency } from "@/lib/format-currency"; import { Button } from "./button"; import { Plus } from "lucide-react"; export type AccountCarouselType = "bankAccount" | "credit" | "propertyLoan"; export interface AccountCarouselItem { id: string; name: string; /** Institution name (e.g. "Commonwealth Bank") */ institution: string; balance: number; } export interface AccountListCarouselProps { accounts: AccountCarouselItem[]; type: AccountCarouselType; /** When provided, shows an "Add Account" button at the end (hidden for propertyLoan) */ onAddAccount?: () => void; className?: string; } function AccountCard({ item, isCombined, }: { item: { name: string; institution?: string; balance: number }; isCombined?: boolean; }) { return (

{isCombined ? "All accounts" : item.institution}

{item.name}

{formatCurrency(item.balance)}

); } export function AccountListCarousel({ accounts, type, onAddAccount, className, }: AccountListCarouselProps) { const combinedBalance = accounts.reduce((sum, a) => sum + a.balance, 0); const showCombined = type === "bankAccount" && accounts.length > 0; const showAddButton = type !== "propertyLoan" && onAddAccount; return (
{showCombined && ( )} {accounts.map((account) => ( ))} {showAddButton && ( )}
); }