import React from "react"; import { cn } from "@/lib/utils"; import { formatCurrency } from "@/lib/format-currency"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; /** * Displays a read-only list of income entries with edit/delete actions and an * "Add income" CTA. Extracted from the loan application income tab. * Consumers pre-calculate per-year totals before passing them in. */ export type IncomeSummaryItem = { /** Primary label — e.g. "Developer at Acme Corp" or "Rental Income" */ title: string; /** Annualised income in whole dollars */ amountPerYear: number; /** Optional duration string — "Employed for 3.5 yrs" */ employmentDuration?: string; /** Small tag chips — employment status, basis, type */ statusTags?: string[]; /** Non-PAYG income source label */ source?: string; }; export type IncomeSummaryComponentProps = { incomes: IncomeSummaryItem[]; onAdd: () => void; onEdit: (index: number) => void; onDelete: (index: number) => void; className?: string; }; export function IncomeSummaryComponent({ incomes, onAdd, onEdit, onDelete, className, }: IncomeSummaryComponentProps) { if (!incomes.length) { return (

No incomes added yet.

); } return (
{incomes.map((income, index) => (
{/* Title row + actions */}
{income.title}
{/* Amount + duration */}
{formatCurrency(income.amountPerYear)} Per Year {income.employmentDuration && ( {income.employmentDuration} )}
{/* Status tags */} {income.statusTags && income.statusTags.length > 0 && (
{income.statusTags.map((tag) => ( {tag} ))}
)} {/* Non-PAYG source */} {income.source && ( Source: {income.source} )}
))}
); }