'use client'; /** * PreviousPeriodCard — Displays the previous quarter summary. * * Shows "Período anterior" heading with the quarter date range, a status * badge, the final balance in CLP, an expandable "Mostrar detalles" section, * and a "Descargar Declaración" dropdown button. * * Requirements: 5.1, 5.2, 5.3, 5.4, 5.5 */ import { useState } from 'react'; import type { PortalPeriod } from '@/lib/mock-data/types'; import { useCompactCurrencyFormatter } from '@/lib/hooks/useCurrencyFormatter'; import { useTranslation } from '@/lib/hooks/useTranslation'; interface PreviousPeriodCardProps { period: PortalPeriod; } /** Map period status to badge styling */ function statusBadgeClass(status: PortalPeriod['status']): string { switch (status) { case 'Establecido': return 'bg-green-900/40 text-green-400 border-green-700/50'; case 'Activo': return 'bg-blue-900/40 text-blue-400 border-blue-700/50'; case 'Pendiente': return 'bg-yellow-900/40 text-yellow-400 border-yellow-700/50'; default: return 'bg-gray-900/40 text-gray-400 border-gray-700/50'; } } export default function PreviousPeriodCard({ period }: PreviousPeriodCardProps) { const [showDetails, setShowDetails] = useState(false); const [showDownload, setShowDownload] = useState(false); const t = useTranslation(); const fmtMoney = useCompactCurrencyFormatter(); return (
{period.label}
{t.portal.finalBalance}
{fmtMoney(period.balance)}
{t.portal.advances}
{fmtMoney(period.advances)}
{t.portal.adjustments}
{fmtMoney(period.adjustments)}
{t.portal.netEarnings}
{fmtMoney(period.netEarnings)}