import { Link } from '@tanstack/react-router' import type { StudentFee } from '@gruperly/shared' import { ExternalLink, Receipt } from 'lucide-react' import { Badge } from '../../components/ui' import { formatPrice } from '../../lib/format' import { feeLabel } from './format' import { FeeStatusBadge } from './FeeStatusBadge' import { useTranslation } from 'react-i18next' /* "Tu cuota": only while there is something unpaid. */ export function FeeCard({ fees }: { fees: StudentFee[] }) { const { t } = useTranslation(['student', 'common']) if (fees.length === 0) return null const first = fees[0] as StudentFee const toReport = fees.filter((fee) => fee.status !== 'reported') const total = toReport.reduce((sum, fee) => sum + fee.amount, 0) // Cada cuota tiene su propio link de MP: con varias, se elige en Pagos. const payable = toReport.filter((fee) => fee.checkoutUrl) const single = payable.length === 1 ? (payable[0] as StudentFee) : null const primary = 'flex min-h-12 items-center justify-center gap-2 rounded-xl bg-accent font-semibold text-on-accent hover:bg-accent-strong' return (

{t('fee.yourFee')}

{fees.length === 1 ? feeLabel(first) : t('fee.unpaid', { count: fees.length })}

{formatPrice(toReport.length > 0 ? total : first.amount, first.currency)}

{fees.length === 1 ? ( ) : toReport.some((fee) => fee.status === 'overdue') ? ( {t('fee.overdue')} ) : null}
{toReport.length > 0 ? (
{single ? ( {t('fee.payMp')} ) : payable.length > 1 ? ( {t('fee.payMp')} ) : null} 0 ? 'flex min-h-12 items-center justify-center gap-2 rounded-xl border border-border font-semibold text-primary hover:bg-primary-soft' : primary } >
) : (

{t('fee.awaiting')}

)}
) }