import { For, Show } from 'solid-js' import { FinanceSummaryCards } from '../components/finance/finance-summary-cards' import type { MiniAppDashboard } from '../miniapp-api' type Props = { copy: Record dashboard: MiniAppDashboard | null readyIsAdmin: boolean pendingMembersCount: number currentMemberLine: MiniAppDashboard['members'][number] | null utilityTotalMajor: string purchaseTotalMajor: string memberBaseDueMajor: (member: MiniAppDashboard['members'][number]) => string ledgerTitle: (entry: MiniAppDashboard['ledger'][number]) => string ledgerPrimaryAmount: (entry: MiniAppDashboard['ledger'][number]) => string ledgerSecondaryAmount: (entry: MiniAppDashboard['ledger'][number]) => string | null } export function HomeScreen(props: Props) { if (!props.dashboard) { return (
{props.copy.remainingLabel ?? ''}
{props.copy.shareRent ?? ''}
{props.copy.shareUtilities ?? ''}
{props.copy.purchasesTitle ?? ''}
) } return (
{props.copy.pendingRequests ?? ''} {String(props.pendingMembersCount)}
{(member) => (
{props.copy.yourBalanceTitle ?? ''} {member().remainingMajor} {props.dashboard!.currency}

{props.copy.shareRent ?? ''}: {props.dashboard!.rentSourceAmountMajor}{' '} {props.dashboard!.rentSourceCurrency} {props.dashboard!.rentSourceCurrency !== props.dashboard!.currency ? ` -> ${props.dashboard!.rentDisplayAmountMajor} ${props.dashboard!.currency}` : ''}

{props.copy.baseDue ?? ''} {props.memberBaseDueMajor(member())} {props.dashboard!.currency}
{props.copy.shareOffset ?? ''} {member().purchaseOffsetMajor} {props.dashboard!.currency}
{props.copy.finalDue ?? ''} {member().netDueMajor} {props.dashboard!.currency}
{props.copy.paidLabel ?? ''} {member().paidMajor} {props.dashboard!.currency}
{props.copy.remainingLabel ?? ''} {member().remainingMajor} {props.dashboard!.currency}
)}
{props.copy.latestActivityTitle ?? ''}
{props.dashboard.ledger.length === 0 ? (

{props.copy.latestActivityEmpty ?? ''}

) : (
{(entry) => (
{props.ledgerTitle(entry)} {props.ledgerPrimaryAmount(entry)}
{(secondary) =>

{secondary()}

}

{entry.actorDisplayName ?? props.copy.ledgerActorFallback ?? ''}

)}
)}
) }