import React, { useMemo } from 'react'; import { History } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; function hasHistoricalVisibility(bill) { const visibility = bill.history_visibility; return !!bill.has_history_ranges || (visibility && visibility !== 'default'); } export const MobileBillRow = React.memo(function MobileBillRow({ bill, onEdit, onToggle, onDelete, onHistory }) { const hasHistory = useMemo(() => hasHistoricalVisibility(bill), [bill]); const statusClass = useMemo(() => { return cn( 'rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide', bill.active ? 'bg-emerald-500/15 text-emerald-500' : 'bg-muted text-muted-foreground', ); }, [bill.active]); const autopayClass = useMemo(() => { return cn( 'rounded bg-emerald-500/20 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-500', !!bill.autopay_enabled ? 'opacity-100' : 'opacity-0', ); }, [bill.autopay_enabled]); const toggleBtnClass = useMemo(() => { return cn( 'h-8 px-2.5 text-xs', bill.active ? 'text-muted-foreground hover:text-destructive' : 'text-emerald-500 hover:text-emerald-400', ); }, [bill.active]); return (
{hasHistory && ( )}
{bill.active ? 'Active' : 'Inactive'} {bill.autopay_enabled && ( AP )} {bill.has_2fa && ( 2FA )}
${Number(bill.expected_amount).toFixed(2)}

Due

Day {bill.due_day}

Category

{bill.category_name || '—'}

Cycle

{bill.billing_cycle || 'monthly'}

{!bill.active && ( )}
); }); MobileBillRow.displayName = 'MobileBillRow';